<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:themes="clr-namespace:XamlTheme;assembly=XamlTheme"
                    xmlns:controls="clr-namespace:XamlTheme.Controls;assembly=XamlTheme" 
                    xmlns:markup="clr-namespace:XamlTheme.Markup;assembly=XamlTheme" 
                    xmlns:models="clr-namespace:XamlViewer.Models">

    <ResourceDictionary.MergedDictionaries>
        <markup:SharedResourceDictionary Source="../Converters.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="XamlSelectionItemStyle" 
           BasedOn="{StaticResource {x:Static themes:ResourceKeys.NormalListBoxItemStyleKey}}"
           TargetType="{x:Type ListBoxItem}">
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Height" Value="24"/>
        <Setter Property="FontSize" Value="13"/>
        <Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay}"/>
        <Setter Property="ContextMenu">
            <Setter.Value>
                <ContextMenu Style="{DynamicResource {x:Static themes:ResourceKeys.ContextMenuStyleKey}}">
                    <MenuItem x:Name="SaveItem" Header="Save" InputGestureText="Ctrl+S" 
                              Command="{Binding SaveCommand}"
                              Style="{DynamicResource {x:Static themes:ResourceKeys.MenuItemStyleKey}}">
                        <MenuItem.Icon>
                            <Viewbox Width="12" Height="12">
                                <controls:DrawingIcon>
                                    <controls:DrawingIcon.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="#005198" Geometry="M0,0 L6,0 6,1 3,1 3,5 9,5 9,1 8,1 8,0 10,0 10,1 11,1 11,2 10,2 10,6 2,6 2,1 1,1 1,11 11,11 11,2 12,2 12,12 0,12 z" />
                                            <GeometryDrawing Brush="#FF5400" Geometry="M2,9 L7,9 7,10 2,10 z M2,7 L10,7 10,8 2,8 z M6,0 L8,0 8,4 6,4 z" />
                                        </DrawingGroup>
                                    </controls:DrawingIcon.Drawing>
                                    <controls:DrawingIcon.HDPIDrawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="#005198" Geometry="M1,1 L1,11 11,11 11,2.3 10,1.36 10,6 2,6 2,1 z M0,0 L6,0 6,1 3,1 3,5 9,5 9,1 8,1 8,0 10,0 12,2 12,12 0,12 z" />
                                            <GeometryDrawing Brush="#FF5400" Geometry="M2,9 L7,9 7,10 2,10 z M2,7 L10,7 10,8 2,8 z M6,0 L8,0 8,4 6,4 z" />
                                        </DrawingGroup>
                                    </controls:DrawingIcon.HDPIDrawing>
                                </controls:DrawingIcon>
                            </Viewbox>
                        </MenuItem.Icon> 
                    </MenuItem>
                    <MenuItem Header="Close All"
                              Command="{Binding CloseAllCommand}"
                              Style="{DynamicResource {x:Static themes:ResourceKeys.MenuItemStyleKey}}"> 
                    </MenuItem>
                    <MenuItem Header="Close All But This"
                              Command="{Binding CloseAllButThisCommand}"
                              Style="{DynamicResource {x:Static themes:ResourceKeys.MenuItemStyleKey}}"/>
                    <Separator Margin="0,1"
                               Style="{DynamicResource {x:Static themes:ResourceKeys.HorSeparatorStyleKey}}"/>
                    <MenuItem Header="Copy Full Path" 
                              Command="{Binding CopyOrOpenPathCommand}"
                              Style="{DynamicResource {x:Static themes:ResourceKeys.MenuItemStyleKey}}"/>
                    <MenuItem Header="Open Containing Folder" 
                              Command="{Binding CopyOrOpenPathCommand}"
                              CommandParameter="{StaticResource TrueKey}"
                              Style="{DynamicResource {x:Static themes:ResourceKeys.MenuItemStyleKey}}"/>
                </ContextMenu>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver"  Value="True">
                <Setter Property="Background" Value="#1C97EA"/>
                <Setter Property="Foreground" Value="White"/>
            </Trigger>
            <Trigger Property="IsSelected" Value="true">
                <Setter Property="Background" Value="#007ACC"/>
                <Setter Property="Foreground" Value="White"/>
            </Trigger>
        </Style.Triggers>
    </Style> 
    
    <DataTemplate x:Key="XamlSelectionTemplate">
        <StackPanel Orientation="Horizontal" Margin="6,0,3,0">
            <TextBlock x:Name="TitleTextBlock" VerticalAlignment="Center"
                       Text="{Binding Title}"
                       FontStyle="{Binding Status,Converter={StaticResource xamlTabFontStyleConverter}}">
                <TextBlock.ToolTip>
                    <MultiBinding Converter="{StaticResource xamlTabToolTipMultiConverter}">
                        <Binding Path="FileName"/>
                        <Binding Path="Status"/>
                    </MultiBinding>
                </TextBlock.ToolTip>
            </TextBlock>
            <TextBlock Margin="2,0,0,0"
                       FontStyle="{Binding Status,Converter={StaticResource xamlTabFontStyleConverter}}"
                       Visibility="{Binding Status,Converter={StaticResource flagEnumToVisibilityConverter},ConverterParameter={x:Static models:TabStatus.NoSave}}">
                <Run FontSize="13" Text="*" BaselineAlignment="Superscript"/>
            </TextBlock>
            <Border Background="Transparent" ToolTip="Read Only"> 
                <Path Margin="5,1,0,0" Fill="{Binding Foreground, ElementName=TitleTextBlock}"
                      VerticalAlignment="Center" HorizontalAlignment="Center" 
                      Data="M2,0 H6V1 H2 M1,1 H2V4 H1 M6,1 H7V4 H6 M0,4 H8V9 H0z" 
                      Visibility="{Binding Status,Converter={StaticResource flagEnumToVisibilityConverter},ConverterParameter={x:Static models:TabStatus.Locked}}"/>
            </Border> 
            <Button Width="18" Height="18" Margin="8,0,0,0" ToolTip="Close"
                    Command="{Binding CloseCommand}"
                    Style="{StaticResource {x:Static themes:ResourceKeys.SelectionCloseBtnStyleKey}}">
                <Button.Visibility>
                    <MultiBinding Converter="{StaticResource anyBoolToVisibilityMultiConverter}">
                        <Binding Path="IsMouseOver" RelativeSource="{RelativeSource AncestorType=ListBoxItem}"/>
                        <Binding Path="IsSelected" RelativeSource="{RelativeSource AncestorType=ListBoxItem}"/>
                    </MultiBinding>
                </Button.Visibility>
                <Path Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=Button}}" VerticalAlignment="Center" HorizontalAlignment="Center" 
                      RenderOptions.EdgeMode="Aliased" Data="F1M0,0L2,0 5,3 8,0 10,0 6,4 10,8 8,8 5,5 2,8 0,8 4,4 0,0z" />
            </Button>
        </StackPanel>
    </DataTemplate>

    <Style x:Key="ActiveFilesItemStyle" 
           BasedOn="{StaticResource {x:Static themes:ResourceKeys.NormalListBoxItemStyleKey}}"
           TargetType="{x:Type ListBoxItem}">
        <Setter Property="Padding" Value="0"/>
        <Setter Property="FontSize" Value="13"/>
        <Setter Property="Foreground" Value="#FF141414"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver"  Value="True">
                <Setter Property="Background" Value="#F8F9FA"/>
            </Trigger>
        </Style.Triggers>
    </Style>

    <DataTemplate x:Key="ActiveFilesTemplate">
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="10"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto" SharedSizeGroup="StatusColumn"/>
            </Grid.ColumnDefinitions>
            <controls:DrawingIcon>
                <controls:DrawingIcon.Drawing>
                    <DrawingGroup>
                        <GeometryDrawing Brush="#005198" Geometry="M1,0 H10V1 H11V2 H12V3 H13V4 H14V16 H12V15 H13V5 H9V1 H2V9 H1" />
                        <GeometryDrawing Brush="#FF5400" Geometry="M2,10 V11 H1V12 H0V14 H1V15 H2V16 H3V14 H2V12 H3V10 M7,11 V12 H6V13 H5V14 H4V15 H5V14 H6V13 H7V12 H8V11 M9,10 V12 H10V14 H9V16 H10V15 H11V14 H12V12 H11V11 H10V10" />
                    </DrawingGroup>
                </controls:DrawingIcon.Drawing>
                <controls:DrawingIcon.HDPIDrawing>
                    <DrawingGroup>
                        <GeometryDrawing Brush="#005198" Geometry="M1,0 H10 L14,4 V16 H12V15 H13V5 H9V1 H2V9 H1" />
                        <GeometryDrawing Brush="#FF5400" Geometry="M2,10 L0,13 2,16 2.7,15.5 1,13 2.7,10.5z M7,10.5 L4,15.5 H5 L8,10.5z M9.3,10.5 L10,10 12,13 10,16 9.3,15.5 11,13z" />
                    </DrawingGroup>
                </controls:DrawingIcon.HDPIDrawing>
            </controls:DrawingIcon>
            <TextBlock Grid.Column="2" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"
                       Text="{Binding Title}"
                       FontStyle="{Binding Status,Converter={StaticResource xamlTabFontStyleConverter}}">
                <TextBlock.ToolTip>
                    <MultiBinding Converter="{StaticResource xamlTabToolTipMultiConverter}">
                        <Binding Path="FileName"/>
                        <Binding Path="Status"/>
                    </MultiBinding>
                </TextBlock.ToolTip>
            </TextBlock>

            <Border Grid.Column="3" Margin="5,0,0,0" Background="Transparent" ToolTip="Read Only"
                    Visibility="{Binding Status,Converter={StaticResource flagEnumToVisibilityConverter},ConverterParameter={x:Static models:TabStatus.Locked}}">
                <Path Fill="#005198" VerticalAlignment="Center" HorizontalAlignment="Center"
                      Data="M2,0 H6V1 H2 M1,1 H2V4 H1 M6,1 H7V4 H6 M0,4 H8V9 H0z"/>
            </Border>
            <Border Grid.Column="3" Margin="5,0,0,0" Background="Transparent" ToolTip="Unsaved"
                    Visibility="{Binding Status,Converter={StaticResource flagEnumToVisibilityConverter},ConverterParameter={x:Static models:TabStatus.NoSave}}">
                <Path Fill="#005198" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill" Width="6" Height="6"
                      Data="M3.4101563,5.4331779 L4.8251953,5.4331779 L4.5791016,8.3072014 L7.0576172,7.3579826 L7.4882813,8.6236076 L4.8867188,9.1333733 L6.7060547,11.40974 L5.5810547,12.183178 L4.1220703,9.6695061 L2.6455078,12.183178 L1.5205078,11.40974 L3.3310547,9.1333733 L0.71191406,8.6236076 L1.1689453,7.3579826 L3.6474609,8.3072014 z"/>
            </Border>
        </Grid>
    </DataTemplate>

</ResourceDictionary>