<Window x:Class="HandBrakeWPF.Views.SubtitlesDefaultsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:helpers="clr-namespace:HandBrakeWPF.Helpers"
             xmlns:subtitles="clr-namespace:HandBrakeWPF.Converters.Subtitles"
             xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
             d:DesignHeight="350"
             d:DesignWidth="550"
             ResizeMode="NoResize"
             SizeToContent="WidthAndHeight"
             WindowStartupLocation="CenterScreen"
             TextOptions.TextFormattingMode="Display"
             mc:Ignorable="d"
             Title="{Binding Title}">
    <Window.Resources>
        <subtitles:SubtitleBehaviourConverter x:Key="subtitleBehaviourConverter" />
        <subtitles:SubtitleBurnInBehaviourConverter x:Key="subtitleBurnInBehaviourConverter" />

        <Style x:Key="LongToolTip" TargetType="TextBlock">
            <Setter Property="Width" Value="400" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="ToolTipService.ShowDuration" Value="20000" />
            <Setter Property="Margin" Value="0,2,0,2" />
        </Style>

    </Window.Resources>

    <Grid VerticalAlignment="Top" Margin="0,10,10,10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

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

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

        <!-- Row 0 -->
        <Grid Grid.Row="1" Grid.Column="0"  Margin="10,15,0,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

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

            <!-- Subtitles -->
            <TextBlock Text="{x:Static Properties:Resources.SubtitlesView_TrackSelectionBehaviour}"  Grid.Column="0" Grid.Row="0" Margin="0,0,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
            <ComboBox Name="autoSubtitleMode"  Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center"
                          ItemsSource="{Binding SubtitleBehaviourModeList, Converter={StaticResource subtitleBehaviourConverter}}" 
                          SelectedItem="{Binding SubtitleBehaviours.SelectedBehaviour, Converter={StaticResource subtitleBehaviourConverter}}" Width="210" Margin="0,0,5,0" />

            <!-- Languages -->
            <Grid Margin="25,10,0,0" Grid.Row="2" Grid.ColumnSpan="2">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>

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

                        <StackPanel Orientation="Vertical" Grid.Column="0">
                            <TextBlock Text="{x:Static Properties:Resources.Shared_AvailableLanguages}" Margin="0,0,0,5"/>
                            <ListBox Name="availableLanguages" ItemsSource="{Binding AvailableLanguages}" 
                                     helpers:ListBoxHelper.SelectedItems="{Binding SelectedAvailableToMove}" 
                                             SelectionMode="Extended" Width="140" Height="120" />
                        </StackPanel>

                        <DockPanel Grid.Column="1" Margin="10,0,10,0">
                            <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                <Button Content="{x:Static Properties:Resources.Generic_MoveRight}"  VerticalAlignment="Center" Margin="0,0,0,5" Command="{Binding RelayCommand}" CommandParameter="LanguageMoveRight" MaxWidth="90" />
                                <Button Content="{x:Static Properties:Resources.Generic_MoveLeft}"  VerticalAlignment="Center" Margin="0,0,0,5" Command="{Binding RelayCommand}" CommandParameter="LanguageMoveLeft" MaxWidth="90" />
                                <Button Content="{x:Static Properties:Resources.Generic_Clear}" VerticalAlignment="Center" Margin="0,0,0,5" Command="{Binding RelayCommand}" CommandParameter="LanguageClearAll" Width="80"/>
                            </StackPanel>
                        </DockPanel>

                        <StackPanel Orientation="Vertical" Grid.Column="2">
                            <TextBlock Text="{x:Static Properties:Resources.Shared_ChosenLanguages}"  Margin="0,0,0,5"/>
                            <ListBox Name="selectedLanguages" ItemsSource="{Binding SubtitleBehaviours.SelectedLanguages}" 
                                     helpers:ListBoxHelper.SelectedItems="{Binding SelectedLanguagesToMove}" 
                                             SelectionMode="Extended" Width="140" Height="120"
                                             dd:DragDrop.DropHandler="{Binding}"
                                             dd:DragDrop.IsDragSource="True"
                                             dd:DragDrop.IsDropTarget="True"/>
                        </StackPanel>
                    </Grid>
                </StackPanel>
            </Grid>

            <!-- Options -->
            <TextBlock Grid.Row="3" Grid.Column="0" Text="Options: " Margin="0,20,0,0" />
            <CheckBox Content="{x:Static Properties:Resources.SubtitlesView_AddCC}" Grid.Row="3" Grid.Column="1"  Margin="0,20,0,0" 
                          HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddClosedCaptions}"/>
            <CheckBox Content="{x:Static Properties:Resources.SubtitlesView_AddForeignAudioSearch}"  Grid.Column="1" Grid.Row="4" Margin="0,5,0,0" 
                          HorizontalAlignment="Left" IsChecked="{Binding SubtitleBehaviours.AddForeignAudioScanTrack}"/>


            <!-- Burn In Behaviour -->
            <TextBlock Text="{x:Static Properties:Resources.SubtitlesView_BurnInBehaviour}"  Grid.Column="0" Grid.Row="5" Margin="0,15,5,0" HorizontalAlignment="Left" VerticalAlignment="Center" />
            <ComboBox Name="burninBehaviour"  Grid.Column="2" Grid.Row="5" HorizontalAlignment="Left"
                          ItemsSource="{Binding SubtitleBurnInBehaviourModeList, Converter={StaticResource subtitleBurnInBehaviourConverter}}" 
                          SelectedItem="{Binding SubtitleBehaviours.SelectedBurnInBehaviour, Converter={StaticResource subtitleBurnInBehaviourConverter}}" Width="210" Margin="0,15,5,0">
                <ComboBox.ToolTip>
                    <TextBlock Style="{StaticResource LongToolTip}" Text="{x:Static Properties:Resources.Subtitles_BurnInBehaviourModes}" />
                </ComboBox.ToolTip>
            </ComboBox>
        </Grid>

        <Border BorderBrush="DarkGray" BorderThickness="0,1,0,0" SnapsToDevicePixels="True" Grid.Row="2" Grid.ColumnSpan="3" Margin="10,15,0,0" >
            <Grid Margin="0,10,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <Button Command="{Binding RelayCommand}" CommandParameter="LaunchHelp" Background="Transparent" BorderThickness="0" Grid.Column="0" HorizontalAlignment="Left" Padding="0,2">
                    <Button.Content>
                        <Image Source="/Views/Images/question.png" Width="16" />
                    </Button.Content>
                </Button>

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

                <Button Grid.Column="2"
                        Command="{Binding RelayCommand}" CommandParameter="Save"
                        Content="{x:Static Properties:Resources.Generic_Save}"
                        IsDefault="True"
                        Padding="8,2" />
            </Grid>
        </Border>

    </Grid>
</Window>
