<Window x:Class="ScreenToGif.Windows.Other.KeyStrokes"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:n="clr-namespace:ScreenToGif.Controls"
        Title="{DynamicResource S.KeyStrokes.Edit.Title}" MinWidth="350" MinHeight="250" Height="500" Width="450" WindowStartupLocation="CenterScreen"
        Background="{DynamicResource Panel.Background}" Loaded="KeyStrokes_Loaded">

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

        <n:StatusBand Grid.Row="0" x:Name="StatusBand"/>

        <DataGrid Grid.Row="1" x:Name="KeysDataGrid" Margin="3" MinHeight="60" SelectionMode="Single" MinRowHeight="28" SelectionUnit="FullRow">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="{DynamicResource S.KeyStrokes.Edit.Number}" Width="90" IsReadOnly="True" SortMemberPath="Index">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Path=Index, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" Margin="3,0"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="{DynamicResource S.KeyStrokes.Edit.Keys}" IsReadOnly="True" Width="*" CanUserSort="False">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ItemsControl x:Name="MainItemsControl" ItemsSource="{Binding Path=KeyList, UpdateSourceTrigger=PropertyChanged}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <DockPanel>
                                            <n:KeyBox x:Name="KeyBox" MainKey="{Binding Key, Mode=TwoWay}" ModifierKeys="{Binding Modifiers, Mode=TwoWay}" Margin="1,1,0,1" Padding="0" 
                                                      AllowAllKeys="True" CanRemove="False" IsSingleLetterLowerCase="{Binding IsUppercase, Mode=TwoWay, Converter={StaticResource InvertedBool}}"/>

                                            <n:ExtendedButton DockPanel.Dock="Right" x:Name="RemoveButton" Icon="{StaticResource Vector.Close}" Style="{StaticResource Style.Button.NoText.Border}" 
                                                              ContentWidth="12" ContentHeight="12" Width="16" Margin="0,1,1,1" BorderThickness="0,1,1,1" Height="23" ToolTip="{DynamicResource S.KeyStrokes.Edit.Remove}"
                                                              PreviewMouseLeftButtonUp="RemoveButton_OnMouseLeftButtonDown"/>
                                        </DockPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel Orientation="Horizontal" Margin="0"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>

            <DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="20"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>

                        <Border Background="{StaticResource Vector.Arrow.Blue.Top}" Margin="5,0"/>

                        <TextBlock Grid.Column="1" Text="{DynamicResource S.KeyStrokes.Edit.Add}" Foreground="{DynamicResource Element.Foreground}" VerticalAlignment="Center" Margin="2,3,5,3"/>

                        <n:KeyBox Grid.Column="2" x:Name="AddKeyBox" MinWidth="100" AllowAllKeys="True" CanRemove="False" IsSingleLetterLowerCase="{Binding ElementName=LowercaseCheckBox, Path=IsChecked}"/>

                        <n:ExtendedButton Grid.Column="3" x:Name="AddButton" Text="{DynamicResource S.Add}" Icon="{StaticResource Vector.Add}" ContentHeight="14" Height="23" Padding="5,0" Margin="5,3"
                                          Click="AddButton_Click"/>
                    </Grid>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
            
            <!--<model:FrameInfo Delay="10" Index="0">
                <model:FrameInfo.KeyList>
                    <util:SimpleKeyGesture Key="A" Modifiers="Control"/>
                    <util:SimpleKeyGesture Key="B" Modifiers="Shift"/>
                    <util:SimpleKeyGesture Key="C" Modifiers="Alt"/>
                    <util:SimpleKeyGesture Key="C" Modifiers="Alt"/>
                    <util:SimpleKeyGesture Key="C" Modifiers="Alt"/>
                    <util:SimpleKeyGesture Key="C" Modifiers="Alt"/>
                    <util:SimpleKeyGesture Key="C" Modifiers="Alt"/>
                </model:FrameInfo.KeyList>
            </model:FrameInfo>-->
            <!--<model:FrameInfo Delay="10" Index="1"/>-->
        </DataGrid>

        <Grid Grid.Row="2" Grid.Column="0" Background="{DynamicResource Panel.Background.Level3}" UseLayoutRounding="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <n:ExtendedCheckBox Grid.Column="0" x:Name="LowercaseCheckBox" Text="{DynamicResource S.KeyStrokes.Edit.Lower}" Margin="3,0" HorizontalAlignment="Center"
                                ToolTip="{DynamicResource S.KeyStrokes.Edit.Lower.Info}"/>

            <n:ExtendedButton Grid.Column="1" x:Name="OkButton" Text="{DynamicResource S.Ok}" Icon="{StaticResource Vector.Ok}" IsDefault="True" 
                              ContentWidth="18" ContentHeight="18" Padding="5,0" MinWidth="90" Margin="5" Click="OkButton_Click"/>

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