<Window x:Class="HandBrakeWPF.Views.AddPresetView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cal="http://www.caliburnproject.org"
        xmlns:Converters="clr-namespace:HandBrakeWPF.Converters"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:Properties="clr-namespace:HandBrakeWPF.Properties" xmlns:controls="clr-namespace:HandBrakeWPF.Controls"
        Title="{Binding Title}"
        Width="350"
        ResizeMode="NoResize"
        SizeToContent="Height"
        WindowStartupLocation="CenterScreen"
        TextOptions.TextFormattingMode="Display"
        mc:Ignorable="d">

    <Window.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
        <Converters:EnumComboConverter x:Key="enumComboConverter" />

        <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement">
            <Setter Property="ToolTipService.ShowDuration" Value="20000" />
            <Setter Property="Margin" Value="0,2,0,2" />
        </Style>
    </Window.Resources>

    <Grid HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.Style>
            <Style TargetType="Grid">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding UseSystemColours}" Value="False">
                        <Setter Property="Background" Value="#FFF1F0EF" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>


        <!--  Header  -->
        <StackPanel Grid.Row="0"
                    Height="30"
                    Margin="0,0,0,10"
                    Orientation="Horizontal">
            <StackPanel.Style>
                <Style TargetType="StackPanel">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UseSystemColours}" Value="False">
                            <Setter Property="Background" Value="White" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Style>
            
            <Image Width="24"
                   Height="24"
                   Margin="10,0,5,0"
                   VerticalAlignment="Center"
                   Source="Images/Add40.png" />
            <StackPanel VerticalAlignment="Center" Orientation="Vertical">
                <TextBlock FontWeight="Bold" Text="Add a Preset" />
            </StackPanel>
        </StackPanel>

        <Grid Grid.Row="1" Margin="10,0,10,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <!--  Name  -->
            <TextBlock Grid.Row="0"
                       Grid.Column="0"
                       Text="Preset Name:" />
            <TextBox Grid.Row="0"
                     Grid.Column="1"
                     Width="150"
                     HorizontalAlignment="Left"
                     Text="{Binding Preset.Name}" />

            <!--  Settings  -->
            <TextBlock Grid.Row="1"
                       Grid.Column="0"
                       Margin="0,20,0,0"
                       FontWeight="Bold"
                       Text="Picture Settings:" />

            <TextBlock Grid.Row="2"
                       Grid.Column="0"
                       Style="{StaticResource LongToolTipHolder}"
                       ToolTip="{x:Static Properties:Resources.AddPreset_PictureSizeMode}"
                       Text="Max Picture Size:" />
            <ComboBox Grid.Row="2"
                      Grid.Column="1"
                      Width="125"
                      HorizontalAlignment="Left"
                      Style="{StaticResource LongToolTipHolder}"
                      ToolTip="{x:Static Properties:Resources.AddPreset_PictureSizeMode}"
                      ItemsSource="{Binding PictureSettingsModes,
                                            Converter={StaticResource enumComboConverter}}"
                      SelectedItem="{Binding SelectedPictureSettingMode,
                                             Converter={StaticResource enumComboConverter}}" />

            <StackPanel Grid.Row="3"
                        Grid.Column="1"
                        Margin="0,10,0,0"
                        Orientation="Horizontal"
                        Visibility="{Binding ShowCustomInputs,
                                             Converter={StaticResource boolToVisConverter}}">
                <controls:NumberBox Width="60" Number="{Binding CustomWidth, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,0,0,5" 
                                    AllowEmpty="True" />
                <TextBlock Margin="10,0,10,0"
                           FontWeight="Bold"
                           Text="X" />
                <controls:NumberBox Width="60" Number="{Binding CustomHeight, Mode=TwoWay}" HorizontalAlignment="Left" Margin="0,0,0,5" 
                                    AllowEmpty="True" />
            </StackPanel>

            <CheckBox Grid.Row="4"
                      Grid.Column="0" Grid.ColumnSpan="2"
                      Margin="0,10,0,0"
                      Content="Save Video Filter Settings"
                      IsChecked="{Binding Preset.UsePictureFilters}" />

            <!--  Description  -->
            <TextBlock Grid.Row="5"
                       Grid.Column="0"
                       FontWeight="Bold" Margin="0,10,0,0"
                       Text="Description:" />
            <TextBox Grid.Row="6"
                     Grid.ColumnSpan="2" Margin="0,10,0,0"
                     HorizontalAlignment="Stretch"
                     Text="{Binding Preset.Description}" />
        </Grid>

        <!--  Controls  -->
        <Grid Grid.Row="3"
              Margin="0,20,0,0">

            <Grid.Style>
                <Style TargetType="Grid">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UseSystemColours}" Value="False">
                            <Setter Property="Background" Value="LightGray" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="1"
                    Margin="0,5,10,5"
                    cal:Message.Attach="[Event Click] = [Action Cancel]"
                    Content="Cancel"
                    IsCancel="True"
                    Padding="8,2" />
            <Button Grid.Column="2"
                    Margin="0,5,10,5"
                    cal:Message.Attach="[Event Click] = [Action Add]"
                    Content="Add"
                    IsDefault="True"
                    Padding="8,2" />
        </Grid>

    </Grid>
</Window>
