<UserControl x:Class="Configuration.View.MainSettings"
             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:c="clr-namespace:Configuration.Converter"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <c:InverseBooleanConverter x:Key="InverseBoolConverter"/>
        <BooleanToVisibilityConverter x:Key="BoolVisibilityConverter"/>
        <c:InverseBooleanToVisibilityConverter x:Key="InverseBoolVisibilityConverter"/>
    </UserControl.Resources>
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <GroupBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Header="Display">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <TextBlock Grid.Row="0" Grid.Column="0" Text="Horizontal resolution" />
                <TextBox Grid.Row="0" Grid.Column="1" Width="50"
                            Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.HorizontalResolution}"
                            IsEnabled="{Binding ElementName=HorizontalStretch, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}"
                            />
                <CheckBox Grid.Row="0" Grid.Column="2" Name="HorizontalStretch" Content="Stretch (use OS defaults)" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsHorizontalStretch}"/>

                <TextBlock Grid.Row="2" Grid.Column="0" Text="Vertical resolution" />
                <TextBox Grid.Row="2" Grid.Column="1" Width="50"
                                        Text ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.VerticalResolution}"
                                        IsEnabled="{Binding ElementName=VerticalStretch, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}"
                                        />

                <CheckBox Grid.Row="2" Grid.Column="2" Name="VerticalStretch" Content="Stretch (use OS defaults)" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsVerticalStretch}"/>

                <CheckBox Grid.Row="4" Grid.Column="0" Content="Fullscreen" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsFullscreen}"/>
            </Grid>
        </GroupBox>
        
        <GroupBox Grid.Row="1" Grid.Column="0" Header="Navigation and Layout">
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Layouts}" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.Layout}"/>
                    <TextBlock Text="Default layout" />
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <ComboBox DisplayMemberPath="Name" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Collections}" SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.FirstCollection}"/>
                    <TextBlock Text="First collection to show on startup" />
                </StackPanel>
                <CheckBox Content="Exit if 'back' key is pressed on first menu"  IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsExitOnFirstBack}"/>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="1" Grid.Column="1" Header="Video">
            <StackPanel Orientation="Vertical">
                <CheckBox Content="Enable video playback"  IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsVideoEnabled}"/>
                <StackPanel Orientation="Horizontal">
                    <TextBox Width="40" IsEnabled="{Binding ElementName=VideoLoopInfinite, Path=IsChecked, Converter={StaticResource InverseBoolConverter}}" Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.VideoLoop}"/>
                    <TextBlock Text="# Times to play" />
                </StackPanel>
                <CheckBox Name="VideoLoopInfinite" Content="Loop Infinite" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsInfiniteLoop}" />
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="2" Grid.Column="0" Header="Attract Mode">
            <StackPanel Orientation="Vertical">
                <CheckBox Name="EnableAttractMode" Content="Enable attract mode"  IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsAttractModeEnabled}"/>
                <StackPanel Orientation="Horizontal">

                    <TextBox Width="40" 
                             Text ="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.AttractModeTime}"
                             IsEnabled="{Binding ElementName=EnableAttractMode, Path=IsChecked}"
                              />
                    <TextBlock Text="Idle time" />
                </StackPanel>
            </StackPanel>
        </GroupBox>
        <GroupBox Grid.Row="2" Grid.Column="1" Header="Hiding">
            <StackPanel Orientation="Vertical">
                <CheckBox Content="Hide mouse" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsMouseHidden}"/>
                <CheckBox Content="Hide parenthesis '()' in titles" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsParenthesisVisible}"/>
                <CheckBox Content="Hide braces '[]' in titles" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=Data.IsBracesVisible}"/>
            </StackPanel>
        </GroupBox>


    </Grid>
</UserControl>
