<controls:MetroWindow x:Class="SPCode.UI.Windows.OptionsWindow"
                      xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
                      xmlns:components="clr-namespace:SPCode.UI.Components"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      Width="680" 
                      Height="400" 
                      ResizeMode="NoResize" 
                      WindowStartupLocation="CenterOwner" 
                      GlowBrush="{DynamicResource AccentColorBrush}" 
                      Background="{DynamicResource WhiteBrush}"
                      ShowTitleBar="True"
                      Title="Options"
                      TitleCharacterCasing="Normal"
                      KeyDown="MetroWindow_KeyDown">

  <controls:MetroWindow.Resources>
    <ResourceDictionary>

      <Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{DynamicResource WhiteBrush}"/>
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
              <Border Background="{TemplateBinding Background}" BorderBrush="{DynamicResource AccentColorBrush}">
                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
              </Border>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
        <Style.Triggers>
          <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="Background" Value="{DynamicResource AccentColorBrush4}"/>
          </Trigger>
          <Trigger Property="IsPressed" Value="True">
            <Setter Property="Background" Value="{DynamicResource AccentColorBrush2}"/>
          </Trigger>
        </Style.Triggers>
      </Style>

      <Image x:Key="ImgReload" Source="/SPCode;component/Resources/Icons/icon-reload.png" Width="16"/>

      <Style BasedOn="{StaticResource {x:Type CheckBox}}" x:Key="IndentedCheckBox" TargetType="{x:Type CheckBox}">
        <Setter Property="Margin" Value="25,7,0,0"/>
      </Style>

      <Style BasedOn="{StaticResource {x:Type CheckBox}}" x:Key="ParentCheckBox" TargetType="{x:Type CheckBox}">
        <Setter Property="Margin" Value="5,7,0,0"/>
      </Style>

      <Style x:Key="ColorChangeControlStyle" TargetType="{x:Type components:ColorChangeControl}">
        <Setter Property="Margin" Value="5,10,5,0"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Height" Value="105"/>
        <Setter Property="Width" Value="320"/>
      </Style>

      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
      </ResourceDictionary.MergedDictionaries>

    </ResourceDictionary>
  </controls:MetroWindow.Resources>

  <controls:MetroWindow.RightWindowCommands>
    <controls:WindowCommands>
      <Button Name="BackupButton" Click="BackupButton_Clicked" />
      <Button Name="LoadButton" Click="LoadButton_Clicked" />
      <Button Name="ResetButton" Click="RestoreButton_Clicked" />
    </controls:WindowCommands>
  </controls:MetroWindow.RightWindowCommands>

  <Grid x:Name="OptionsWindowMainGrid">

    <controls:MetroAnimatedSingleRowTabControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,5,0,0" controls:TabControlHelper.IsUnderlined="True">

      <!-- Program Tab -->
      <controls:MetroTabItem Name="ProgramHeader">
        <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Visible">

          <Grid>

            <Grid.ColumnDefinitions>
              <ColumnDefinition/>
              <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <!-- Left side checkboxes -->
            <StackPanel Grid.Column="0">

              <StackPanel.Resources>
                <Style BasedOn="{StaticResource ParentCheckBox}" TargetType="{x:Type CheckBox}"/>
              </StackPanel.Resources>

              <CheckBox Name="HardwareAcc" Checked="HardwareAcc_Changed" Unchecked="HardwareAcc_Changed" />
              <CheckBox Name="UIAnimation" Checked="UIAnimation_Changed" Unchecked="UIAnimation_Changed" />
              <CheckBox Name="OpenIncludes" Checked="AutoOpenInclude_Changed" Unchecked="AutoOpenInclude_Changed" />
              <CheckBox Name="OpenIncludesRecursive" Style="{StaticResource IndentedCheckBox}" Checked="OpenIncludeRecursively_Changed" Unchecked="OpenIncludeRecursively_Changed" />
              <CheckBox Name="AutoUpdate" Checked="AutoUpdate_Changed" Unchecked="AutoUpdate_Changed" />
              <CheckBox Name="ShowToolBar" Checked="ShowToolbar_Changed" Unchecked="ShowToolbar_Changed" />
              <CheckBox Name="DynamicISAC" Checked="DynamicISAC_Changed" Unchecked="DynamicISAC_Changed" />
              <CheckBox Name="DarkTheme" Checked="DarkTheme_Changed" Unchecked="DarkTheme_Changed" />
              <CheckBox Name="HardwareSalts" Checked="HardwareSalts_Changed" Unchecked="HardwareSalts_Changed" />
              <CheckBox Name="DiscordPresence" Checked="DiscordPresence_Changed" Unchecked="DiscordPresence_Changed" />
              <CheckBox Name="DiscordPresenceTime" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceTime_Changed" Unchecked="DiscordPresenceTime_Changed" />
              <CheckBox Name="DiscordPresenceFile" Style="{StaticResource IndentedCheckBox}" Checked="DiscordPresenceFile_Changed" Unchecked="DiscordPresenceFile_Changed" />

            </StackPanel>

            <!-- Right side comboboxes -->
            <StackPanel Grid.Column="1">

              <StackPanel Orientation="Horizontal">
                <Label Name="ThemeColorLabel" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,10,0"/>
                <ComboBox Name="AccentColor" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" SelectionChanged="AccentColor_Changed" />
              </StackPanel>

              <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                <Label Name="LanguageLabel" Margin="0,0,10,0" />
                <ComboBox Name="LanguageBox" Width="120" SelectionChanged="LanguageBox_Changed" />
                <Button x:Name="ReloadLanguageButton" Style="{StaticResource ButtonStyle}" Content="{StaticResource ImgReload}" Click="ReloadLanguageButton_Click" Height="22" Width="22" Margin="5,0,0,0"/>
              </StackPanel>

              <StackPanel Orientation="Horizontal" Margin="0,10,0,0">
                <Label Name="ActionOnCloseLabel" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,0,10,0"/>
                <ComboBox Name="ActionOnCloseBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="180" SelectionChanged="ActionOnCloseBox_Changed" />
              </StackPanel>

            </StackPanel>

          </Grid>

        </ScrollViewer>
      </controls:MetroTabItem>

      <!-- Editor Tab -->
      <controls:MetroTabItem Name="EditorHeader">
        <ScrollViewer>
          <Grid>
            <StackPanel>

              <!-- Upper grid -->
              <Grid>

                <Grid.ColumnDefinitions>
                  <ColumnDefinition/>
                  <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <StackPanel Grid.Column="0" Margin="5,5,0,0">

                  <TextBlock Name="FontSizeBlock" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
                  <Slider Name="FontSizeD" HorizontalAlignment="Left" Margin="0,5,0,0" VerticalAlignment="Top" Width="280" Minimum="5" Maximum="30" AutoToolTipPlacement="TopLeft" TickFrequency="1" IsSnapToTickEnabled="True" TickPlacement="BottomRight" ValueChanged="FontSize_Changed" />

                  <TextBlock Name="FontFamilyTB" Margin="0,15,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
                  <ComboBox Name="FontFamilyCB" HorizontalAlignment="Left" VerticalAlignment="Top" Width="250" xmlns:ComponentModel="clr-namespace:System.ComponentModel;assembly=WindowsBase" ItemTemplate="{DynamicResource FontTemplate}" SelectionChanged="FontFamily_Changed">
                    <ComboBox.Resources>
                      <CollectionViewSource x:Key="myFonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
                        <CollectionViewSource.SortDescriptions>
                          <ComponentModel:SortDescription PropertyName="Source" />
                        </CollectionViewSource.SortDescriptions>
                      </CollectionViewSource>
                      <Style x:Key="FontStyle">
                        <Setter Property="Control.FontFamily" Value="{Binding Source}" />
                        <Setter Property="Control.FontSize" Value="16" />
                      </Style>
                      <DataTemplate x:Key="FontTemplate">
                        <StackPanel VirtualizingStackPanel.IsVirtualizing="True">
                          <TextBlock Style="{StaticResource FontStyle}" Text="{Binding Source}" ToolTip="{Binding Source}" />
                        </StackPanel>
                      </DataTemplate>
                    </ComboBox.Resources>
                    <ComboBox.ItemsSource>
                      <Binding Source="{StaticResource myFonts}" />
                    </ComboBox.ItemsSource>
                  </ComboBox>

                  <TextBlock Name="AutoSaveBlock" Margin="0,15,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
                  <ComboBox Name="AutoSave" HorizontalAlignment="Left" VerticalAlignment="Top" Width="250" SelectionChanged="AutoSave_Changed">
                    <ComboBoxItem Content="None" />
                    <ComboBoxItem Content="0.5" />
                    <ComboBoxItem Content="1" />
                    <ComboBoxItem Content="2" />
                    <ComboBoxItem Content="3" />
                    <ComboBoxItem Content="4" />
                    <ComboBoxItem Content="5" />
                    <ComboBoxItem Content="10" />
                    <ComboBoxItem Content="15" />
                  </ComboBox>

                  <TextBlock Name="IndentationSizeBlock" Margin="0,15,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
                  <Slider Name="IndentationSize" Margin="0,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="280" Minimum="1" Maximum="10" AutoToolTipPlacement="TopLeft" TickFrequency="1" IsSnapToTickEnabled="True" TickPlacement="BottomRight" ValueChanged="IndentationSize_Changed" />

                </StackPanel>

                <StackPanel Grid.Column="1">

                  <TextBlock Name="ScrollSpeedBlock" Margin="5,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False" />
                  <Slider Name="ScrollSpeed" Margin="5,5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="280" Minimum="1" Maximum="20" AutoToolTipPlacement="TopLeft" TickFrequency="1" IsSnapToTickEnabled="True" TickPlacement="BottomRight" ValueChanged="ScrollSpeed_Changed" />

                  <StackPanel Margin="0,10,0,0">
                    <StackPanel.Resources>
                      <Style BasedOn="{StaticResource ParentCheckBox}" TargetType="{x:Type CheckBox}"/>
                    </StackPanel.Resources>
                    <CheckBox Name="WordWrap" Checked="WordWrap_Changed" Unchecked="WordWrap_Changed" />
                    <CheckBox Name="AgressiveIndentation" Checked="AIndentation_Changed" Unchecked="AIndentation_Changed" />
                    <CheckBox Name="LineReformatting" Checked="LineReformat_Changed" Unchecked="LineReformat_Changed" />
                    <CheckBox Name="TabToSpace" Checked="TabToSpace_Changed" Unchecked="TabToSpace_Changed" />
                    <CheckBox Name="AutoCloseBrackets" Checked="AutoCloseBrackets_Changed" Unchecked="AutoCloseBrackets_Changed" />
                    <CheckBox Name="AutoCloseStringChars" Checked="AutoCloseStringChars_Changed" Unchecked="AutoCloseStringChars_Changed" />
                    <CheckBox Name="ShowSpaces" Checked="ShowSpaces_Changed" Unchecked="ShowSpaces_Changed" />
                    <CheckBox Name="ShowTabs" Checked="ShowTabs_Changed" Unchecked="ShowTabs_Changed" />
                    <CheckBox Name="UseTabToAutocomplete" Checked="TabToAutocomplete_Changed" Unchecked="TabToAutocomplete_Changed" />
                  </StackPanel>

                </StackPanel>

              </Grid>

              <!-- Lower grid -->
              <Grid Margin="0,10,0,0">

                <Grid.ColumnDefinitions>
                  <ColumnDefinition/>
                  <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <CheckBox Name="HighlightDeprecateds" Margin="5,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Checked="HighlightDeprecateds_Changed" Unchecked="HighlightDeprecateds_Changed" />

                <StackPanel Grid.Column="0" Margin="0,30,0,10" x:Name="RGBSliders1">

                  <StackPanel.Resources>
                    <Style BasedOn="{StaticResource ColorChangeControlStyle}" TargetType="{x:Type components:ColorChangeControl}">
                      <Setter Property="HorizontalAlignment" Value="Left"/>
                    </Style>
                  </StackPanel.Resources>

                  <components:ColorChangeControl x:Name="SH_Comments" ColorChanged="Comments_Changed" />
                  <components:ColorChangeControl x:Name="SH_PreProcessor" ColorChanged="PreProcessor_Changed" />
                  <components:ColorChangeControl x:Name="SH_Types" ColorChanged="Types_Changed" />
                  <components:ColorChangeControl x:Name="SH_Keywords" ColorChanged="Keywords_Changed" />
                  <components:ColorChangeControl x:Name="SH_Chars" ColorChanged="Chars_Changed" />
                  <components:ColorChangeControl x:Name="SH_Numbers" ColorChanged="Numbers_Changed" />
                  <components:ColorChangeControl x:Name="SH_Deprecated" ColorChanged="Deprecated_Changed" />
                  <components:ColorChangeControl x:Name="SH_Functions" ColorChanged="Functions_Changed" />
                  
                </StackPanel>

                <Button Grid.Column="1" Margin="0,0,5,0" 
                        Height="30" VerticalContentAlignment="Center" 
                        HorizontalContentAlignment="Center" HorizontalAlignment="Right" 
                        VerticalAlignment="Top" x:Name="DefaultButton" Click="DefaultButton_Click" 
                        FontWeight="Bold"/>

                <StackPanel Grid.Column="1" Margin="0,30,0,0" x:Name="RGBSliders2">

                  <StackPanel.Resources>
                    <Style BasedOn="{StaticResource ColorChangeControlStyle}" TargetType="{x:Type components:ColorChangeControl}">
                      <Setter Property="HorizontalAlignment" Value="Right"/>
                    </Style>
                  </StackPanel.Resources>

                  <components:ColorChangeControl x:Name="SH_CommentMarkers" ColorChanged="CommentMarker_Changed" />
                  <components:ColorChangeControl x:Name="SH_Strings" ColorChanged="String_Changed" />
                  <components:ColorChangeControl x:Name="SH_TypesValues" ColorChanged="TypeValues_Changed" />
                  <components:ColorChangeControl x:Name="SH_ContextKeywords" ColorChanged="ContextKeywords_Changed" />
                  <components:ColorChangeControl x:Name="SH_UnknownFunctions" ColorChanged="UFunctions_Changed" />
                  <components:ColorChangeControl x:Name="SH_SpecialCharacters" ColorChanged="SpecialCharacters_Changed" />
                  <components:ColorChangeControl x:Name="SH_Constants" ColorChanged="Constants_Changed" />
                  <components:ColorChangeControl x:Name="SH_Methods" ColorChanged="Methods_Changed" />

                </StackPanel>

              </Grid>
            </StackPanel>

          </Grid>
        </ScrollViewer>
      </controls:MetroTabItem>
      <controls:MetroTabItem Name="HotkeysHeader">
        <ScrollViewer>
          <Grid Name="HotkeysGrid">
            <Grid.ColumnDefinitions>
              <ColumnDefinition/>
              <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <TextBlock Name="TxtCommand" HorizontalAlignment="Left" Margin="93,9,0,0" VerticalAlignment="Top" Width="185" FontSize="20" TextAlignment="Center"/>
            <TextBlock Name="TxtHotkey" HorizontalAlignment="Left" Margin="86,9,0,0" VerticalAlignment="Top" Width="141" FontSize="20" Grid.Column="1" TextAlignment="Center"/>
            <Separator Margin="30,21,30,0" Height="41" VerticalAlignment="Top" Grid.ColumnSpan="2"/>
            <Label Name="LblDisallowed" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="Red"/>
          </Grid>
        </ScrollViewer>
      </controls:MetroTabItem>
    </controls:MetroAnimatedSingleRowTabControl>
  </Grid>
</controls:MetroWindow>
