<Window x:Class="ScreenToGif.Windows.Other.AutomatedTask"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:n="clr-namespace:ScreenToGif.Controls"
        xmlns:m="clr-namespace:ScreenToGif.Model"
        xmlns:c="clr-namespace:ScreenToGif.Util.Converters"
        xmlns:u="clr-namespace:ScreenToGif.Util"
        Title="{DynamicResource S.Options.Tasks.Title}" Width="370" Height="400" MinWidth="350" MinHeight="300" 
        WindowStartupLocation="CenterScreen" SnapsToDevicePixels="True" Background="{DynamicResource Panel.Background}" Loaded="Window_Loaded">

    <Window.CommandBindings>
        <CommandBinding Command="{StaticResource Command.Ok}" CanExecute="Ok_CanExecute" Executed="Ok_Executed"/>
    </Window.CommandBindings>
    
    <Window.Resources>
        <c:StringToStaticResource x:Key="StringToStaticResource"/>
        <c:NullToVisibility x:Key="NullToVisibility"/>
        <u:ComboBoxItemTemplateSelector x:Key="ItemSelector"/>
    </Window.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition/>
            <RowDefinition Height="40"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Background="{DynamicResource Panel.Background.Level4}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Border Grid.Column="0" x:Name="MainBorder" Margin="6" Background="{StaticResource Vector.Add}" Width="23" Opacity="{DynamicResource Element.Opacity}"/>

            <TextBlock Grid.Column="1" x:Name="TypeTextBlock" Text="{DynamicResource S.Add}" Margin="5" VerticalAlignment="Center" 
                       FontFamily="Segoe UI Semilight" FontSize="18" Foreground="{DynamicResource Element.Foreground.Header}"/>

            <ComboBox Grid.Column="2" x:Name="TypeComboBox" Margin="5,3" SelectedIndex="0" ItemTemplateSelector="{StaticResource ItemSelector}" SelectionChanged="TypeComboBox_Selected">
                <u:ComboBoxItemTemplateSelector.SelectedTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30"/>
                                <ColumnDefinition Width="1"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <Border Grid.Column="0" Background="{Binding Image, Converter={StaticResource StringToStaticResource}}" Width="14" Height="14" Margin="3,2,6,2"/>

                            <Separator Grid.Column="1" Width="1" Margin="0"/>
                            <TextBlock Grid.Column="2" Text="{Binding Kind}" Margin="10,0,2,0" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center"/>
                        </Grid>
                    </DataTemplate>
                </u:ComboBoxItemTemplateSelector.SelectedTemplate>

                <u:ComboBoxItemTemplateSelector.DropDownTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30"/>
                                <ColumnDefinition Width="1"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <Border Grid.Column="0" Background="{Binding Image, Converter={StaticResource StringToStaticResource}}" Width="20" Height="20" Margin="3,3,6,3"/>

                            <Separator Grid.Column="1" Width="1" Margin="0"/>
                            <TextBlock Grid.Column="2" Text="{Binding Kind}" Margin="10,0,2,0" Foreground="{DynamicResource Element.Foreground.Medium}" VerticalAlignment="Center"/>
                        </Grid>
                    </DataTemplate>
                </u:ComboBoxItemTemplateSelector.DropDownTemplate>

                <m:DefaultTaskModel Image="Vector.Info"/>
                <m:MouseClicksModel Image="Vector.Cursor"/>
                <m:KeyStrokesModel Image="Vector.Keyboard"/>
                <m:DelayModel Image="Vector.Clock"/>
                <m:ProgressModel Image="Vector.Progress"/>
                <m:BorderModel Image="Vector.Border"/>
                <m:ShadowModel Image="Vector.Shadow"/>
            </ComboBox>
        </Grid>

        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto">
            <ContentControl x:Name="MainPresenter" Focusable="False"/>
        </ScrollViewer>

        <TextBlock Grid.Row="1" FontSize="20" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap"
                   Foreground="{DynamicResource Element.Foreground.Gray192}" FontFamily="Segoe UI Semilight" Effect="{StaticResource Shadow.Background.Tiny}"
                   Visibility="{Binding ElementName=MainPresenter, Path=Content, Converter={StaticResource NullToVisibility}}">
            <Run Text="▲"/>
            <LineBreak/>
            <Run Text="{DynamicResource S.Options.Tasks.SelectType.Info}"/>
        </TextBlock>
        
        <Grid Grid.Row="2" Background="{DynamicResource Panel.Background.Level3}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto" MinWidth="100"/>
                <ColumnDefinition Width="Auto" MinWidth="100"/>
            </Grid.ColumnDefinitions>

            <n:ExtendedCheckBox Grid.Column="0" x:Name="EnabledCheckBox" Text="{DynamicResource S.Options.Tasks.Enable}" Margin="5,3" Visibility="Collapsed"
                                IsChecked="{Binding ElementName=MainPresenter, Path=Content.DataContext.IsEnabled, FallbackValue=True}"/>

            <n:ExtendedButton Grid.Column="1" x:Name="OkButton" Text="{DynamicResource S.Ok}" Icon="{StaticResource Vector.Ok}" ContentHeight="18" ContentWidth="18" 
                              Padding="4,0" Margin="5" Command="{StaticResource Command.Ok}"/>
            <n:ExtendedButton Grid.Column="2" x:Name="CancelButton" Text="{DynamicResource S.Cancel}" Icon="{StaticResource Vector.Cancel}" ContentHeight="18" ContentWidth="18" 
                              Padding="4,0" Margin="5" Click="CancelButton_Click" IsCancel="True"/>
        </Grid>
    </Grid>
</Window>