<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: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"
        xmlns:picture="clr-namespace:HandBrakeWPF.Converters.Picture"
        Title="{Binding Title}"
        Width="450"
        MaxHeight="800"
        ResizeMode="NoResize"
        SizeToContent="Height"
        WindowStartupLocation="CenterScreen"
        TextOptions.TextFormattingMode="Display"
        mc:Ignorable="d">

    <Window.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
        <picture:ResolutionLimitConverter x:Key="resolutionLimitConverter" />
    </Window.Resources>

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

        <TextBlock Text="{x:Static Properties:Resources.AddPresetView_AddPreset}" Style="{StaticResource windowTitle}" Margin="10,0,10,10" Grid.Row="0" />

        <!--  Header  -->
        <Grid Grid.Row="1" Margin="10,0,10,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120" />
                <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="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!--  Name  -->
            <TextBlock Grid.Row="0"
                       Grid.Column="0"
                       Text="{x:Static Properties:Resources.AddPresetView_Name}" />
            <TextBox Grid.Row="0"
                     Grid.Column="1"
                     HorizontalAlignment="Stretch"
                     Text="{Binding Preset.Name, UpdateSourceTrigger=PropertyChanged}" />


            <!--  Description  -->
            <TextBlock Grid.Row="2" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Description}" />
            <TextBox Grid.Row="2" Grid.Column="1" Margin="0,10,0,0" MinHeight="75" TextWrapping="WrapWithOverflow" VerticalContentAlignment="Top"
                     Text="{Binding Preset.Description, UpdateSourceTrigger=PropertyChanged}" />

            <TextBlock Grid.Row="3" Grid.Column="0" Margin="0,10,0,0" Text="{x:Static Properties:Resources.AddPresetView_Category}" />
            <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" Margin="0,10,0,0">

                <ComboBox ItemsSource="{Binding PresetCategories}" SelectedItem="{Binding SelectedPresetCategory}" DisplayMemberPath="Category" />
                <TextBox Text="{Binding PresetCategory, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding CanAddNewPresetCategory, Converter={StaticResource boolToVisConverter}}" />
            </StackPanel>
           

            <!--  Settings  -->
            <TextBlock Text="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" Grid.Row="4" Grid.Column="0" VerticalAlignment="Center"  Margin="0,15,0,5"  />
            <ComboBox ItemsSource="{Binding ResolutionLimitModes, Converter={StaticResource resolutionLimitConverter}}"  
                          SelectedItem="{Binding SelectedPictureSettingsResLimitMode, Converter={StaticResource resolutionLimitConverter}}" 
                          Width="150" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,5" 
                          AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_ResLimit}" />


            <!-- MAX Width and MAX Height -->
            <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal">
                <controls:NumberBox Number="{Binding CustomWidth, Mode=TwoWay}" UpdateBindingOnTextChange="True"
                                    Modulus="2" Minimum="0" Width="60"
                                    AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxWidth}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" />

                <TextBlock Text="x" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" VerticalAlignment="Center" Margin="10,0,10,0" />
                <controls:NumberBox Number="{Binding CustomHeight, Mode=TwoWay}" UpdateBindingOnTextChange="True"
                                    Modulus="2" Minimum="0" Width="60"
                                    AutomationProperties.Name="{x:Static Properties:Resources.PictureSettingsView_MaxHeight}" Visibility="{Binding IsCustomMaxRes, Converter={StaticResource boolToVisConverter}}" />
            </StackPanel>
  
            <TextBlock Text="Audio:" Grid.Row="6" VerticalAlignment="Center" Margin="0,15,0,0" />
            <Button Content="{x:Static Properties:Resources.AudioViewModel_ConfigureDefaults}" Grid.Row="6"  Grid.Column="1" HorizontalAlignment="Left" Margin="0,15,0,0" Padding="8,2"
                    Command="{Binding RelayCommand}" CommandParameter="EditAudioDefaults" />
            
            <TextBlock Text="Subtitles:" Grid.Row="7" VerticalAlignment="Center" Margin="0,5,0,0" />
            <Button Content="{x:Static Properties:Resources.SubtitlesViewModel_ConfigureDefaults}" Grid.Row="7"  Grid.Column="1" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="8,2"
                    Command="{Binding RelayCommand}" CommandParameter="EditSubtitleDefaults" />

        </Grid>

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

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="1"
                    Margin="0,5,10,10"
                    Command="{Binding RelayCommand}" CommandParameter="Cancel"
                    Content="{x:Static Properties:Resources.Generic_Cancel}"
                    IsCancel="True"
                    Padding="8,2" />
            <Button Grid.Column="2"
                    Margin="0,5,10,10"
                    Command="{Binding RelayCommand}" CommandParameter="Add"
                    Content="{x:Static Properties:Resources.Generic_Add}"
                    IsDefault="True"
                    Padding="8,2" />
        </Grid>

    </Grid>
</Window>
