<UserControl x:Name="userControl"
             x:Class="AutoDarkModeApp.Controls.ColorControlPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ui="http://schemas.modernwpf.com/2019"
             xmlns:p="clr-namespace:AutoDarkModeLib.Properties;assembly=AutoDarkModeLib"
             xmlns:local="clr-namespace:AutoDarkModeApp.Controls"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="750">

    <!-- ******* RESOURCES ******* -->
    <UserControl.Resources>
        <!-- *** BRUSHES *** -->
        <!-- SPECTRUM GRAD -->
        <LinearGradientBrush x:Key="SpectrumVerticalGradient"
                             x:Name="HueVerticalGrad"
                             EndPoint="0.5,1"
                             StartPoint="0.5,0">
            <GradientStop Color="Red" />
            <GradientStop Color="Red"
                          Offset="1" />
            <GradientStop Color="#FEFFFF00"
                          Offset="0.1667" />
            <GradientStop Color="#FE00FF00"
                          Offset="0.3333" />
            <GradientStop Color="#FE00FFFF"
                          Offset="0.5" />
            <GradientStop Color="#FE0000FF"
                          Offset="0.6667" />
            <GradientStop Color="#FEFF00FF"
                          Offset="0.8333" />
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="SpectrumHorizontalGradient"
                             EndPoint="1,0.5"
                             StartPoint="0,0.5">
            <GradientStop Color="Red" />
            <GradientStop Color="Red"
                          Offset="1" />
            <GradientStop Color="#FEFFFF00"
                          Offset="0.1667" />
            <GradientStop Color="#FE00FF00"
                          Offset="0.3333" />
            <GradientStop Color="#FE00FFFF"
                          Offset="0.5" />
            <GradientStop Color="#FE0000FF"
                          Offset="0.6667" />
            <GradientStop Color="#FEFF00FF"
                          Offset="0.8333" />
        </LinearGradientBrush>

        <SolidColorBrush x:Key="TextBoxBorderBrush"
                         Color="{Binding TextBoxBorder, ElementName=userControl}" />

        <!-- Checker background -->
        <DrawingBrush x:Key="CheckerBackground"
                      Stretch="Fill"
                      TileMode="Tile"
                      Viewport="12,12,20,20"
                      ViewportUnits="Absolute">

            <!-- a drawing of 4 checkerboard tiles -->
            <DrawingBrush.Drawing>
                <DrawingGroup>

                    <!-- checkerboard background -->
                    <GeometryDrawing Brush="White">
                        <GeometryDrawing.Geometry>
                            <RectangleGeometry Rect="0,0,20,20" />
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>

                    <!-- two checkerboard foreground tiles -->
                    <GeometryDrawing Brush="LightGray">
                        <GeometryDrawing.Geometry>
                            <GeometryGroup>
                                <RectangleGeometry Rect="0,0,10,10" />
                                <RectangleGeometry Rect="10,10,10,10" />
                            </GeometryGroup>
                        </GeometryDrawing.Geometry>
                    </GeometryDrawing>

                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>

        <!-- Simple ScrollRepeatButton Style - This RepeatButton is used above and below the Thumb in the Scrollbar. They are set to transparent si that they do not show over the scrollbar -->
        <Style x:Key="ScrollRepeatButtonStyle"
               TargetType="{x:Type RepeatButton}">
            <Setter Property="Background"
                    Value="Transparent" />
            <Setter Property="BorderBrush"
                    Value="Transparent" />
            <Setter Property="IsTabStop"
                    Value="false" />
            <Setter Property="Focusable"
                    Value="false" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Grid>
                            <Rectangle Fill="{TemplateBinding Background}"
                                       Stroke="{TemplateBinding BorderBrush}"
                                       StrokeThickness="{TemplateBinding BorderThickness}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Color Slider Thumb - The Thumb is the draggable part of a Slider -->
        <Style x:Key="ColorSliderThumb"
               TargetType="{x:Type Thumb}">
            <Setter Property="SnapsToDevicePixels"
                    Value="true" />
            <Setter Property="Height"
                    Value="14" />
            <Setter Property="Width"
                    Value="14" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Grid>
                            <Ellipse x:Name="Ellipse"
                                     Fill="{TemplateBinding Foreground}"
                                     Stroke="White"
                                     StrokeThickness="3" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Spectrum Slider Thumb - The Thumb is the draggable part of a Slider -->
        <Style x:Key="SpectrumSliderThumb"
               TargetType="{x:Type Thumb}">
            <Setter Property="SnapsToDevicePixels"
                    Value="true" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Grid>
                            <Rectangle x:Name="Ellipse"
                                       Fill="{TemplateBinding Foreground}"
                                       Stroke="Black"
                                       StrokeThickness="1"
                                       Width="15"
                                       Height="{TemplateBinding Width}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Spectrum Slider -->
        <Style x:Key="SliderHueComponent"
               TargetType="{x:Type Slider}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Grid x:Name="GridRoot">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto"
                                               MinHeight="{TemplateBinding MinHeight}" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!-- TickBar shows the ticks for Slider -->
                            <TickBar Visibility="Collapsed"
                                     x:Name="TopTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Top"
                                     Fill="{x:Null}"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,10"
                                     Grid.RowSpan="2" />

                            <Border Grid.Row="1"
                                    Margin="0"
                                    x:Name="Border"
                                    Height="25"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="4"
                                    Grid.ColumnSpan="3" />

                            <Track x:Name="PART_Track"
                                   Grid.Row="1">
                                <Track.Thumb>
                                    <Thumb x:Name="TrackThumb"
                                           Style="{StaticResource SpectrumSliderThumb}"
                                           Foreground="{TemplateBinding Foreground}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.IncreaseLarge" />
                                </Track.IncreaseRepeatButton>
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.DecreaseLarge" />
                                </Track.DecreaseRepeatButton>
                            </Track>

                            <TickBar Visibility="Collapsed"
                                     Grid.Row="2"
                                     x:Name="BottomTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Bottom"
                                     Fill="{TemplateBinding Foreground}"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,-4" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TickPlacement"
                                     Value="TopLeft">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="BottomRight">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="Both">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>

                            <!-- Use a rotation to create a Vertical Slider form the default Horizontal -->
                            <Trigger Property="Orientation"
                                     Value="Vertical">
                                <Setter Property="LayoutTransform"
                                        TargetName="GridRoot">
                                    <Setter.Value>
                                        <RotateTransform Angle="-90" />
                                    </Setter.Value>
                                </Setter>
                                <!-- Track rotates itself based on orientation so need to force it back -->
                                <Setter TargetName="PART_Track"
                                        Property="Orientation"
                                        Value="Horizontal" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Color Slider -->
        <Style x:Key="SliderColorComponent"
               TargetType="{x:Type Slider}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Grid x:Name="GridRoot">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto"
                                               MinHeight="{TemplateBinding MinHeight}" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!-- TickBar shows the ticks for Slider -->
                            <TickBar Visibility="Collapsed"
                                     x:Name="TopTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Top"
                                     Fill="#ff5a5a5a"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,10"
                                     Grid.RowSpan="2" />

                            <Border Grid.Row="1"
                                    Margin="0,5"
                                    x:Name="Border"
                                    Height="4"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="2"
                                    Grid.ColumnSpan="3" />

                            <Track x:Name="PART_Track"
                                   Grid.Row="1"
                                   Margin="-1,0,-1,0">
                                <Track.Thumb>
                                    <Thumb x:Name="TrackThumb"
                                           Style="{DynamicResource ColorSliderThumb}"
                                           Foreground="{TemplateBinding Foreground}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.IncreaseLarge" />
                                </Track.IncreaseRepeatButton>
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.DecreaseLarge" />
                                </Track.DecreaseRepeatButton>
                            </Track>

                            <TickBar Visibility="Collapsed"
                                     Grid.Row="2"
                                     x:Name="BottomTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Bottom"
                                     Fill="{TemplateBinding Foreground}"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,-4" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TickPlacement"
                                     Value="TopLeft">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="BottomRight">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="Both">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>

                            <!-- Use a rotation to create a Vertical Slider form the default Horizontal -->
                            <Trigger Property="Orientation"
                                     Value="Vertical">
                                <Setter Property="LayoutTransform"
                                        TargetName="GridRoot">
                                    <Setter.Value>
                                        <RotateTransform Angle="-90" />
                                    </Setter.Value>
                                </Setter>
                                <!-- Track rotates itself based on orientation so need to force it back -->
                                <Setter TargetName="PART_Track"
                                        Property="Orientation"
                                        Value="Horizontal" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Alpha Slider -->
        <Style x:Key="SliderAlphaComponent"
               TargetType="{x:Type Slider}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Slider}">
                        <Grid x:Name="GridRoot">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto"
                                               MinHeight="{TemplateBinding MinHeight}" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <!-- TickBar shows the ticks for Slider -->
                            <TickBar Visibility="Collapsed"
                                     x:Name="TopTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Top"
                                     Fill="{DynamicResource GlyphBrush}"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,10"
                                     Grid.RowSpan="2" />

                            <!-- Underlying pattern for alpha component slider -->
                            <Border Grid.Row="1"
                                    Margin="0,5"
                                    Height="4"
                                    CornerRadius="2"
                                    Background="{StaticResource CheckerBackground}" />
                            <Border Grid.Row="1"
                                    Margin="0,5"
                                    x:Name="Border"
                                    Height="4"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    CornerRadius="2"
                                    Grid.ColumnSpan="3" />

                            <Track x:Name="PART_Track"
                                   Grid.Row="1"
                                   Margin="-1,0,-1,0">
                                <Track.Thumb>
                                    <Thumb Style="{DynamicResource ColorSliderThumb}"
                                           Foreground="{TemplateBinding Foreground}" />
                                </Track.Thumb>
                                <Track.IncreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.IncreaseLarge" />
                                </Track.IncreaseRepeatButton>
                                <Track.DecreaseRepeatButton>
                                    <RepeatButton Style="{StaticResource ScrollRepeatButtonStyle}"
                                                  Command="Slider.DecreaseLarge" />
                                </Track.DecreaseRepeatButton>
                            </Track>

                            <TickBar Visibility="Collapsed"
                                     Grid.Row="2"
                                     x:Name="BottomTick"
                                     Height="4"
                                     SnapsToDevicePixels="True"
                                     Placement="Bottom"
                                     Fill="{TemplateBinding Foreground}"
                                     Grid.ColumnSpan="3"
                                     Margin="0,0,0,-4" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TickPlacement"
                                     Value="TopLeft">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="BottomRight">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>
                            <Trigger Property="TickPlacement"
                                     Value="Both">
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="TopTick" />
                                <Setter Property="Visibility"
                                        Value="Visible"
                                        TargetName="BottomTick" />
                            </Trigger>

                            <!-- Use a rotation to create a Vertical Slider form the default Horizontal -->
                            <Trigger Property="Orientation"
                                     Value="Vertical">
                                <Setter Property="LayoutTransform"
                                        TargetName="GridRoot">
                                    <Setter.Value>
                                        <RotateTransform Angle="-90" />
                                    </Setter.Value>
                                </Setter>
                                <!-- Track rotates itself based on orientation so need to force it back -->
                                <Setter TargetName="PART_Track"
                                        Property="Orientation"
                                        Value="Horizontal" />
                            </Trigger>

                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- Triggers -->
        <Style x:Key="GridTriggers"
               TargetType="Grid">
            <Style.Triggers>
                <Trigger Property="IsEnabled"
                         Value="false">
                    <Setter Property="OpacityMask"
                            Value="#3F191919" />
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <!-- ********* LAYOUT ******** -->
    <Grid x:Name="RootGrid"
          MinWidth="450"
          Style="{StaticResource GridTriggers}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition x:Name="selector"
                              Width="230" />
            <ColumnDefinition Width="30" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="{Binding Width, ElementName=selector, Mode=TwoWay}" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border BorderThickness="2"
                BorderBrush="{DynamicResource Win11Background}"
                CornerRadius="4"
                Padding="0"
                HorizontalAlignment="Center"
                VerticalAlignment="Center">

            <Grid>

                <!-- Rounded mask (stretches to fill Grid) -->
                <Border Name="mask"
                        Background="White"
                        CornerRadius="4" />

                <StackPanel>

                    <!-- Use a VisualBrush of 'mask' as the opacity mask -->
                    <StackPanel.OpacityMask>
                        <VisualBrush Visual="{Binding ElementName=mask}" />
                    </StackPanel.OpacityMask>

                    <Canvas x:Name="SaturationGradient"
                            Margin="0"
                            Width="225"
                            Height="225"
                            ClipToBounds="True"
                            Focusable="False">
                        <Canvas.Background>
                            <LinearGradientBrush EndPoint="1,0.5"
                                                 StartPoint="0,0.5">
                                <GradientStop Color="White" />
                                <GradientStop Color="#FF00D6FF"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </Canvas.Background>
                        <Rectangle x:Name="ValueGradient"
                                   Height="{Binding ActualHeight, ElementName=SaturationGradient, Mode=OneWay}"
                                   Canvas.Left="0"
                                   Canvas.Top="0"
                                   Width="{Binding ActualWidth, ElementName=SaturationGradient, Mode=OneWay}">
                            <Rectangle.Fill>
                                <LinearGradientBrush EndPoint="0.5,1"
                                                     StartPoint="0.5,0">
                                    <GradientStop Color="Black"
                                                  Offset="1" />
                                    <GradientStop Color="#00000000" />
                                </LinearGradientBrush>
                            </Rectangle.Fill>
                        </Rectangle>
                        <Ellipse x:Name="thumbSV"
                                 Height="16"
                                 Stroke="White"
                                 StrokeThickness="3"
                                 Width="16"
                                 Fill="Black"
                                 Canvas.Left="97.731"
                                 Canvas.Top="71.578" />
                    </Canvas>
                    <Rectangle x:Name="SVbounds"
                               Stroke="Black"
                               Margin="0"
                               d:LayoutOverrides="LeftPosition, RightPosition, TopPosition, BottomPosition" />
                </StackPanel>
            </Grid>
        </Border>

        <Slider x:Name="sliderSpectrum"
                Style="{StaticResource SliderHueComponent}"
                BorderBrush="{DynamicResource Win11Background}"
                Focusable="False"
                Maximum="360"
                Foreground="#FF0071FF"
                Margin="0"
                Height="228"
                PreviewMouseLeftButtonDown="Slider_PreviewMouseLeftButtonDown"
                PreviewMouseLeftButtonUp="Slider_PreviewMouseLeftButtonUp"
                MouseMove="Slider_MouseMoveHue"
                Orientation="Vertical"
                Grid.Column="1"
                HorizontalAlignment="Center"
                Background="{StaticResource SpectrumHorizontalGradient}"
                Value="220"
                RenderTransformOrigin="0.5,0.5"
                Width="25"
                BorderThickness="1"
                LargeChange="10"
                SmallChange="0.01">
            <Slider.RenderTransform>
                <TransformGroup>
                    <ScaleTransform ScaleY="-1"
                                    ScaleX="1" />
                    <SkewTransform AngleY="0"
                                   AngleX="0" />
                    <RotateTransform Angle="0" />
                    <TranslateTransform />
                </TransformGroup>
            </Slider.RenderTransform>
        </Slider>

        <DockPanel x:Name="RGBAdock"
                   Grid.Column="2"
                   Margin="5,0,0,0">
            <DockPanel x:Name="dockRed"
                       Height="35"
                       LastChildFill="true"
                       Margin="0,0,0,5"
                       DockPanel.Dock="Top">
                <Label x:Name="labelR"
                       DockPanel.Dock="Left"
                       Content="R"
                       ScrollViewer.VerticalScrollBarVisibility="Disabled"
                       Foreground="{Binding Foreground, ElementName=txtRvalue}"
                       Width="25"
                       HorizontalContentAlignment="Center"
                       VerticalContentAlignment="Center"
                       FontSize="16"
                       Padding="2"
                       FontFamily="Segoe UI Semilight" />
                <ui:SimpleStackPanel  DockPanel.Dock="Right">
                    <TextBox x:Name="txtRvalue"
                             Text="255"
                             FontFamily="Segoe UI Semilight"
                             Margin="0"
                             Width="80"
                             FontSize="16" />
                </ui:SimpleStackPanel>
                <Slider x:Name="sliderRed"
                        Style="{StaticResource SliderColorComponent}"
                        Maximum="255"
                        SmallChange="1"
                        Foreground="#FF570000"
                        VerticalAlignment="Center"
                        Margin="5,0,15,0"
                        LargeChange="15"
                        Value="25"
                        Focusable="False"
                        PreviewMouseLeftButtonDown="Slider_PreviewMouseLeftButtonDown"
                        PreviewMouseLeftButtonUp="Slider_PreviewMouseLeftButtonUp"
                        MouseMove="Slider_MouseMove">
                    <Slider.Background>
                        <LinearGradientBrush EndPoint="1,0.5"
                                             StartPoint="0,0.5">
                            <GradientStop Color="Black"
                                          Offset="0" />
                            <GradientStop Color="White"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Slider.Background>
                </Slider>
            </DockPanel>
            <DockPanel x:Name="dockGreen"
                       Height="35"
                       LastChildFill="true"
                       Margin="0,0,0,5"
                       DockPanel.Dock="Top">
                <Label x:Name="labelG"
                       DockPanel.Dock="Left"
                       Content="G"
                       ScrollViewer.VerticalScrollBarVisibility="Disabled"
                       Foreground="{Binding Foreground, ElementName=txtRvalue}"
                       Width="25"
                       HorizontalContentAlignment="Center"
                       VerticalContentAlignment="Center"
                       FontSize="16"
                       Padding="2"
                       FontFamily="Segoe UI Semilight" />
                <ui:SimpleStackPanel DockPanel.Dock="Right">
                    <TextBox x:Name="txtGvalue"
                             Text="255"
                             FontFamily="Segoe UI Semilight"
                             Margin="0"
                             Width="80"
                             FontSize="16" />
                </ui:SimpleStackPanel>
                <Slider x:Name="sliderGreen"
                        Style="{StaticResource SliderColorComponent}"
                        BorderBrush="{x:Null}"
                        Value="25"
                        Maximum="255"
                        PreviewMouseLeftButtonDown="Slider_PreviewMouseLeftButtonDown"
                        PreviewMouseLeftButtonUp="Slider_PreviewMouseLeftButtonUp"
                        MouseMove="Slider_MouseMove"
                        SmallChange="1"
                        Foreground="#FF003D00"
                        VerticalAlignment="Center"
                        Margin="5,0,15,0"
                        LargeChange="15"
                        Focusable="False">
                    <Slider.Background>
                        <LinearGradientBrush EndPoint="1,0.5"
                                             StartPoint="0,0.5">
                            <GradientStop Color="Black"
                                          Offset="0" />
                            <GradientStop Color="Lime"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Slider.Background>
                </Slider>
            </DockPanel>
            <DockPanel x:Name="dockBlue"
                       Height="35"
                       LastChildFill="true"
                       Margin="0,0,0,5"
                       DockPanel.Dock="Top">
                <Label x:Name="labelB"
                       DockPanel.Dock="Left"
                       Content="B"
                       ScrollViewer.VerticalScrollBarVisibility="Disabled"
                       Foreground="{Binding Foreground, ElementName=txtRvalue, Mode=TwoWay}"
                       Width="25"
                       HorizontalContentAlignment="Center"
                       VerticalContentAlignment="Center"
                       FontSize="16"
                       Padding="2"
                       FontFamily="Segoe UI Semilight" />
                <ui:SimpleStackPanel                          DockPanel.Dock="Right">
                    <TextBox x:Name="txtBvalue"
                             Text="255"
                             FontFamily="Segoe UI Semilight"
                             Margin="0"
                             VerticalAlignment="Center"
                             FontSize="16"
                             Width="80" />
                </ui:SimpleStackPanel>
                <Slider x:Name="sliderBlue"
                        Style="{StaticResource SliderColorComponent}"
                        BorderBrush="{x:Null}"
                        Value="25"
                        Maximum="255"
                        SmallChange="1"
                        Foreground="#FF000056"
                        VerticalAlignment="Center"
                        Margin="5,0,15,0"
                        LargeChange="15"
                        Focusable="False"
                        PreviewMouseLeftButtonDown="Slider_PreviewMouseLeftButtonDown"
                        PreviewMouseLeftButtonUp="Slider_PreviewMouseLeftButtonUp"
                        MouseMove="Slider_MouseMove">
                    <Slider.Background>
                        <LinearGradientBrush EndPoint="1,0.5"
                                             StartPoint="0,0.5">
                            <GradientStop Color="Black"
                                          Offset="0" />
                            <GradientStop Color="Blue"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Slider.Background>
                </Slider>
            </DockPanel>
            <DockPanel x:Name="dockAlpha"
                       Height="35"
                       LastChildFill="true"
                       Margin="0,0,0,5"
                       DockPanel.Dock="Top"
                       Visibility="{Binding DockAlphaVisibility, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ColorControlPanel}}}">
                <Label x:Name="labelA"
                       DockPanel.Dock="Left"
                       Content="A"
                       ScrollViewer.VerticalScrollBarVisibility="Disabled"
                       Foreground="{Binding Foreground, ElementName=txtRvalue}"
                       Width="25"
                       HorizontalContentAlignment="Center"
                       VerticalContentAlignment="Center"
                       FontSize="16"
                       Padding="2"
                       FontFamily="Segoe UI Semilight" />
                <ui:SimpleStackPanel DockPanel.Dock="Right">
                    <TextBox x:Name="txtAvalue"
                             TextWrapping="Wrap"
                             Text="255"
                             FontFamily="Segoe UI Semilight"
                             Margin="0"
                             Width="80"
                             FontSize="16" />
                </ui:SimpleStackPanel>
                <Slider x:Name="sliderAlpha"
                        Style="{DynamicResource SliderAlphaComponent}"
                        BorderBrush="{x:Null}"
                        Value="25"
                        Maximum="255"
                        SmallChange="1"
                        Foreground="#FF979797"
                        VerticalAlignment="Center"
                        Margin="5,0,15,0"
                        LargeChange="15"
                        Focusable="False"
                        PreviewMouseLeftButtonDown="Slider_PreviewMouseLeftButtonDown"
                        PreviewMouseLeftButtonUp="Slider_PreviewMouseLeftButtonUp"
                        MouseMove="Slider_MouseMove">
                    <Slider.Background>
                        <LinearGradientBrush EndPoint="1,0.5"
                                             StartPoint="0,0.5">
                            <GradientStop Color="#00000000"
                                          Offset="0" />
                            <GradientStop Color="#FF699A69"
                                          Offset="1" />
                        </LinearGradientBrush>
                    </Slider.Background>
                </Slider>
            </DockPanel>
            <Grid x:Name="dockSelectedColor"
                  DockPanel.Dock="Bottom"
                  VerticalAlignment="Bottom">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Height="40"
                      Grid.Row="0"
                      Background="{StaticResource CheckerBackground}"
                      Margin="5,0,0,0"
                      VerticalAlignment="Center"
                      ClipToBounds="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Border x:Name="rectSelectedColor"
                            Background="#FF3E6682"
                            BorderBrush="Black"
                            BorderThickness="0,1,1,1"
                            ToolTip="Current color"
                            Grid.Column="1"
                            Margin="0,-1,-1,-1" />
                    <Border x:Name="rectInitialColor"
                            Background="#FF2B485C"
                            Margin="-1"
                            BorderBrush="Black"
                            BorderThickness="1,1,0,1"
                            ToolTip="Initial Color" />
                    <Rectangle Grid.ColumnSpan="2"
                               Stroke="{DynamicResource Win11Border}"
                               StrokeThickness="1.2" />
                </Grid>
            </Grid>
        </DockPanel>

        <Grid Grid.Row="2"
              Grid.ColumnSpan="3"
              Margin="2,5,0,0"
              x:Name="colorCodeGrid">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <TextBlock FontSize="14"
                       VerticalAlignment="Center"
                       Grid.Row="0"
                       Padding="0,10,0,0"
                       Text="{x:Static p:Resources.WallpaperTextBoxHeaderHex}" />
            <TextBox Grid.Column="2"
                     x:Name="txtColorCode"
                     TextWrapping="Wrap"
                     Margin="0,10,0,0"
                     Text="#AAAAAAAA"
                     FontSize="14"
                     MaxLength="9"
                     LostKeyboardFocus="LostKeyFocus_RGBApanel"
                     KeyDown="KeyDown_RGBApanel"
                     VerticalAlignment="Center"
                     HorizontalContentAlignment="Center"
                     VerticalContentAlignment="Center"
                     Width="95"
                     Height="27"
                     Padding="0" />
        </Grid>
    </Grid>

</UserControl>
