<UserControl
    x:Class="Translumo.MVVM.Views.AppearanceSettingsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:common="clr-namespace:Translumo.MVVM.Common"
    xmlns:controls="clr-namespace:Translumo.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:mde="https://spiegelp.github.io/MaterialDesignExtensions/winfx/xaml"
    Name="wControl"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Stretch"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <UserControl.Resources>
        <SolidColorBrush x:Key="colorBrushWindow" Color="{Binding Model.BackgroundColor}" />
        <SolidColorBrush x:Key="colorBrushFont" Color="{Binding Model.FontColor}" />
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <common:SliderPercentValueConverter x:Key="SliderPercentValueConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="450" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid
            Grid.Row="0"
            Grid.Column="0"
            HorizontalAlignment="Left">
            <Grid.Resources>
                <Style TargetType="{x:Type StackPanel}">
                    <Setter Property="Margin" Value="0,0,0,7" />
                </Style>
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="70" />
                <RowDefinition Height="70" />
                <RowDefinition Height="70" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="70" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <StackPanel
                Grid.Row="0"
                Grid.Column="0"
                Orientation="Horizontal">
                <Button
                    Name="BtnWidowColor"
                    Background="{StaticResource colorBrushWindow}"
                    Click="btnWidowColor_Click"
                    Command="{Binding ChangeBackColorClickedCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                    Style="{StaticResource RoundPrimaryButton}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.WindowColor}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="0"
                Grid.Column="1"
                HorizontalAlignment="Left"
                Orientation="Horizontal">
                <Button
                    Name="BtnFontColor"
                    Background="{StaticResource colorBrushFont}"
                    Click="btnFontColor_Click"
                    Command="{Binding ChangeFontColorClickedCommand}"
                    CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                    Style="{StaticResource RoundPrimaryButton}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.FontColor}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="1"
                Grid.Column="0"
                Orientation="Horizontal">
                <mde:OversizedNumberSpinner
                    Height="70"
                    Max="80"
                    Value="{Binding Model.FontSize, Mode=TwoWay}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.FontSize}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="2"
                Grid.Column="0"
                Orientation="Horizontal">
                <mde:OversizedNumberSpinner
                    Height="70"
                    Max="50"
                    Value="{Binding Model.LineSpacing, Mode=TwoWay}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.LineSpacing}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="3"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                Margin="10,12,0,0"
                Orientation="Horizontal">
                <ComboBox
                    Width="300"
                    DisplayMemberPath="DisplayText"
                    FontSize="16"
                    ItemsSource="{Binding Path=AvailableAlignments}"
                    SelectedValue="{Binding Path=Model.TextAlignment, Mode=TwoWay}"
                    SelectedValuePath="TextAlignment"
                    Style="{StaticResource ComboBoxBase}" />
            </StackPanel>
            <StackPanel
                Grid.Row="4"
                Grid.Column="0"
                Margin="10,0,0,0"
                Orientation="Horizontal">
                <ToggleButton IsChecked="{Binding Model.TextProcessing.AutoClearTexts}" Style="{StaticResource PrimaryToggleButton}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.AutoClearTexts}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="5"
                Grid.Column="0"
                Grid.ColumnSpan="2"
                Margin="10,0,0,0"
                Orientation="Vertical">
                <StackPanel Margin="0,0,0,14" Orientation="Horizontal">
                    <ToggleButton
                        x:Name="ExcludeFromCaptueToggle"
                        IsChecked="{Binding Model.ExcludeFromCaptue}"
                        Style="{StaticResource PrimaryToggleButton}" />
                    <Label Content="{DynamicResource Str.AppearanceSettings.ExcludeFromCaptue}" Style="{StaticResource ControlCaptionLabel}" />
                </StackPanel>
                <Label Content="{DynamicResource Str.AppearanceSettings.WindowOpacity}" />
                <Slider
                    Name="slicderFontOpacity"
                    Width="230"
                    HorizontalAlignment="Left"
                    Style="{DynamicResource MaterialDesignSlider}"
                    Value="{Binding Model.BackgroundOpacity, Converter={StaticResource SliderPercentValueConverter}}" />
                <Button
                    Margin="0,30,0,0"
                    HorizontalAlignment="Left"
                    Command="{Binding SendTestTextCommand}"
                    Content="{DynamicResource Str.Button.ShowText}"
                    Style="{DynamicResource PrimaryButton}" />
            </StackPanel>

            <StackPanel
                Grid.Row="1"
                Grid.Column="1"
                Orientation="Horizontal">
                <ToggleButton IsChecked="{Binding Model.FontBold}" Style="{StaticResource PrimaryToggleButton}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.Bold}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="2"
                Grid.Column="1"
                Orientation="Horizontal">
                <ToggleButton IsChecked="{Binding Model.TextProcessing.KeepFormatting}" Style="{StaticResource PrimaryToggleButton}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.KeepFormatting}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
            <StackPanel
                Grid.Row="4"
                Grid.Column="1"
                Margin="-6,0,0,0"
                Orientation="Horizontal"
                Visibility="{Binding Model.TextProcessing.AutoClearTexts, Converter={StaticResource BooleanToVisibilityConverter}}">
                <Label Content="{DynamicResource Str.AppearanceSettings.AutoClearTexts2}" Style="{StaticResource ControlCaptionLabel}" />
                <mde:OversizedNumberSpinner
                    Height="70"
                    Min="1000"
                    Style="{StaticResource BigOversizedNumberSpinner}"
                    Value="{Binding Model.TextProcessing.AutoClearTextsDelayMs, Mode=TwoWay}" />
                <Label Content="{DynamicResource Str.AppearanceSettings.Ms}" Style="{StaticResource ControlCaptionLabel}" />
            </StackPanel>
        </Grid>
        <DockPanel
            Grid.Row="0"
            Grid.Column="1"
            Margin="9,0,0,0"
            Visibility="{Binding ColorPickerIsOpened, Converter={StaticResource BooleanToVisibilityConverter}}">
            <controls:ColorSelectionControl
                x:Name="colorSelector"
                Padding="9,0,5,0"
                HorizontalAlignment="Stretch"
                BorderBrush="{StaticResource PrimaryHueMidBrush}"
                BorderThickness="1,0,0,0"
                ColorPickedCommand="{Binding ColorIsPickedCommand}"
                SelectedColor="{Binding SelectedColor, Mode=TwoWay}"
                UseLayoutRounding="False" />
        </DockPanel>
    </Grid>
</UserControl>
