<UserControl x:Class="HandBrakeWPF.Views.FiltersView"
             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:Converters="clr-namespace:HandBrakeWPF.Converters"
             xmlns:filters="clr-namespace:HandBrakeWPF.Converters.Filters"
             xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
             mc:Ignorable="d" >
    <UserControl.Resources>
        <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />
        <Converters:EnumComboConverter x:Key="boolComboConverter" />
        <filters:DenoisePresetConverter x:Key="DenoisePresetConverter" />
        <filters:SharpenPresetConverter x:Key="SharpenPresetConverter" />
        <filters:SharpenTuneConverter x:Key="SharpenTuneConverter" />
    </UserControl.Resources>

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

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

        <TextBlock Text="{x:Static Properties:Resources.FiltersView_Filters}" FontWeight="Bold" Margin="10,5,0,0" Grid.Row="0" ></TextBlock>

        <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="0" Margin="10,10,0,0">
            <Grid>
                <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="Auto" />
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="75" />
                    <ColumnDefinition MinWidth="160" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <!-- Detelecine -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Detelecine}" Grid.Row="0" Grid.Column="0" Margin="0,0,0,10" />
                <ComboBox Width="120" Grid.Row="0" ItemsSource="{Binding DetelecineOptions, Converter={StaticResource boolComboConverter}}" 
                          SelectedItem="{Binding SelectedDetelecine, Converter={StaticResource boolComboConverter}}" Grid.Column="1" Margin="0,0,0,10"
                          ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Detelecine}"
                          HorizontalAlignment="Left" AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Detelecine}" />
                <TextBox Width="120" Grid.Row="0" Grid.Column="2" Margin="0,0,0,10" Text="{Binding CustomDetelecine, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left"
                         Visibility="{Binding ShowDetelecineCustom, Converter={StaticResource boolToVisConverter}}"/>

                <!-- Interlace Detection -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_InterlaceDetection}" VerticalAlignment="Center" Margin="0,0,5,0" Grid.Row="1"  />

                <ComboBox Width="120" Grid.Row="1" Grid.Column="1" ItemsSource="{Binding CombDetectPresets, Converter={StaticResource boolComboConverter}}" HorizontalAlignment="Left" VerticalAlignment="Center"
                          SelectedItem="{Binding SelectedCombDetectPreset, Converter={StaticResource boolComboConverter}}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_InterlaceDetection}"
                          VerticalContentAlignment="Center" AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_InterlaceDetection}"/>

                <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="2">
                <TextBlock Text="Custom:" VerticalAlignment="Center" Margin="0,0,5,0" Visibility="{Binding ShowCombDetectCustom, Converter={StaticResource boolToVisConverter}}" />
                <TextBox Width="120" Text="{Binding CustomCombDetect, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Left"
                         Visibility="{Binding ShowCombDetectCustom, Converter={StaticResource boolToVisConverter}}" MinHeight="22" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_InterlaceDetectionCustom}"  />
                </StackPanel>

                <!-- Deinterlace -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Deinterlace}" VerticalAlignment="Center" Grid.Row="2" Grid.Column="0" Margin="0,0,0,10" />
                <StackPanel Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="0,0,0,10">
                    <ComboBox Width="120" ItemsSource="{Binding DeinterlaceFilterOptions, Converter={StaticResource boolComboConverter}}" HorizontalAlignment="Left"
                              SelectedItem="{Binding SelectedDeinterlaceFilter, Converter={StaticResource boolComboConverter}}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deinterlace}"
                              AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Deinterlace}" />
                </StackPanel>

                <StackPanel Grid.Row="2" Grid.Column="2" Orientation="Horizontal" Margin="0,0,0,10">
                    <TextBlock Text="{x:Static Properties:Resources.FiltersView_DeinterlacePreset}" VerticalAlignment="Center" Margin="0,0,5,0" Visibility="{Binding IsDeinterlaceEnabled, Converter={StaticResource boolToVisConverter}}"  />
                    <ComboBox Width="120" ItemsSource="{Binding DeinterlacePresets}" HorizontalAlignment="Left" VerticalAlignment="Center"
                              SelectedItem="{Binding SelectedDeInterlacePreset}" DisplayMemberPath="Name" Visibility="{Binding IsDeinterlaceEnabled, Converter={StaticResource boolToVisConverter}}"
                              AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_DeinterlacePresetAuto}" />

                    <TextBlock Text="Custom:" VerticalAlignment="Center" Margin="5,0,5,0"  Visibility="{Binding ShowCustomDeinterlace, Converter={StaticResource boolToVisConverter}}" />
                    <TextBox Width="120" Text="{Binding CustomDeinterlaceSettings, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Left"
                             Visibility="{Binding ShowCustomDeinterlace, Converter={StaticResource boolToVisConverter}}" MinHeight="22" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_DeinterlaceCustom}" />
                </StackPanel>


                <!-- Denoise -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Denoise}" Grid.Row="3" Grid.Column="0" Margin="0,0,0,10"/>
                <ComboBox Width="120" Grid.Row="3" ItemsSource="{Binding DenoiseOptions, Converter={StaticResource boolComboConverter}}" 
                          SelectedItem="{Binding SelectedDenoise, Converter={StaticResource boolComboConverter}}" Grid.Column="1"
                          HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,10" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Denoise}"
                          AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Denoise}"/>

                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="3" Grid.Column="2" Margin="0,0,0,10" 
                            Visibility="{Binding ShowDenoiseOptions, Converter={StaticResource boolToVisConverter}}">
                    <TextBlock Text="{x:Static Properties:Resources.FiltersView_Preset}" Margin="0,0,5,0" />
                    <ComboBox SelectedItem="{Binding SelectedDenoisePreset}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_DenoisePreset}"
                              AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_DenoisePresetAuto}"
                              MinWidth="100"  HorizontalAlignment="Center" VerticalAlignment="Center">
                        <ComboBox.ItemsSource>
                            <MultiBinding Converter="{StaticResource DenoisePresetConverter}">
                                <Binding Path="DenoisePresets" />
                                <Binding Path="SelectedDenoise" />
                            </MultiBinding>
                        </ComboBox.ItemsSource>
                    </ComboBox>

                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowDenoiseTune, Converter={StaticResource boolToVisConverter}}">
                        <TextBlock Text="{x:Static Properties:Resources.FiltersView_Tune}" Margin="5,0,5,0" />
                        <ComboBox ItemsSource="{Binding DenoiseTunes}" SelectedItem="{Binding SelectedDenoiseTune}" MinWidth="100" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_DenoiseTune}"
                                  AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_DenoiseTuneAuto}"
                          Visibility="{Binding ShowDenoiseTune, Converter={StaticResource boolToVisConverter}}" VerticalAlignment="Center" />
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowDenoiseCustom, Converter={StaticResource boolToVisConverter}}">
                        <TextBlock Text="{x:Static Properties:Resources.FiltersView_Custom}" Margin="5,0,5,0" />
                        <TextBox Width="120" Margin="0" Text="{Binding CustomDenoise, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22"
                                 ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_CustomDenoiseParams}" />
                    </StackPanel>

                </StackPanel>
                
                <!-- Sharpen -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Sharpen}" Grid.Row="4" Grid.Column="0" Margin="0,0,0,10"/>
                <ComboBox Width="120" Grid.Row="4" ItemsSource="{Binding SharpenOptions, Converter={StaticResource boolComboConverter}}" 
                          SelectedItem="{Binding SelectedSharpen, Converter={StaticResource boolComboConverter}}" Grid.Column="1"
                          AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Sharpen}"
                          HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,0,10" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Sharpen}" />
                
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Grid.Row="4" Grid.Column="2" Margin="0,0,0,10" 
                            Visibility="{Binding ShowSharpenOptions, Converter={StaticResource boolToVisConverter}}">
                    
                    <TextBlock Text="{x:Static Properties:Resources.FiltersView_Preset}" Margin="0,0,5,0" />
                    <ComboBox SelectedItem="{Binding SelectedSharpenPreset}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenPreset}"
                              MinWidth="100"  HorizontalAlignment="Center" VerticalAlignment="Center" DisplayMemberPath="DisplayName"
                              AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_SharpenPresetAuto}" >
                        <ComboBox.ItemsSource>
                            <MultiBinding Converter="{StaticResource SharpenPresetConverter}">
                                <Binding Path="SharpenPresets" />
                                <Binding Path="SelectedSharpen" />
                            </MultiBinding>
                        </ComboBox.ItemsSource>
                    </ComboBox>

                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenTune, Converter={StaticResource boolToVisConverter}}">
                        <TextBlock Text="{x:Static Properties:Resources.FiltersView_Tune}" Margin="5,0,5,0" />
                        <ComboBox SelectedItem="{Binding SelectedSharpenTune}" MinWidth="100" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_SharpenTune}" VerticalAlignment="Center" DisplayMemberPath="DisplayName" 
                                  AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_SharpenTuneAuto}" >
                            <ComboBox.ItemsSource>
                                <MultiBinding Converter="{StaticResource SharpenTuneConverter}">
                                    <Binding Path="SharpenTunes" />
                                    <Binding Path="SelectedSharpen" />
                                </MultiBinding>
                            </ComboBox.ItemsSource>
                        </ComboBox>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Visibility="{Binding ShowSharpenCustom, Converter={StaticResource boolToVisConverter}}">
                        <TextBlock Text="{x:Static Properties:Resources.FiltersView_Custom}" Margin="5,0,5,0" />
                        <TextBox Width="120" Margin="0" Text="{Binding CustomSharpen, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" MinHeight="22"
                                 ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_CustomSharpenParams}" />
                    </StackPanel>

                </StackPanel>

                <!-- Deblock -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Deblock}" Grid.Row="5" Grid.Column="0" Margin="0,0,0,10"/>
                <Slider Width="120" Value="{Binding DeblockValue}" TickPlacement="BottomRight" Minimum="4" Maximum="15" Grid.Row="5" Grid.Column="1" Margin="0,0,0,10"
                        HorizontalAlignment="Left" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Deblock}"
                        AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Deblock}" />
                <TextBlock Text="{Binding DeblockText}" Grid.Row="5" Grid.Column="2" Margin="0,0,0,10"/>

                <CheckBox Content="{x:Static Properties:Resources.FiltersView_Grayscale}" IsChecked="{Binding Grayscale}" Grid.Row="6" Grid.Column="1" Margin="0,0,0,10"
                          ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Grayscale}" />

                <!-- Rotation -->
                <TextBlock Text="{x:Static Properties:Resources.FiltersView_Rotate}" Grid.Row="7" Grid.Column="0" Margin="0,0,0,0"/>
                <ComboBox Width="120" ItemsSource="{Binding RotationOptions}" Grid.Row="7" Grid.Column="1"
                              SelectedItem="{Binding SelectedRotation}" ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Rotate}"
                          AutomationProperties.Name="{x:Static Properties:Resources.FiltersView_Rotate}"
                              HorizontalAlignment="Left" VerticalAlignment="Center" />

                <CheckBox Content="{x:Static Properties:Resources.FiltersView_FlipVideo}" Margin="5,0,0,0" VerticalAlignment="Center" Grid.Row="7" Grid.Column="2" IsChecked="{Binding FlipVideo, UpdateSourceTrigger=PropertyChanged}"
                          ToolTip="{x:Static Properties:ResourcesTooltips.FilterView_Flip}"/>
            </Grid>

        </StackPanel>

    </Grid>
</UserControl>
