<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Microsoft.CmdPal.UI.Dock">

    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <SolidColorBrush x:Key="DockItemBackground" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBorderBrush" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBackgroundPointerOver" Color="#0FFFFFFF" />
            <SolidColorBrush x:Key="DockItemBackgroundPressed" Color="#0BFFFFFF" />
            <LinearGradientBrush x:Key="DockItemBorderBrushPointerOver" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0.33" Color="#0FFFFFFF" />
                    <GradientStop Offset="1.0" Color="#19FFFFFF" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="DockItemBorderBrushPressed" Color="#0BFFFFFF" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="Light">
            <SolidColorBrush x:Key="DockItemBackground" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBorderBrush" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBackgroundPointerOver" Color="#80FFFFFF" />
            <SolidColorBrush x:Key="DockItemBackgroundPressed" Color="#4DFFFFFF" />
            <LinearGradientBrush x:Key="DockItemBorderBrushPointerOver" MappingMode="Absolute" StartPoint="0,0" EndPoint="0,3">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0.33" Color="#08000000" />
                    <GradientStop Offset="1.0" Color="#17000000" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
            <SolidColorBrush x:Key="DockItemBorderBrushPressed" Color="#05000000" />
        </ResourceDictionary>
        <ResourceDictionary x:Key="HighContrast">
            <SolidColorBrush x:Key="DockItemBackground" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBorderBrush" Color="Transparent" />
            <SolidColorBrush x:Key="DockItemBackgroundPointerOver" Color="{StaticResource SystemColorHighlightTextColor}" />
            <SolidColorBrush x:Key="DockItemBackgroundPressed" Color="{StaticResource SystemColorHighlightTextColor}" />
            <SolidColorBrush x:Key="DockItemBorderBrushPointerOver" Color="{StaticResource SystemColorHighlightColor}" />
            <SolidColorBrush x:Key="DockItemBorderBrushPressed" Color="{StaticResource SystemColorHighlightTextColor}" />
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>

    <CornerRadius x:Key="DockItemCornerRadius">4</CornerRadius>
    <Thickness x:Key="DockItemPadding">4,0,4,0</Thickness>
    <Thickness x:Key="DockItemMargin">2,0,2,0</Thickness>
    <Style BasedOn="{StaticResource DefaultDockItemControlStyle}" TargetType="local:DockItemControl" />

    <Style x:Key="DefaultDockItemControlStyle" TargetType="local:DockItemControl">
        <Style.Setters>
            <Setter Property="Background" Value="{ThemeResource DockItemBackground}" />
            <Setter Property="BorderBrush" Value="{ThemeResource DockItemBorderBrush}" />
            <Setter Property="Padding" Value="{StaticResource DockItemPadding}" />
            <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
            <Setter Property="CornerRadius" Value="{StaticResource DockItemCornerRadius}" />
            <Setter Property="TextVisibility" Value="Visible" />
            <Setter Property="IsTabStop" Value="True" />
            <Setter Property="UseSystemFocusVisuals" Value="True" />
            <Setter Property="FocusVisualMargin" Value="-2" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="local:DockItemControl">
                        <Grid
                            x:Name="PART_RootGrid"
                            Padding="{StaticResource DockItemMargin}"
                            Background="Transparent">
                            <Grid
                                x:Name="PART_BackPlate"
                                MinWidth="32"
                                Padding="{TemplateBinding Padding}"
                                VerticalAlignment="Stretch"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                CornerRadius="{TemplateBinding CornerRadius}">
                                <Grid
                                    x:Name="ContentGrid"
                                    AutomationProperties.Name="{TemplateBinding Title}"
                                    Background="Transparent"
                                    ColumnSpacing="8">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>

                                    <!--  Icon  -->
                                    <ContentPresenter
                                        x:Name="IconPresenter"
                                        VerticalAlignment="Center"
                                        Content="{TemplateBinding Icon}" />

                                    <!--  Text (Title + Subtitle)  -->
                                    <StackPanel
                                        x:Name="TextPanel"
                                        Grid.Column="1"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Center"
                                        Visibility="{TemplateBinding TextVisibility}">
                                        <TextBlock
                                            x:Name="TitleText"
                                            MinWidth="24"
                                            MaxWidth="100"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Center"
                                            FontFamily="Segoe UI"
                                            FontSize="12"
                                            Text="{TemplateBinding Title}"
                                            TextAlignment="Left"
                                            TextTrimming="CharacterEllipsis"
                                            TextWrapping="NoWrap" />
                                        <TextBlock
                                            x:Name="SubtitleText"
                                            MaxWidth="100"
                                            Margin="0,-2,0,0"
                                            HorizontalAlignment="Stretch"
                                            VerticalAlignment="Center"
                                            FontFamily="Segoe UI"
                                            FontSize="10"
                                            Foreground="{ThemeResource TextFillColorTertiary}"
                                            Text="{TemplateBinding Subtitle}"
                                            TextAlignment="Left"
                                            TextTrimming="CharacterEllipsis"
                                            TextWrapping="NoWrap" />
                                    </StackPanel>
                                </Grid>
                            </Grid>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="PointerOver">
                                        <VisualState.Setters>
                                            <Setter Target="PART_BackPlate.Background" Value="{ThemeResource DockItemBackgroundPointerOver}" />
                                            <Setter Target="PART_BackPlate.BorderBrush" Value="{ThemeResource DockItemBorderBrushPointerOver}" />
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <VisualState.Setters>
                                            <Setter Target="PART_BackPlate.Background" Value="{ThemeResource DockItemBackgroundPointerOver}" />
                                            <Setter Target="PART_BackPlate.BorderBrush" Value="{ThemeResource DockItemBorderBrushPressed}" />
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="Disabled">
                                        <VisualState.Setters>
                                            <Setter Target="PART_BackPlate.Background" Value="{ThemeResource DockItemBackground}" />
                                            <Setter Target="PART_BackPlate.BorderBrush" Value="{ThemeResource DockItemBackground}" />
                                            <Setter Target="IconPresenter.Foreground" Value="{ThemeResource ButtonForegroundDisabled}" />
                                            <Setter Target="TitleText.Foreground" Value="{ThemeResource ButtonForegroundDisabled}" />
                                            <Setter Target="SubtitleText.Foreground" Value="{ThemeResource ButtonForegroundDisabled}" />
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="TextVisibilityStates">
                                    <VisualState x:Name="TextVisible" />
                                    <VisualState x:Name="TitleOnly">
                                        <VisualState.Setters>
                                            <Setter Target="SubtitleText.Visibility" Value="Collapsed" />
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="SubtitleOnly">
                                        <VisualState.Setters>
                                            <Setter Target="TitleText.Visibility" Value="Collapsed" />
                                            <Setter Target="SubtitleText.Margin" Value="0" />
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="TextHidden">
                                        <VisualState.Setters>
                                            <Setter Target="ContentGrid.ColumnSpacing" Value="0" />
                                            <Setter Target="ContentGrid.HorizontalAlignment" Value="Center" />
                                            <Setter Target="TextPanel.Visibility" Value="Collapsed" />
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="IconVisibilityStates">
                                    <VisualState x:Name="IconVisible" />
                                    <VisualState x:Name="IconHidden">
                                        <VisualState.Setters>
                                            <Setter Target="ContentGrid.ColumnSpacing" Value="0" />
                                            <Setter Target="IconPresenter.Visibility" Value="Collapsed" />
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="TextAlignmentStates">
                                    <VisualState x:Name="TextLeftAligned">
                                        <VisualState.Setters>
                                            <Setter Target="TitleText.TextAlignment" Value="Left" />
                                            <Setter Target="SubtitleText.TextAlignment" Value="Left" />
                                        </VisualState.Setters>
                                    </VisualState>
                                    <VisualState x:Name="TextCentered">
                                        <VisualState.Setters>
                                            <Setter Target="TitleText.TextAlignment" Value="Center" />
                                            <Setter Target="SubtitleText.TextAlignment" Value="Center" />
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CompactStates">
                                    <VisualState x:Name="DefaultLayout" />
                                    <VisualState x:Name="Compact">
                                        <VisualState.Setters>
                                            <Setter Target="PART_RootGrid.Padding" Value="0" />
                                            <Setter Target="SubtitleText.Visibility" Value="Collapsed" />
                                            <Setter Target="TitleText.Margin" Value="0,-1,0,0" />
                                        </VisualState.Setters>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>
</ResourceDictionary>