<Window x:Class="HandBrakeWPF.Views.QueueSelectionView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:cal="http://www.caliburnproject.org"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Title="{Binding Title}"
        Width="450"
        MaxHeight="450"
        SizeToContent="Height"
        WindowStartupLocation="CenterScreen"
        TextOptions.TextFormattingMode="Display"
        mc:Ignorable="d">

    <Window.Resources>

        <Style x:Key="LongToolTipHolder" TargetType="FrameworkElement">
            <Setter Property="ToolTipService.ShowDuration" Value="20000" />
            <Setter Property="Margin" Value="0,2,0,2" />
        </Style>
    </Window.Resources>

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

        <!--  Header  -->
        <StackPanel Grid.Row="0"
                    Height="30"
                    Margin="0,0,0,10"
                    Background="White"
                    Orientation="Horizontal">
            <Image Width="24"
                   Height="24"
                   Margin="10,0,5,0"
                   VerticalAlignment="Center"
                   Source="Images/AddToQueue_small.png" />
            <StackPanel VerticalAlignment="Center" Orientation="Vertical">
                <TextBlock FontWeight="Bold" Text="Queue Multiple Items" />
            </StackPanel>
        </StackPanel>

        <!-- Text -->
        <StackPanel Orientation="Vertical" Grid.Row="1" Margin="10,10,10,0">
            <TextBlock Text="Select multiple titles to add: " />
        </StackPanel>

        <!-- Selection -->
        <ListBox Grid.Row="2"
                 Margin="10,10,10,10"
                 VerticalAlignment="Stretch"
                 Background="LightGray"
                 ItemsSource="{Binding TitleList}"
                 SelectionMode="Single">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                    <Setter Property="Background" Value="WhiteSmoke" />
                    <Setter Property="Margin" Value="0,0,0,1" />
                </Style>
            </ListBox.ItemContainerStyle>

            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action SelectAll]" />
                    <MenuItem Header="Select All" cal:Message.Attach="[Event Click] = [Action UnSelectAll]" />
                    <Separator />
                    <MenuItem Header="Order by Title" IsChecked="{Binding OrderedByTitle}" cal:Message.Attach="[Event Click] = [Action OrderByTitle]" />
                    <MenuItem Header="Order by Duration" IsChecked="{Binding OrderedByDuration}" cal:Message.Attach="[Event Click] = [Action OrderByDuration]" />
                </ContextMenu>
            </ListBox.ContextMenu>

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Stretch" MinHeight="28">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        
                        <CheckBox IsChecked="{Binding IsSelected}" Grid.RowSpan="2" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" />

                        <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" >                           
                            <TextBlock Text="Title:" Margin="0,0,5,0" FontWeight="Bold" />
                            <TextBlock Text="{Binding Title}" Margin="5,0,5,0" />
                        </StackPanel>

                        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" Margin="10,0,0,0" >
                            <TextBlock Text="Source:" Margin="0,0,5,0" FontWeight="Bold" />
                            <TextBlock Text="{Binding SourceName}" Margin="5,0,5,0" />
                        </StackPanel>
                    </Grid>

                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <!-- Checlist -->
        <StackPanel Orientation="Vertical" Grid.Row="3" Margin="10,10,10,0">
            <TextBlock Text="Checklist " />
        </StackPanel>

        <!--  Controls  -->
        <Grid Grid.Row="4"
              Margin="0,20,0,0"
              Background="LightGray">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="1"
                    Margin="0,5,10,5"
                    cal:Message.Attach="[Event Click] = [Action Cancel]"
                    Content="Cancel"
                    IsCancel="True"
                    Padding="8,2" />
            <Button Grid.Column="2"
                    Margin="0,5,10,5"
                    cal:Message.Attach="[Event Click] = [Action Add]"
                    Content="Add"
                    IsDefault="True"
                    Padding="8,2" />
        </Grid>

    </Grid>
</Window>
