<!--
    Copyright (c) Microsoft Corporation. All rights reserved. Licensed under
    the MIT License. See LICENSE in the project root for license information.
-->
<Page x:Class="Microsoft.Terminal.Settings.Editor.Actions"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:local="using:Microsoft.Terminal.Settings.Editor"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:mtu="using:Microsoft.Terminal.UI"
      mc:Ignorable="d">

    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="CommonResources.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <!--  Theme Dictionary  -->
            <ResourceDictionary.ThemeDictionaries>
                <ResourceDictionary x:Key="Dark">
                    <!--  TextBox colors !  -->
                    <SolidColorBrush x:Key="TextControlBackground"
                                     Color="#333333" />
                    <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush"
                                     Color="#B5B5B5" />
                    <SolidColorBrush x:Key="TextControlForeground"
                                     Color="#B5B5B5" />
                    <SolidColorBrush x:Key="TextControlBorderBrush"
                                     Color="#404040" />
                    <SolidColorBrush x:Key="TextControlButtonForeground"
                                     Color="#B5B5B5" />

                    <SolidColorBrush x:Key="TextControlBackgroundPointerOver"
                                     Color="#404040" />
                    <SolidColorBrush x:Key="TextControlForegroundPointerOver"
                                     Color="#FFFFFF" />
                    <SolidColorBrush x:Key="TextControlBorderBrushPointerOver"
                                     Color="#404040" />
                    <SolidColorBrush x:Key="TextControlButtonForegroundPointerOver"
                                     Color="#FF4343" />

                    <SolidColorBrush x:Key="TextControlBackgroundFocused"
                                     Color="#333333" />
                    <SolidColorBrush x:Key="TextControlForegroundFocused"
                                     Color="#FFFFFF" />
                    <SolidColorBrush x:Key="TextControlBorderBrushFocused"
                                     Color="#404040" />
                    <SolidColorBrush x:Key="TextControlButtonForegroundPressed"
                                     Color="#FFFFFF" />
                    <SolidColorBrush x:Key="TextControlButtonBackgroundPressed"
                                     Color="#FF4343" />

                    <!--  KeyChordText styles  -->
                    <Style x:Key="KeyChordBorderStyle"
                           TargetType="Border">
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
                        <Setter Property="Background" Value="{ThemeResource SystemAltMediumLowColor}" />
                        <Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
                    </Style>
                    <Style x:Key="KeyChordTextBlockStyle"
                           TargetType="TextBlock">
                        <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
                    </Style>

                </ResourceDictionary>
                <ResourceDictionary x:Key="Light">
                    <!--  TextBox colors !  -->
                    <SolidColorBrush x:Key="TextControlBackground"
                                     Color="#CCCCCC" />
                    <SolidColorBrush x:Key="TextBoxPlaceholderTextThemeBrush"
                                     Color="#636363" />
                    <SolidColorBrush x:Key="TextControlBorderBrush"
                                     Color="#636363" />
                    <SolidColorBrush x:Key="TextControlButtonForeground"
                                     Color="#636363" />

                    <SolidColorBrush x:Key="TextControlBackgroundPointerOver"
                                     Color="#DADADA" />
                    <SolidColorBrush x:Key="TextControlBorderBrushPointerOver"
                                     Color="#636363" />
                    <SolidColorBrush x:Key="TextControlButtonForegroundPointerOver"
                                     Color="#FF4343" />

                    <SolidColorBrush x:Key="TextControlBackgroundFocused"
                                     Color="#CCCCCC" />
                    <SolidColorBrush x:Key="TextControlBorderBrushFocused"
                                     Color="#636363" />
                    <SolidColorBrush x:Key="TextControlButtonForegroundPressed"
                                     Color="#FFFFFF" />
                    <SolidColorBrush x:Key="TextControlButtonBackgroundPressed"
                                     Color="#FF4343" />

                    <!--  KeyChordText styles  -->
                    <Style x:Key="KeyChordBorderStyle"
                           TargetType="Border">
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
                        <Setter Property="Background" Value="{ThemeResource SystemAltMediumLowColor}" />
                        <Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
                    </Style>
                    <Style x:Key="KeyChordTextBlockStyle"
                           TargetType="TextBlock">
                        <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" />
                    </Style>

                </ResourceDictionary>
                <ResourceDictionary x:Key="HighContrast">

                    <!--  KeyChordText styles (use XAML defaults for High Contrast theme)  -->
                    <Style x:Key="KeyChordBorderStyle"
                           TargetType="Border" />
                    <Style x:Key="KeyChordTextBlockStyle"
                           TargetType="TextBlock" />

                </ResourceDictionary>
            </ResourceDictionary.ThemeDictionaries>

            <!--  Styles  -->
            <Style x:Key="KeyBindingContainerStyle"
                   BasedOn="{StaticResource DefaultListViewItemStyle}"
                   TargetType="ListViewItem">
                <Setter Property="Padding" Value="12,4,4,4" />
                <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                <Setter Property="XYFocusKeyboardNavigation" Value="Enabled" />
            </Style>
            <Style x:Key="KeyBindingNameTextBlockStyle"
                   BasedOn="{StaticResource BaseTextBlockStyle}"
                   TargetType="TextBlock">
                <Setter Property="VerticalAlignment" Value="Center" />
                <Setter Property="TextWrapping" Value="WrapWholeWords" />
            </Style>
            <Style x:Key="KeyChordEditorStyle"
                   TargetType="local:KeyChordListener">
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>

            <!--  Converters & Misc.  -->
            <SolidColorBrush x:Key="ActionContainerBackgroundEditing"
                             Color="{ThemeResource SystemListMediumColor}" />
            <SolidColorBrush x:Key="ActionContainerBackground"
                             Color="Transparent" />

            <!--  Templates  -->
            <DataTemplate x:Key="CommandTemplate"
                          x:DataType="local:CommandViewModel">
                <ListViewItem AutomationProperties.Name="{x:Bind DisplayNameAndKeyChordAutomationPropName, Mode=OneWay}"
                              Style="{StaticResource KeyBindingContainerStyle}">
                    <Grid ColumnSpacing="8">
                        <Grid.ColumnDefinitions>
                            <!--  command name  -->
                            <ColumnDefinition Width="*" />
                            <!--  key chord  -->
                            <ColumnDefinition Width="auto" />
                        </Grid.ColumnDefinitions>

                        <!--  Command Name  -->
                        <TextBlock Grid.Column="0"
                                   FontWeight="Normal"
                                   Style="{StaticResource KeyBindingNameTextBlockStyle}"
                                   Text="{x:Bind DisplayName, Mode=OneWay}" />
                        <!--  Key Chord Text  -->
                        <Border Grid.Column="1"
                                Padding="8,4,8,4"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                Style="{ThemeResource KeyChordBorderStyle}"
                                Visibility="{x:Bind mtu:Converters.StringNotEmptyToVisibility(FirstKeyChordText)}">
                            <TextBlock FontSize="14"
                                       Style="{ThemeResource KeyChordTextBlockStyle}"
                                       Text="{x:Bind FirstKeyChordText, Mode=OneWay}"
                                       TextWrapping="WrapWholeWords" />
                        </Border>
                    </Grid>
                </ListViewItem>
            </DataTemplate>
        </ResourceDictionary>
    </Page.Resources>

    <Border MaxWidth="{StaticResource StandardControlMaxWidth}">
        <StackPanel MaxWidth="600"
                    HorizontalAlignment="Left"
                    Spacing="8"
                    Style="{StaticResource SettingsStackStyle}">
            <HyperlinkButton x:Uid="Actions_Disclaimer"
                             Margin="0"
                             Padding="0"
                             NavigateUri="https://go.microsoft.com/fwlink/?linkid=2341386" />
            <!--  Add New Button  -->
            <Button x:Name="AddNewButton"
                    Margin="0,12,0,0"
                    Click="{x:Bind ViewModel.AddNewCommand}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <FontIcon FontSize="{StaticResource StandardIconSize}"
                                  Glyph="&#xE710;" />
                        <TextBlock x:Uid="Actions_AddNewTextBlock"
                                   Style="{StaticResource IconButtonTextBlockStyle}" />
                    </StackPanel>
                </Button.Content>
            </Button>

            <!--  Commands  -->
            <ListView x:Name="CommandsListView"
                      Margin="-8,0,0,0"
                      IsItemClickEnabled="True"
                      ItemClick="{x:Bind ViewModel.CmdListItemClicked}"
                      ItemTemplate="{StaticResource CommandTemplate}"
                      ItemsSource="{x:Bind ViewModel.CommandList, Mode=OneWay}" />
        </StackPanel>
    </Border>
</Page>
