<UserControl  x:Class="HandBrakeWPF.Views.OptionsView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:Options="clr-namespace:HandBrakeWPF.Converters.Options"
              xmlns:Converters="clr-namespace:HandBrakeWPF.Converters" xmlns:local="clr-namespace:HandBrakeWPF.Model"
              xmlns:Properties="clr-namespace:HandBrakeWPF.Properties"
              xmlns:views="clr-namespace:HandBrakeWPF.Views"
              xmlns:options="clr-namespace:HandBrakeWPF.Views.Options">

    <UserControl.Resources>

        <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="Margin" Value="0,0,5,0" />
        </Style>

        <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
            <Setter Property="Padding" Value="5,2" />
            <Setter Property="MinHeight" Value="22" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="ToolTipService.ShowDuration" Value="20000" />
        </Style>

        <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
            <Setter Property="Margin" Value="0,2,0,2" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>

        <Style TargetType="ListBoxItem" BasedOn="{StaticResource {x:Type ListBoxItem}}">
            <Setter Property="Padding" Value="8,4" />
        </Style>

        <Options:OptionsTabConverter x:Key="tabConverter" />
        <Options:OptionsTabNameConverter x:Key="tabNameConverter" />
        <Converters:EnumComboConverter x:Key="enumComboConverter" />

        <Options:FileSizeConverter x:Key="fileSizeConverter" />
        <Converters:OptionTabConverter x:Key="optionTabConverter" />

        <Options:Mp4BehaviourConverter x:Key="Mp4BehaviourConverter" />
        <Options:UpdateCheckConverter x:Key="UpdateCheckConverter" />
        <Options:ThemeSettingConverter x:Key="ThemeSettingConverter" />
        <Options:PresetDisplayModeConverter x:Key="PresetDisplayModeConverter" />
        <Options:RightToLeftConverter x:Key="RightToLeftConverter" />

        <Converters:BooleanToVisibilityConverter x:Key="boolToVisConverter" />

        <ObjectDataProvider MethodName="GetValues"
                        ObjectType="{x:Type local:OptionsTab}"
                        x:Key="OptionTabsList">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="local:OptionsTab" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>


    </UserControl.Resources>

    <Grid Margin="0,0,0,10">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="180" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

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

        <!-- Row 1 -->
        <Grid  Grid.Row="0" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

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

        <Grid Grid.Column="0" Grid.Row="1" HorizontalAlignment="Left">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <StackPanel Orientation="Vertical" Margin="11,0,-1,0">

                <Button Content="{x:Static Properties:Resources.OptionsView_BackButton}" IsDefault="True" Command="{Binding RelayCommand}" CommandParameter="Close" 
                            HorizontalAlignment="Left" Padding="12,2" Margin="0,0,0,10" />

                <ListBox x:Name="optionCategories" ItemsSource="{Binding Source={StaticResource OptionTabsList}, Converter={StaticResource optionTabConverter}}" SelectedItem="{Binding SelectedTab}"
                                 BorderThickness="0" Background="Transparent" ItemContainerStyle="{StaticResource ModernListBoxItemStyle}" Width="150">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                                <TextBlock Text="{Binding Converter={StaticResource tabNameConverter}}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Grid.Column="1" />
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

            </StackPanel>
        </Grid>

        <StackPanel Grid.Row="2" Grid.Column="0">
            <Button Command="{Binding RelayCommand}" CommandParameter="LaunchHelp" Background="Transparent" BorderThickness="0"
                    HorizontalAlignment="Left" Padding="0,2" Margin="10,0,0,0" ToolTip="{x:Static Properties:ResourcesTooltips.OptionsView_LaunchsHelp}">
                <Button.Content>
                    <Image Source="/Views/Images/question.png" Width="16" />
                </Button.Content>
            </Button>
        </StackPanel>


        <ScrollViewer Grid.Column="1" Grid.Row="0" Grid.RowSpan="2" Margin="0,10,0,0">
            <StackPanel Orientation="Vertical">

                <StackPanel Name="General" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.General}}">
                    <options:OptionsGeneral DataContext="{Binding}"/>
                </StackPanel>

                <StackPanel Name="Output" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.OutputFiles}}">
                    <options:OptionsOutput DataContext="{Binding}"/>
                </StackPanel>

                <StackPanel Name="WhenDone" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.WhenDone}}">
                    <options:OptionsWhenDone DataContext="{Binding}" />
                </StackPanel>

                <StackPanel Name="Hardware" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.Video}}">
                    <options:OptionsHardware DataContext="{Binding}" />
                </StackPanel>

                <StackPanel  Name="Advanced" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.Advanced}}">
                    <options:OptionsAdvanced DataContext="{Binding }" />
                </StackPanel>

                <StackPanel Name="Updates" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.Updates}}">
                    <options:OptionsUpdates DataContext="{Binding }" />
                </StackPanel>

                <StackPanel Name="Reset" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.Reset}}">
                    <options:OptionsReset DataContext="{Binding}" />
                </StackPanel>

                <StackPanel Name="About" Orientation="Vertical" Margin="10,5,0,0"
                            Visibility="{Binding SelectedTab, Converter={StaticResource tabConverter}, ConverterParameter={x:Static local:OptionsTab.About}}">
                    <TextBlock Text="{x:Static Properties:Resources.Options_About}" Style="{StaticResource pageHeader}"  />
                    <views:AboutView x:Name="AboutViewModel" DataContext="{Binding AboutViewModel}" />
                </StackPanel>
            </StackPanel>
        </ScrollViewer>

    </Grid>

</UserControl>
