<settingspagebase:SettingsPageBase xmlns:settingspagebase="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
                                   x:Class="FasdDesktopUi.Pages.SettingsPage.SettingsPageView"
                                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                                   xmlns:local="clr-namespace:FasdDesktopUi.Pages.SettingsPage"
                                   xmlns:ico="clr-namespace:FasdDesktopUi.Basics.UserControls.AdaptableIcon;assembly=F4SD-AdaptableIcon"
                                   xmlns:vc="clr-namespace:FasdDesktopUi.Basics.Converter"
                                   xmlns:sys="clr-namespace:System;assembly=mscorlib"
                                   mc:Ignorable="d"
                                   Title="SettingsPageView"
                                   ResizeMode="NoResize"
                                   WindowStyle="None"
                                   AllowsTransparency="True"
                                   Background="Transparent"
                                   MinHeight="100"
                                   MinWidth="400"
                                   ShowInTaskbar="False"
                                   Topmost="True"
                                   SizeToContent="WidthAndHeight"
                                   WindowStartupLocation="CenterScreen"
                                   Initialized="Window_Initialized"
                                   x:Name="SettingsWindow"
                                   KeyDown="SettingsWindow_KeyDown"
                                   Closed="SettingsWindow_Closed"
                                   IsVisibleChanged="SettingsWindow_IsVisibleChanged">

    <settingspagebase:SettingsPageBase.Resources>
        <vc:LanguageDefinitionsConverter x:Key="LanguageConverter" />
        <BooleanToVisibilityConverter x:Key="BoolToVisibility" />

        <Style TargetType="ico:AdaptableIcon"
               x:Key="ApplyButton"
               BasedOn="{StaticResource SettingsPage.Close.Icon}">
            <Setter Property="Margin"
                    Value="0 -7.5" />
            <Setter Property="IconHeight"
                    Value="22.5" />
            <Setter Property="BorderPadding"
                    Value="0 0 0 5" />
            <Setter Property="Visibility"
                    Value="Collapsed" />
            <EventSetter Event="MouseLeftButtonUp"
                         Handler="ApplyZoomButton_MouseLeftButtonUp" />
            <EventSetter Event="TouchDown"
                         Handler="ApplyZoomButton_TouchDown" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver"
                         Value="True">
                    <Setter Property="PrimaryIconColor"
                            Value="{DynamicResource Color.Green}" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </settingspagebase:SettingsPageBase.Resources>

    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="40" />
    </WindowChrome.WindowChrome>

    <Border CornerRadius="10"
            Background="{DynamicResource BackgroundColor.Menu.Categories}"
            Padding="10">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>

            <ico:AdaptableIcon x:Name="CloseButton"
                               Grid.Row="0"
                               HorizontalAlignment="Right"
                               Style="{DynamicResource SettingsPage.Close.Icon}"
                               MouseLeftButtonUp="CloseButton_MouseUp"
                               TouchDown="CloseButton_TouchDown"
                               SelectedInternIcon="window_close" />

            <StackPanel Grid.Row="1">
                <StackPanel.Resources>
                    <Style TargetType="Border">
                        <Setter Property="CornerRadius"
                                Value="7.5" />
                        <Setter Property="Background"
                                Value="{DynamicResource BackgroundColor.Menu.MainCategory}" />
                        <Setter Property="Margin"
                                Value="5" />
                        <Setter Property="Padding"
                                Value="10,5" />
                    </Style>

                    <Style TargetType="TextBlock">
                        <Setter Property="Margin"
                                Value="0, 0, 20, 0" />
                        <Setter Property="FontSize"
                                Value="14" />
                        <Setter Property="FontFamily"
                                Value="Calibri" />
                        <Setter Property="FontWeight"
                                Value="Bold" />
                        <Setter Property="Foreground"
                                Value="{DynamicResource FontColor.Menu.Categories}" />
                        <Setter Property="VerticalAlignment"
                                Value="Center" />
                    </Style>
                </StackPanel.Resources>

                <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global}" />
                <Border>
                    <StackPanel>
                        <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme}" />

                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <Style TargetType="ico:AdaptableIcon">
                                    <Setter Property="BorderPadding"
                                            Value="0" />
                                    <Setter Property="Margin"
                                            Value="0, 5, 10, 0" />
                                    <Setter Property="Cursor"
                                            Value="Hand" />
                                    <Setter Property="PrimaryIconColor"
                                            Value="{DynamicResource Color.Menu.Icon}" />
                                    <Setter Property="IconHeight"
                                            Value="20" />
                                    <Setter Property="IconWidth"
                                            Value="20" />

                                    <EventSetter Event="MouseUp"
                                                 Handler="ColorModeIcon_MouseUp" />
                                    <EventSetter Event="TouchDown"
                                                 Handler="ColorModeIcon_TouchDown" />

                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver"
                                                 Value="True">
                                            <Setter Property="PrimaryIconColor"
                                                    Value="{DynamicResource Color.Menu.Icon.Hover}" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Resources>

                            <ico:AdaptableIcon x:Name="LightModeIcon"
                                               Tag="LightMode"
                                               IconHeight="25"
                                               IconWidth="25"
                                               ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme.LightMode}"
                                               SelectedInternIcon="style_sunFilled" />

                            <ico:AdaptableIcon x:Name="DarkModeIcon"
                                               Tag="DarkMode"
                                               ToolTip="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.Global.ColorTheme.DarkMode}"
                                               SelectedInternIcon="style_moonFilled" />

                        </StackPanel>

                        <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.SelectLanguage}" />

                        <StackPanel Orientation="Horizontal">
                            <StackPanel.Resources>
                                <Style TargetType="ico:AdaptableIcon">
                                    <Setter Property="Margin"
                                            Value="5 0" />
                                    <Setter Property="Cursor"
                                            Value="Hand" />
                                    <Setter Property="IconBackgroundColor"
                                            Value="{DynamicResource Color.Menu.Icon}" />
                                    <Setter Property="PrimaryIconColor"
                                            Value="{DynamicResource Color.Menu.Icon}" />
                                    <Setter Property="BorderPadding"
                                            Value="2.5" />
                                    <Setter Property="IconHeight"
                                            Value="22.5" />
                                    <Setter Property="IconWidth"
                                            Value="22.5" />
                                    <EventSetter Event="MouseLeftButtonUp"
                                                 Handler="Flag_MouseLeftButtonUp" />
                                    <EventSetter Event="TouchDown"
                                                 Handler="Flag_TouchDown" />

                                    <Style.Triggers>
                                        <Trigger Property="IsMouseOver"
                                                 Value="True">
                                            <Setter Property="PrimaryIconColor"
                                                    Value="{DynamicResource Color.Menu.Icon.Hover}" />
                                            <Setter Property="IconBackgroundColor"
                                                    Value="{DynamicResource Color.Menu.Icon.Hover}" />
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </StackPanel.Resources>

                            <ico:AdaptableIcon IconBackgroundColor="Transparent"
                                               IconWidth="30"
                                               IconHeight="30"
                                               Margin="-2.5 0 5 0"
                                               SelectedMaterialIcon="ic_language" />

                            <ico:AdaptableIcon Tag="DE"
                                               SelectedCountryCode="DE" />

                            <ico:AdaptableIcon Tag="US"
                                               SelectedCountryCode="GB" />
                        </StackPanel>

                        <StackPanel x:Name="ShouldSkipSlimViewLabel"
                                    Orientation="Horizontal">
                            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.ShouldSkipSlimView}" />
                            <ico:AdaptableIcon x:Name="ShouldSkipSlimViewPolicy"
                                               SelectedInternIcon="lock_closed"
                                               PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
                                               BorderPadding="0"
                                               Margin="-20 0 0 0"
                                               IconWidth="12"
                                               IconHeight="12"
                                               Visibility="Collapsed" />
                        </StackPanel>

                        <CheckBox x:Name="ShouldSkipSlimViewCheckBox"
                                  Style="{DynamicResource ToggleSwitch}"
                                  IsChecked="{Binding ElementName=SettingsWindow, Path=ShouldSkipSlimView}"
                                  HorizontalAlignment="Left"
                                  Margin="0,3,0,10">
                        </CheckBox>

                        <StackPanel x:Name="PositionOfSmallViewsLabel"
                                    Orientation="Horizontal">
                            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfSmallViews}" />
                            <ico:AdaptableIcon x:Name="PositionOfSmallViewsPolicy"
                                               SelectedInternIcon="lock_closed"
                                               PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
                                               BorderPadding="0"
                                               Margin="-20 0 0 0"
                                               IconWidth="12"
                                               IconHeight="12"
                                               Visibility="Collapsed" />
                        </StackPanel>

                        <Grid x:Name="PositionOfSmallViewsInput"
                              Grid.IsSharedSizeScope="True"
                              HorizontalAlignment="Left">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"
                                                  SharedSizeGroup="Label" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto"
                                                  SharedSizeGroup="Label" />
                            </Grid.ColumnDefinitions>

                            <TextBlock x:Name="SmallViewLeftTextBlock"
                                       Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Left}"
                                       Grid.Column="0"
                                       FontWeight="Regular"
                                       Cursor="Hand"
                                       HorizontalAlignment="Right"
                                       Margin="2.5 -0 2.5 0"
                                       Tag="0"
                                       TouchDown="SmallViewTextBlock_TouchDown"
                                       MouseLeftButtonUp="SmallViewTextBlock_MouseLeftButtonUp" />

                            <Border Grid.Column="1"
                                    Padding="5 0">
                                <Slider x:Name="SmallViewPositionSlider"
                                        Minimum="0"
                                        Maximum="2"
                                        MinWidth="75"
                                        IsSnapToTickEnabled="True"
                                        Ticks="0 2"
                                        TickPlacement="TopLeft"
                                        TickFrequency="2"
                                        Value="{Binding ElementName=SettingsWindow, Path=PositionOfSmallViews}" />

                            </Border>

                            <TextBlock x:Name="SmallViewRightTextBlock"
                                       Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Right}"
                                       Grid.Column="2"
                                       FontWeight="Regular"
                                       Cursor="Hand"
                                       HorizontalAlignment="Left"
                                       Margin="2.5 -0 2.5 0"
                                       Tag="2"
                                       TouchDown="SmallViewTextBlock_TouchDown"
                                       MouseLeftButtonUp="SmallViewTextBlock_MouseLeftButtonUp" />

                        </Grid>

                        <StackPanel x:Name="PositionOfFavouriteBarLabel"
                                    Orientation="Horizontal">
                            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Menu.PositionOfFavouriteBar}" />
                            <ico:AdaptableIcon x:Name="PositionOfFavouriteBarPolicy"
                                               SelectedInternIcon="lock_closed"
                                               PrimaryIconColor="{DynamicResource Color.Menu.Icon}"
                                               BorderPadding="0"
                                               Margin="-20 0 0 0"
                                               IconWidth="12"
                                               IconHeight="12"
                                               Visibility="Collapsed" />
                        </StackPanel>

                        <Grid x:Name="PositionOfFavouriteBarInput"
                              Grid.IsSharedSizeScope="True"
                              HorizontalAlignment="Left">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"
                                                  SharedSizeGroup="Label" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto"
                                                  SharedSizeGroup="Label" />
                            </Grid.ColumnDefinitions>

                            <TextBlock x:Name="FavouritePositionLeftTextBlock"
                                       Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Left}"
                                       Grid.Column="0"
                                       FontWeight="Regular"
                                       Cursor="Hand"
                                       HorizontalAlignment="Right"
                                       Margin="2.5 -0 2.5 0"
                                       Tag="0"
                                       TouchDown="FavouritePositionTextBlock_TouchDown"
                                       MouseLeftButtonUp="FavouritePositionTextBlock_MouseLeftButtonUp" />

                            <Border Grid.Column="1"
                                    Padding="5 0">
                                <Slider x:Name="FavouritePositionSlider"
                                        Minimum="0"
                                        Maximum="2"
                                        MinWidth="75"
                                        IsSnapToTickEnabled="True"
                                        Ticks="0 1 2"
                                        TickPlacement="TopLeft"
                                        TickFrequency="1"
                                        Value="{Binding ElementName=SettingsWindow, Path=PositionOfFavouriteBar}" />

                            </Border>

                            <TextBlock x:Name="FavouritePositionRightTextBlock"
                                       Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Global.Direction.Right}"
                                       Grid.Column="2"
                                       FontWeight="Regular"
                                       Cursor="Hand"
                                       HorizontalAlignment="Left"
                                       Margin="2.5 -0 2.5 0"
                                       Tag="2"
                                       TouchDown="FavouritePositionTextBlock_TouchDown"
                                       MouseLeftButtonUp="FavouritePositionTextBlock_MouseLeftButtonUp" />

                        </Grid>

                    </StackPanel>
                </Border>

                <StackPanel x:Name="SlimPageSection"
                            Visibility="{Binding ElementName=SettingsWindow, Path=IsSlimPageVisibile, Converter={StaticResource BoolToVisibility}}">
                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.SlimPage}" />
                    <Border>
                        <StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.ZoomFactor}" />
                                <TextBox x:Name="SlimPageScaleValueTextBox"
                                         Tag="SlimPageZoom"
                                         Text="{Binding ElementName=SettingsWindow, Path=ZoomSlimPageInPercent, Mode=TwoWay, UpdateSourceTrigger=LostFocus, TargetNullValue={x:Static sys:String.Empty}}"
                                         Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
                                         Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
                                         BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
                                         Width="28"
                                         TextChanged="ScaleValueTextBox_TextChanged">
                                    <TextBox.Resources>
                                        <Style TargetType="Border">
                                            <Setter Property="CornerRadius"
                                                    Value="2.5" />
                                        </Style>
                                    </TextBox.Resources>
                                </TextBox>

                                <ico:AdaptableIcon x:Name="ApplySlimPageZoomButton"
                                                   Style="{DynamicResource ApplyButton}"
                                                   Tag="SlimPageZoom"
                                                   SelectedInternIcon="misc_check" />
                            </StackPanel>

                            <Slider x:Name="SizeSliderSlimPage"
                                    Orientation="Horizontal"
                                    Minimum="50"
                                    Maximum="250"
                                    Value="{Binding ElementName=SettingsWindow, Path=ZoomSlimPageInPercent, Mode=TwoWay}"
                                    Margin="0,3"
                                    TickFrequency="1" />

                        </StackPanel>
                    </Border>
                </StackPanel>

                <StackPanel x:Name="DetailsPageSection"
                            Visibility="{Binding ElementName=SettingsWindow, Path=IsDetailsPageVisibile, Converter={StaticResource BoolToVisibility}}">
                    <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.DetailPage}" />
                    <Border>
                        <StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.ZoomFactor}" />
                                <TextBox x:Name="ScaleValueTextBox"
                                         Tag="DetailsPageZoom"
                                         Text="{Binding ElementName=SettingsWindow, Path=ZoomDetailsPageInPecent, Mode=TwoWay, UpdateSourceTrigger=LostFocus, TargetNullValue={x:Static sys:String.Empty}}"
                                         Foreground="{DynamicResource FontColor.DetailsPage.DataHistory.Value}"
                                         Background="{DynamicResource BackgroundColor.DetailsPage.DataHistory.TitleColumn}"
                                         BorderBrush="{DynamicResource BackgroundColor.DetailsPage.DataHistory.ValueColumn}"
                                         Width="28"
                                         TextChanged="ScaleValueTextBox_TextChanged">
                                    <TextBox.Resources>
                                        <Style TargetType="Border">
                                            <Setter Property="CornerRadius"
                                                    Value="2.5" />
                                        </Style>
                                    </TextBox.Resources>
                                </TextBox>

                                <ico:AdaptableIcon x:Name="ApplyDetailsPageZoomButton"
                                                   Style="{DynamicResource ApplyButton}"
                                                   Tag="DetailsPageZoom"
                                                   SelectedInternIcon="misc_check" />
                            </StackPanel>

                            <Slider x:Name="SizeSlider"
                                    Orientation="Horizontal"
                                    Minimum="50"
                                    Maximum="250"
                                    Value="{Binding ElementName=SettingsWindow, Path=ZoomDetailsPageInPecent, Mode=TwoWay}"
                                    Margin="0,3"
                                    TickFrequency="1" />

                            <TextBlock Text="{Binding Converter={StaticResource LanguageConverter}, ConverterParameter=Settings.DetailPage.HighlightColors}" />

                            <StackPanel x:Name="HighlightColorStack"
                                        Orientation="Horizontal"
                                        Margin="-5,0,0,0">
                                <StackPanel.Resources>
                                    <Style TargetType="Border">
                                        <Setter Property="Cursor"
                                                Value="Hand" />
                                        <Setter Property="CornerRadius"
                                                Value="5" />
                                        <Setter Property="Height"
                                                Value="25" />
                                        <Setter Property="Width"
                                                Value="25" />
                                        <Setter Property="Margin"
                                                Value="5" />
                                        <Setter Property="BorderThickness"
                                                Value="2.5" />

                                        <EventSetter Event="MouseEnter"
                                                     Handler="HightlightColorBorder_MouseEnter" />
                                        <EventSetter Event="MouseLeave"
                                                     Handler="HightlightColorBorder_MouseLeave" />
                                        <EventSetter Event="MouseUp"
                                                     Handler="HighlightColorBorder_MouseUp" />
                                        <EventSetter Event="TouchDown"
                                                     Handler="HighlightColorBorder_TouchDown" />

                                        <Style.Triggers>
                                            <Trigger Property="IsMouseOver"
                                                     Value="True">
                                                <Setter Property="Height"
                                                        Value="30" />
                                                <Setter Property="Width"
                                                        Value="30" />
                                                <Setter Property="Margin"
                                                        Value="2.5" />
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </StackPanel.Resources>

                                <Border x:Name="HighlightBlue"
                                        Background="{DynamicResource Color.Blue}"
                                        BorderBrush="{DynamicResource Color.Menu.Icon}"
                                        Tag="Blue" />
                                <Border x:Name="HighlightGreen"
                                        Background="{DynamicResource Color.Green}"
                                        BorderBrush="{DynamicResource Color.Menu.Icon}"
                                        Tag="Green" />
                                <Border x:Name="HighlightOrange"
                                        Background="{DynamicResource Color.Orange}"
                                        BorderBrush="{DynamicResource Color.Menu.Icon}"
                                        Tag="Orange" />
                                <Border x:Name="HighlightRed"
                                        Background="{DynamicResource Color.Red}"
                                        BorderBrush="{DynamicResource Color.Menu.Icon}"
                                        Tag="Red" />
                            </StackPanel>
                        </StackPanel>
                    </Border>
                </StackPanel>

            </StackPanel>

        </Grid>
    </Border>

</settingspagebase:SettingsPageBase>
