<Window x:Class="PixiEditor.Views.Dialogs.DebugDialogs.CommandDebugPopup"
        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:local="clr-namespace:PixiEditor.Views.Dialogs"
        xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
        xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
        xmlns:command="clr-namespace:PixiEditor.Models.Commands"
        xmlns:cmds="clr-namespace:PixiEditor.Models.Commands.XAML" xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls" xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
        xmlns:helpers="clr-namespace:PixiEditor.Helpers"
        xmlns:views="clr-namespace:PixiEditor.Views"
        xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
        WindowStyle="None"
        mc:Ignorable="d"
        x:Name="uc"
        Foreground="White"
        ui:Translator.Key="COMMAND_DEBUG_WINDOW_TITLE"
        Height="450" Width="800"
        FlowDirection="{helpers:Localization FlowDirection}">

    <Window.CommandBindings>
        <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute"
                        Executed="CommandBinding_Executed_Close" />
    </Window.CommandBindings>

    <WindowChrome.WindowChrome>
        <WindowChrome CaptionHeight="32" GlassFrameThickness="0.1"
                      ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
    </WindowChrome.WindowChrome>

    <DockPanel Background="{StaticResource AccentColor}" Focusable="True">
        <b:Interaction.Behaviors>
            <behaviours:ClearFocusOnClickBehavior />
        </b:Interaction.Behaviors>

        <local:DialogTitleBar DockPanel.Dock="Top"
                              CloseCommand="{x:Static SystemCommands.CloseWindowCommand}"
                              TitleKey="COMMAND_DEBUG_WINDOW_TITLE" />

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

            <StackPanel Orientation="Horizontal" Margin="5">
                <Button Content="Export list" Style="{StaticResource DarkRoundButton}" Command="{cmds:Command PixiEditor.Debug.DumpAllCommands}" Width="100"/>
            </StackPanel>

            <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1">
                <ItemsControl ItemsSource="{Binding Commands, ElementName=uc}" Margin="5,0,0,5">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border BorderThickness="0,0,0,1" BorderBrush="{StaticResource BrighterAccentColor}">
                                <Grid Margin="0,5,0,5">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="35"/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>

                                    <Image Grid.RowSpan="3" Source="{Binding Image}" Margin="0,0,5,0"/>

                                    <TextBlock Text="{Binding Command.InternalName}" Grid.Column="1"/>
                                    <TextBlock Text="{Binding Command.DisplayName, Converter={converters:EmptyStringFillerConverter EmptyText='[internal]', NullText='[internal]'}}" Grid.Column="2" />
                                    <TextBlock Text="{Binding Command.Description, Converter={converters:EmptyStringFillerConverter}}" Grid.Column="3" />

                                    <usercontrols:PrependTextBlock Prepend="Default Shortcut: '" Text="{Binding Command.DefaultShortcut}" Append="'"  Grid.Row="1" Grid.Column="1"/>
                                    <usercontrols:PrependTextBlock Prepend="Current Shortcut: '" Text="{Binding Command.Shortcut}" Append="'" Grid.Row="1" Grid.Column="2"/>
                                    <usercontrols:PrependTextBlock Prepend="Is Debug: '" Text="{Binding Command.IsDebug}" Append="'" Grid.Row="1" Grid.Column="3"/>

                                    <ContentControl Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3" Content="{Binding Comments}"/>
                                </Grid>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </Grid>
    </DockPanel>
</Window>