<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:hsc="clr-namespace:HavenSoft.HexManiac.WPF.Controls"
                    xmlns:hsv="clr-namespace:HavenSoft.HexManiac.WPF.Resources"
                    xmlns:tools="clr-namespace:HavenSoft.HexManiac.Core.ViewModels.Tools;assembly=HexManiac.Core"
                    xmlns:images="clr-namespace:HavenSoft.HexManiac.Core.ViewModels.Images;assembly=HexManiac.Core">
   <hsc:BooleanToVisibilityConverter x:Key="BoolToVisibility" />
   <hsc:PaletteColorConverter x:Key="PaletteColorConverter"/>
   <hsc:TilePaletteHueConverter x:Key="TilePaletteHueConverter"/>
   <hsc:EqualityToBooleanConverter x:Key="EqualityCheck"/>

   <DrawingBrush x:Key="HexBrush" TileMode="FlipX" ViewportUnits="Absolute" Viewport="0,0,33,38">
      <DrawingBrush.Drawing>
         <GeometryDrawing Geometry="{hsv:Icon LargeHexGrid}">
            <GeometryDrawing.Pen>
               <Pen Brush="{DynamicResource Backlight}" Thickness="1"/>
            </GeometryDrawing.Pen>
         </GeometryDrawing>
      </DrawingBrush.Drawing>
   </DrawingBrush>

   <!-- Icons accessible using IconExtension -->
   <hsv:Icons x:Key="Icons"/>

   <!-- Button Style -->
   <Style TargetType="Button">
      <Setter Property="Padding" Value="3"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Backlight}"/>
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="Button">
               <Border Name="Border"
                     Padding="{TemplateBinding Padding}"
                     BorderThickness="{TemplateBinding BorderThickness}"
                     BorderBrush="{TemplateBinding BorderBrush}"
                     Background="{TemplateBinding Background}">
                  <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="ToggleButton">
      <Setter Property="BorderBrush" Value="{DynamicResource Backlight}"/>
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="ToggleButton">
               <Border Name="Border"
                     Padding="{TemplateBinding Padding}"
                     BorderThickness="{TemplateBinding BorderThickness}"
                     BorderBrush="{TemplateBinding BorderBrush}"
                     Background="{TemplateBinding Background}">
                  <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsChecked" Value="True">
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Secondary}"/>
                  </Trigger>
                  <Trigger Property="IsChecked" Value="False">
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
                  <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="RepeatButton">
      <Setter Property="Padding" Value="3"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Backlight}"/>
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="RepeatButton">
               <Border Name="Border"
                     Padding="{TemplateBinding Padding}"
                     BorderThickness="{TemplateBinding BorderThickness}"
                     BorderBrush="{TemplateBinding BorderBrush}"
                     Background="{TemplateBinding Background}">
                  <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger SourceName="Border" Property="IsMouseOver" Value="True">
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="hsc:AngleButton">
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Secondary}"/>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Padding" Value="3"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="hsc:AngleButton">
               <DockPanel Name="Container" Margin="{TemplateBinding Margin}">
                  <Path Name="LeftEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Left"
                           Width="6" StrokeThickness="1" Margin="0,0,-1,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="1,0">
                                    <LineSegment Point="{Binding LeftTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <Path Name="RightEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Right"
                           Width="6" StrokeThickness="1" Margin="-1,0,0,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="-1,0">
                                    <LineSegment Point="{Binding RightTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="-1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <Border HorizontalAlignment="Stretch" Name="ButtonBorder" BorderThickness="0,1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                     <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"/>
                  </Border>
               </DockPanel>
               <ControlTemplate.Triggers>
                  <Trigger Property="Direction" Value="None">
                     <Setter TargetName="LeftEdge" Property="Width" Value="2"/>
                     <Setter TargetName="RightEdge" Property="Width" Value="2"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Left">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Right">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Out">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="In">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="True">
                     <Setter TargetName="ButtonBorder" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="LeftEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="RightEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                     <Setter Property="Opacity" Value=".5"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Expander Style -->
   <Style TargetType="Expander">
      <Setter Property="BorderBrush" Value="{DynamicResource Secondary}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="Expander">
               <DockPanel Background="Transparent">
                  <ToggleButton Name="HeaderSite" DockPanel.Dock="Left" BorderThickness="0" Background="Transparent" Width="NaN" IsTabStop="False"
                        IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
                     <StackPanel Orientation="Horizontal">
                        <Grid Width="16" Height="16">
                           <Ellipse Name="circle" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Fill="{TemplateBinding Background}"/>
                           <Path Name="arrow" RenderTransformOrigin=".5,.5" Data="{hsv:Icon RightArrow}" Fill="{TemplateBinding Foreground}" Stretch="Fill" Margin="3"/>
                        </Grid>
                        <ContentPresenter Name="HeaderContent" ContentSource="Header" Margin="3,0"/>
                     </StackPanel>
                  </ToggleButton>
                  <ContentPresenter Name="ExpanderSite" Visibility="{TemplateBinding IsExpanded, Converter={StaticResource BoolToVisibility}}"/>
               </DockPanel>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsExpanded" Value="True">
                     <Setter TargetName="arrow" Property="RenderTransform" Value="-1,0,0,-1,0,0"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="True">
                     <Setter TargetName="circle" Property="Stroke" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="False">
                     <Setter TargetName="arrow" Property="Fill" Value="Transparent"/>
                  </Trigger>
                  <Trigger Property="Tag" Value="Magic">
                     <Setter TargetName="circle" Property="Stroke" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="arrow" Property="Fill" Value="{DynamicResource Primary}"/>
                  </Trigger>
                  <Trigger Property="Header" Value="{x:Null}">
                     <Setter TargetName="HeaderContent" Property="Margin" Value="0"/>
                  </Trigger>
                  <Trigger Property="ExpandDirection" Value="Down">
                     <Setter TargetName="HeaderSite" Property="DockPanel.Dock" Value="Top"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- ToolTip Style -->
   <Style TargetType="ToolTip">
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Accent}"/>
      <Setter Property="BorderThickness" Value="1"/>
   </Style>

   <!-- Scrollbar style. Based on normal style, but with custom colors. -->
   <Style x:Key="FocusVisual">
      <Setter Property="Control.Template">
         <Setter.Value>
            <ControlTemplate>
               <Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   <Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
      <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Padding" Value="1"/>
      <Setter Property="Focusable" Value="false"/>
      <Setter Property="IsTabStop" Value="false"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
               <Border x:Name="border" BorderBrush="{DynamicResource Backlight}" BorderThickness="1" Background="{DynamicResource Background}" SnapsToDevicePixels="true">
                  <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsMouseOver" Value="true">
                     <Setter Property="Background" TargetName="border" Value="{DynamicResource Background}"/>
                     <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource Backlight}"/>
                  </Trigger>
                  <Trigger Property="IsPressed" Value="true">
                     <Setter Property="Background" TargetName="border" Value="{DynamicResource Background}"/>
                     <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource Backlight}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter Property="Opacity" TargetName="contentPresenter" Value="0.56"/>
                     <Setter Property="Background" TargetName="border" Value="{DynamicResource Background}"/>
                     <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource Backlight}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   <Style x:Key="RepeatButtonTransparent" TargetType="{x:Type RepeatButton}">
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="Focusable" Value="false"/>
      <Setter Property="IsTabStop" Value="false"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
               <Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}"/>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   <Style x:Key="ScrollBarThumbVertical" TargetType="{x:Type Thumb}">
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="IsTabStop" Value="false"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type Thumb}">
               <Rectangle x:Name="rectangle" Fill="{DynamicResource Secondary}" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}"/>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsMouseOver" Value="true">
                     <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource Secondary}"/>
                  </Trigger>
                  <Trigger Property="IsDragging" Value="true">
                     <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   <Style x:Key="ScrollBarThumbHorizontal" TargetType="{x:Type Thumb}">
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="IsTabStop" Value="false"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type Thumb}">
               <Rectangle x:Name="rectangle" Fill="{DynamicResource Secondary}" Height="{TemplateBinding Height}" SnapsToDevicePixels="True" Width="{TemplateBinding Width}"/>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsMouseOver" Value="true">
                     <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource Secondary}"/>
                  </Trigger>
                  <Trigger Property="IsDragging" Value="true">
                     <Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>
   <Style TargetType="{x:Type ScrollBar}">
      <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
      <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
      <Setter Property="Background" Value="{DynamicResource Background}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Backlight}"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="BorderThickness" Value="1,0"/>
      <Setter Property="Width" Value="16"/>
      <Setter Property="MinWidth" Value="16"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type ScrollBar}">
               <Grid x:Name="Bg" SnapsToDevicePixels="true">
                  <Grid.RowDefinitions>
                     <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                     <RowDefinition Height="0.00001*"/>
                     <RowDefinition MaxHeight="{DynamicResource {x:Static SystemParameters.VerticalScrollBarButtonHeightKey}}"/>
                  </Grid.RowDefinitions>
                  <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Row="1"/>
                  <RepeatButton x:Name="PART_LineUpButton" Command="{x:Static ScrollBar.LineUpCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}">
                     <Path x:Name="ArrowTop" Data="M 0,4 C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4 z" Fill="{DynamicResource Primary}" Margin="3,4,3,3" Stretch="Uniform"/>
                  </RepeatButton>
                  <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="1">
                     <Track.DecreaseRepeatButton>
                        <RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource RepeatButtonTransparent}"/>
                     </Track.DecreaseRepeatButton>
                     <Track.IncreaseRepeatButton>
                        <RepeatButton Command="{x:Static ScrollBar.PageDownCommand}" Style="{StaticResource RepeatButtonTransparent}"/>
                     </Track.IncreaseRepeatButton>
                     <Track.Thumb>
                        <Thumb Style="{StaticResource ScrollBarThumbVertical}"/>
                     </Track.Thumb>
                  </Track>
                  <RepeatButton x:Name="PART_LineDownButton" Command="{x:Static ScrollBar.LineDownCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Grid.Row="2" Style="{StaticResource ScrollBarButton}">
                     <Path x:Name="ArrowBottom" Data="M 0,2.5 C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5 z" Fill="{DynamicResource Primary}" Margin="3,4,3,3" Stretch="Uniform"/>
                  </RepeatButton>
               </Grid>
               <ControlTemplate.Triggers>
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineDownButton}" Value="true"/>
                        <Condition Binding="{Binding IsPressed, ElementName=PART_LineDownButton}" Value="true"/>
                     </MultiDataTrigger.Conditions>
                     <Setter Property="Fill" TargetName="ArrowBottom" Value="{DynamicResource Primary}"/>
                  </MultiDataTrigger>
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineUpButton}" Value="true"/>
                        <Condition Binding="{Binding IsPressed, ElementName=PART_LineUpButton}" Value="true"/>
                     </MultiDataTrigger.Conditions>
                     <Setter Property="Fill" TargetName="ArrowTop" Value="{DynamicResource Primary}"/>
                  </MultiDataTrigger>
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineDownButton}" Value="true"/>
                        <Condition Binding="{Binding IsPressed, ElementName=PART_LineDownButton}" Value="false"/>
                     </MultiDataTrigger.Conditions>
                     <Setter Property="Fill" TargetName="ArrowBottom" Value="{DynamicResource Primary}"/>
                  </MultiDataTrigger>
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineUpButton}" Value="true"/>
                        <Condition Binding="{Binding IsPressed, ElementName=PART_LineUpButton}" Value="false"/>
                     </MultiDataTrigger.Conditions>
                     <Setter Property="Fill" TargetName="ArrowTop" Value="{DynamicResource Primary}"/>
                  </MultiDataTrigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter Property="Fill" TargetName="ArrowTop" Value="{DynamicResource Primary}"/>
                     <Setter Property="Fill" TargetName="ArrowBottom" Value="{DynamicResource Primary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
      <Style.Triggers>
         <Trigger Property="Orientation" Value="Horizontal">
            <Setter Property="Width" Value="Auto"/>
            <Setter Property="MinWidth" Value="0"/>
            <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
            <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
            <Setter Property="BorderThickness" Value="0,1"/>
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type ScrollBar}">
                     <Grid x:Name="Bg" SnapsToDevicePixels="true">
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                           <ColumnDefinition Width="0.00001*"/>
                           <ColumnDefinition MaxWidth="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}}"/>
                        </Grid.ColumnDefinitions>
                        <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1"/>
                        <RepeatButton x:Name="PART_LineLeftButton" Command="{x:Static ScrollBar.LineLeftCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}">
                           <Path x:Name="ArrowLeft" Data="M 3.18,7 C3.18,7 5,7 5,7 5,7 1.81,3.5 1.81,3.5 1.81,3.5 5,0 5,0 5,0 3.18,0 3.18,0 3.18,0 0,3.5 0,3.5 0,3.5 3.18,7 3.18,7 z" Fill="{DynamicResource Primary}" Margin="3" Stretch="Uniform"/>
                        </RepeatButton>
                        <Track x:Name="PART_Track" Grid.Column="1" IsEnabled="{TemplateBinding IsMouseOver}">
                           <Track.DecreaseRepeatButton>
                              <RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource RepeatButtonTransparent}"/>
                           </Track.DecreaseRepeatButton>
                           <Track.IncreaseRepeatButton>
                              <RepeatButton Command="{x:Static ScrollBar.PageRightCommand}" Style="{StaticResource RepeatButtonTransparent}"/>
                           </Track.IncreaseRepeatButton>
                           <Track.Thumb>
                              <Thumb Style="{StaticResource ScrollBarThumbHorizontal}"/>
                           </Track.Thumb>
                        </Track>
                        <RepeatButton x:Name="PART_LineRightButton" Grid.Column="2" Command="{x:Static ScrollBar.LineRightCommand}" IsEnabled="{TemplateBinding IsMouseOver}" Style="{StaticResource ScrollBarButton}">
                           <Path x:Name="ArrowRight" Data="M 1.81,7 C1.81,7 0,7 0,7 0,7 3.18,3.5 3.18,3.5 3.18,3.5 0,0 0,0 0,0 1.81,0 1.81,0 1.81,0 5,3.5 5,3.5 5,3.5 1.81,7 1.81,7 z" Fill="{DynamicResource Primary}" Margin="3" Stretch="Uniform"/>
                        </RepeatButton>
                     </Grid>
                     <ControlTemplate.Triggers>
                        <MultiDataTrigger>
                           <MultiDataTrigger.Conditions>
                              <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineRightButton}" Value="true"/>
                              <Condition Binding="{Binding IsPressed, ElementName=PART_LineRightButton}" Value="true"/>
                           </MultiDataTrigger.Conditions>
                           <Setter Property="Fill" TargetName="ArrowRight" Value="{DynamicResource Primary}"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                           <MultiDataTrigger.Conditions>
                              <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineLeftButton}" Value="true"/>
                              <Condition Binding="{Binding IsPressed, ElementName=PART_LineLeftButton}" Value="true"/>
                           </MultiDataTrigger.Conditions>
                           <Setter Property="Fill" TargetName="ArrowLeft" Value="{DynamicResource Primary}"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                           <MultiDataTrigger.Conditions>
                              <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineRightButton}" Value="true"/>
                              <Condition Binding="{Binding IsPressed, ElementName=PART_LineRightButton}" Value="false"/>
                           </MultiDataTrigger.Conditions>
                           <Setter Property="Fill" TargetName="ArrowRight" Value="{DynamicResource Primary}"/>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                           <MultiDataTrigger.Conditions>
                              <Condition Binding="{Binding IsMouseOver, ElementName=PART_LineLeftButton}" Value="true"/>
                              <Condition Binding="{Binding IsPressed, ElementName=PART_LineLeftButton}" Value="false"/>
                           </MultiDataTrigger.Conditions>
                           <Setter Property="Fill" TargetName="ArrowLeft" Value="{DynamicResource Primary}"/>
                        </MultiDataTrigger>
                        <Trigger Property="IsEnabled" Value="false">
                           <Setter Property="Fill" TargetName="ArrowLeft" Value="{DynamicResource Primary}"/>
                           <Setter Property="Fill" TargetName="ArrowRight" Value="{DynamicResource Primary}"/>
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Trigger>
      </Style.Triggers>
   </Style>

   <!-- Menu style -->
   <Style TargetType="{x:Type Menu}">
      <Setter Property="Background" Value="{DynamicResource Background}"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
   </Style>

   <Style TargetType="{x:Type MenuItem}">
      <Style.Triggers>
         <Trigger Property="Role" Value="TopLevelHeader">
            <Setter Property="Background" Value="{DynamicResource Background}"/>
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type MenuItem}">
                     <Grid Name="ItemBorder" Background="{TemplateBinding Background}">
                        <ContentPresenter Margin="10,2" ContentSource="Header" RecognizesAccessKey="True" TextBlock.Foreground="{DynamicResource Primary}"/>
                        <Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" SnapsToDevicePixels="True">
                           <Border x:Name="SubmenuBorder" BorderThickness="1" Background="{DynamicResource Background}" BorderBrush="{DynamicResource Accent}">
                              <StackPanel Name="ItemsPresenter" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                           </Border>
                        </Popup>
                     </Grid>
                     <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                           <Setter TargetName="ItemBorder" Property="Background" Value="{DynamicResource Backlight}" />
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Trigger>
         <Trigger Property="Role" Value="SubmenuHeader">
            <Setter Property="Background" Value="{DynamicResource Background}"/>
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type MenuItem}">
                     <Grid Name="ItemBorder" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="30"/>
                           <ColumnDefinition Width="*"/>
                           <ColumnDefinition Width="12"/>
                        </Grid.ColumnDefinitions>
                        <ContentPresenter Grid.Column="0" Margin="5,5,0,5" ContentSource="Icon" />
                        <Border x:Name="Border" Width="13" Height="13"
                              Background="{TemplateBinding Background}" BorderThickness="1" HorizontalAlignment="Center"
                              VerticalAlignment="Center" BorderBrush="{DynamicResource Secondary}"
                              Visibility="{TemplateBinding IsCheckable, Converter={StaticResource BoolToVisibility}}">
                           <Path Width="7" Height="7" StrokeThickness="2" SnapsToDevicePixels="False" 
                                 x:Name="CheckMark" Stroke="{DynamicResource Accent}" Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                        </Border>
                        <ContentPresenter Grid.Column="1" Name="MainContent" Margin="10,5" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True" TextBlock.Foreground="{DynamicResource Primary}" />
                        <Path Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="{DynamicResource Secondary}" Data="M0,0 L0,2 1,1 Z" Stretch="Uniform" Width="10" Height="10"/>
                        <Popup x:Name="Popup"
                                 Placement="Right"
                                 HorizontalOffset="-4"
                                 IsOpen="{TemplateBinding IsSubmenuOpen}"
                                 AllowsTransparency="True"
                                 Focusable="False"
                                 PopupAnimation="Fade">
                           <Border x:Name="SubmenuBorder"
                                    SnapsToDevicePixels="True"
                                    Background="{DynamicResource Background}"
                                    BorderBrush="{DynamicResource Accent}"
                                    BorderThickness="1">
                              <ScrollViewer CanContentScroll="True" MaxHeight="200" VerticalScrollBarVisibility="Auto">
                                 <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                              </ScrollViewer>
                           </Border>
                        </Popup>
                     </Grid>
                     <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                           <Setter TargetName="ItemBorder" Property="Background" Value="{DynamicResource Backlight}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                           <Setter TargetName="MainContent" Property="TextBlock.Foreground" Value="{DynamicResource Secondary}" />
                           <Setter TargetName="MainContent" Property="TextBlock.FontStyle" Value="Italic" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="False">
                           <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Trigger>
         <Trigger Property="Role" Value="SubmenuItem">
            <Setter Property="Background" Value="{DynamicResource Background}"/>
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type MenuItem}">
                     <Grid Name="ItemBorder" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="30"/>
                           <ColumnDefinition Width="*"/>
                           <ColumnDefinition Width="100"/>
                        </Grid.ColumnDefinitions>
                        <ContentPresenter Grid.Column="0" Margin="5,5,0,5" ContentSource="Icon" />
                        <Border x:Name="Border" Width="13" Height="13"
                              Background="{TemplateBinding Background}" BorderThickness="1" HorizontalAlignment="Center"
                              VerticalAlignment="Center" BorderBrush="{DynamicResource Secondary}"
                              Visibility="{TemplateBinding IsCheckable, Converter={StaticResource BoolToVisibility}}">
                           <Path Width="7" Height="7" StrokeThickness="2" SnapsToDevicePixels="False" 
                                 x:Name="CheckMark" Stroke="{DynamicResource Accent}" Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                        </Border>

                        <ContentPresenter Grid.Column="1" Name="MainContent" Margin="10,5" VerticalAlignment="Center" ContentSource="Header" RecognizesAccessKey="True" TextBlock.Foreground="{DynamicResource Primary}" />
                        <TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{TemplateBinding InputGestureText}" Foreground="{DynamicResource Secondary}" />
                     </Grid>
                     <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                           <Setter TargetName="ItemBorder" Property="Background" Value="{DynamicResource Backlight}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                           <Setter TargetName="MainContent" Property="TextBlock.Foreground" Value="{DynamicResource Secondary}" />
                           <Setter TargetName="MainContent" Property="TextBlock.FontStyle" Value="Italic" />
                        </Trigger>
                        <Trigger Property="IsChecked" Value="False">
                           <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Trigger>
      </Style.Triggers>
   </Style>

   <Style TargetType="{x:Type ContextMenu}">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="ContextMenu">
               <Border Background="{DynamicResource Background}" BorderBrush="{DynamicResource Accent}" BorderThickness="1">
                  <ItemsPresenter/>
               </Border>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Separator Style has to specify that it's the style to use for MenuItems. This has something to do with the Menu searching for this key. -->
   <Style TargetType="{x:Type Separator}" x:Key="{x:Static MenuItem.SeparatorStyleKey}">
      <Setter Property="Background" Value="{DynamicResource Secondary}"/>
      <Setter Property="Margin" Value="0,2"/>
      <Setter Property="Focusable" Value="false"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Secondary}"/>
   </Style>

   <!-- TextBlock Style-->
   <Style TargetType="TextBlock">
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Style.Triggers>
         <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
            <Setter Property="FontStyle" Value="Italic"/>
         </Trigger>
      </Style.Triggers>
   </Style>

   <LinearGradientBrush EndPoint="0,1" x:Key="TopToBottomBrush">
      <GradientStop Offset="0" Color="{DynamicResource BackgroundColor}"/>
      <GradientStop Offset=".5" Color="{DynamicResource BackgroundColor}"/>
      <GradientStop Offset=".5" Color="{DynamicResource SecondaryColor}"/>
      <GradientStop Offset="1" Color="{DynamicResource SecondaryColor}"/>
   </LinearGradientBrush>

   <!-- TextBox Style -->
   <Style TargetType="TextBox">
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="SelectionBrush" Value="{DynamicResource Accent}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource TopToBottomBrush}"/>
      <Setter Property="BorderThickness" Value="1,1,1,1"/>
      <Setter Property="MinHeight" Value="18"/>
      <Setter Property="SnapsToDevicePixels" Value="True"/>
      <Setter Property="ContextMenu">
         <Setter.Value>
            <ContextMenu>
               <MenuItem Command="ApplicationCommands.Cut" />
               <MenuItem Command="ApplicationCommands.Copy" />
               <MenuItem Command="ApplicationCommands.Paste" />
               <Separator />
               <MenuItem Command="ApplicationCommands.SelectAll" />
            </ContextMenu>
         </Setter.Value>
      </Setter>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="TextBox">
               <Border Name="Border" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                  <ScrollViewer Foreground="{TemplateBinding Foreground}" x:Name="PART_ContentHost" />
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsKeyboardFocused" Value="True">
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="True">
                     <Setter Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                     <Setter Property="Opacity" Value=".5"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- TabContol Styles -->
   <Style TargetType="{x:Type TabControl}">
      <Setter Property="Padding" Value="2"/>
      <Setter Property="HorizontalContentAlignment" Value="Center"/>
      <Setter Property="VerticalContentAlignment" Value="Center"/>
      <Setter Property="Background" Value="{DynamicResource Background}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Background}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
   </Style>

   <Style TargetType="{x:Type TabItem}">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type TabItem}">
               <Border Name="OuterBorder" BorderThickness="0,0,1,0" BorderBrush="{DynamicResource Background}">
                  <!-- used for the 1-pixel spacing between tabs -->
                  <Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="{DynamicResource Backlight}" Background="{DynamicResource Backlight}">
                     <!-- used for selection -->
                     <Border Name="InnerBorder" BorderThickness="1,1,1,0" Padding="5,3" BorderBrush="{DynamicResource Backlight}">
                        <!-- used for hover-over before selection -->
                        <ContentPresenter ContentSource="Header" />
                     </Border>
                  </Border>
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsSelected" Value="True">
                     <Setter TargetName="Border" Property="Background" Value="{DynamicResource Background}"/>
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="OuterBorder" Property="BorderBrush" Value="{DynamicResource Background}"/>
                     <Setter TargetName="Border" Property="Panel.ZIndex" Value="10"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="True">
                     <Setter TargetName="InnerBorder" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Combobox Style -->

   <ControlTemplate x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
      <Border x:Name="Border"
               Grid.ColumnSpan="2"
               Background="{DynamicResource Backlight}"
               BorderBrush="{DynamicResource Accent}"
               BorderThickness="1">
         <Path x:Name="Arrow" Width="20"
               Grid.Column="1"
               Fill="{DynamicResource Secondary}"
               VerticalAlignment="Center"
               HorizontalAlignment="Right"
               Data="M0,0 L0,2 L4,6 L8,2 L8,0 L4,4 z" />
      </Border>
   </ControlTemplate>

   <ControlTemplate x:Key="ComboBoxTextBox" TargetType="{x:Type TextBox}">
      <ScrollViewer x:Name="PART_ContentHost" Focusable="False" Background="{TemplateBinding Background}" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
   </ControlTemplate>

   <Style TargetType="{x:Type ComboBox}">
      <Setter Property="SnapsToDevicePixels" Value="true"/>
      <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
      <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
      <Setter Property="MinHeight" Value="20"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
               <Grid>
                  <ToggleButton
                            Name="ToggleButton"
                            Template="{StaticResource ComboBoxToggleButton}"
                            Grid.Column="2"
                            Focusable="false"
                            IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                            ClickMode="Press">
                  </ToggleButton>
                  <ContentPresenter Name="ContentSite" IsHitTestVisible="False"  Content="{TemplateBinding SelectionBoxItem}"
                            ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                            ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                            Margin="3,3,23,3"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Left" />
                  <TextBox x:Name="PART_EditableTextBox"
                            Style="{x:Null}"
                            Template="{StaticResource ComboBoxTextBox}"
                            HorizontalAlignment="Left"
                            VerticalAlignment="Center"
                            Margin="3,3,23,3"
                            Focusable="True"
                            Background="{DynamicResource Backlight}"
                            Foreground="{DynamicResource Primary}"
                            Visibility="Hidden"
                            IsReadOnly="{TemplateBinding IsReadOnly}"/>
                  <Popup
                            Name="Popup"
                            Placement="Bottom"
                            IsOpen="{TemplateBinding IsDropDownOpen}"
                            AllowsTransparency="True"
                            Focusable="False"
                            PopupAnimation="Slide">

                     <Grid Name="DropDown"
                              SnapsToDevicePixels="True"
                              MinWidth="{TemplateBinding ActualWidth}"
                              MaxHeight="{TemplateBinding MaxDropDownHeight}">
                        <Border
                                x:Name="DropDownBorder"
                                Background="{DynamicResource Background}"
                                BorderThickness="1"
                                BorderBrush="{DynamicResource Secondary}"/>
                        <ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
                           <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                     </Grid>
                  </Popup>
               </Grid>
               <ControlTemplate.Triggers>
                  <Trigger Property="HasItems" Value="false">
                     <Setter TargetName="DropDownBorder" Property="MinHeight" Value="95"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
                  <Trigger Property="IsGrouping" Value="true">
                     <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                  </Trigger>
                  <Trigger SourceName="Popup" Property="Popup.AllowsTransparency" Value="true">
                     <Setter TargetName="DropDownBorder" Property="CornerRadius" Value="0"/>
                     <Setter TargetName="DropDownBorder" Property="Margin" Value="0,2,0,0"/>
                  </Trigger>
                  <Trigger Property="IsEditable"  Value="true">
                     <Setter Property="IsTabStop" Value="false"/>
                     <Setter TargetName="PART_EditableTextBox" Property="Visibility" Value="Visible"/>
                     <Setter TargetName="ContentSite" Property="Visibility" Value="Hidden"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- SimpleStyles: ComboBoxItem -->
   <Style x:Key="{x:Type ComboBoxItem}" TargetType="{x:Type ComboBoxItem}">
      <Setter Property="SnapsToDevicePixels" Value="true"/>
      <Setter Property="Foreground" Value="White"/>
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBoxItem}">
               <Border Name="Border"
                              Padding="2"
                              SnapsToDevicePixels="true">
                  <ContentPresenter />
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsHighlighted" Value="true">
                     <Setter TargetName="Border" Property="Background" Value="{DynamicResource Backlight}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- ListBox Style -->
   <Style TargetType="ListBox">
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="BorderThickness" Value="0"/>
   </Style>
   <Style TargetType="ListBoxItem">
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type ListBoxItem}">
               <Border Padding="5,3" BorderThickness="1" Background="Transparent">
                  <Border.Style>
                     <Style TargetType="Border">
                        <Style.Triggers>
                           <Trigger Property="IsMouseOver" Value="True">
                              <Setter Property="BorderBrush" Value="{DynamicResource Accent}"/>
                           </Trigger>
                        </Style.Triggers>
                     </Style>
                  </Border.Style>
                  <ContentPresenter/>
               </Border>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Slider Style -->
   <ControlTemplate x:Key="SliderThumbHorizontalDefault" TargetType="{x:Type Thumb}">
      <Grid HorizontalAlignment="Center" UseLayoutRounding="True" VerticalAlignment="Center">
         <Path x:Name="grip" Data="M 0,0 C0,0 11,0 11,0 11,0 11,18 11,18 11,18 0,18 0,18 0,18 0,0 0,0 z" Fill="{TemplateBinding Background}" Stretch="Fill" SnapsToDevicePixels="True" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1" UseLayoutRounding="True" VerticalAlignment="Center"/>
      </Grid>
      <ControlTemplate.Triggers>
         <Trigger Property="IsMouseOver" Value="true">
            <Setter Property="Stroke" TargetName="grip" Value="{DynamicResource Accent}"/>
         </Trigger>
         <Trigger Property="IsDragging" Value="true">
            <Setter Property="Fill" TargetName="grip" Value="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Thumb}}}"/>
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <Style TargetType="{x:Type Slider}">
      <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Secondary}"/>
      <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type Slider}">
               <Grid>
                  <Border x:Name="TrackBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" Height="4.0" Margin="5,0" VerticalAlignment="Center"/>
                  <Track x:Name="PART_Track">
                     <Track.DecreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.DecreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                     </Track.DecreaseRepeatButton>
                     <Track.IncreaseRepeatButton>
                        <RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource RepeatButtonTransparent}"/>
                     </Track.IncreaseRepeatButton>
                     <Track.Thumb>
                        <Thumb x:Name="Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Template="{StaticResource SliderThumbHorizontalDefault}" VerticalAlignment="Center" Width="11"/>
                     </Track.Thumb>
                  </Track>
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Checkbox Style -->
   <Style TargetType="{x:Type CheckBox}">
      <Setter Property="SnapsToDevicePixels" Value="true"/>
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type CheckBox}">
               <BulletDecorator Background="Transparent" Width="{TemplateBinding Width}" Height="15">
                  <BulletDecorator.Bullet>
                     <Border x:Name="Border" 
                           Width="13" 
                           Height="13" 
                           Margin="1"
                           CornerRadius="0" 
                           Background="{DynamicResource Background}"
                           BorderThickness="1"
                           VerticalAlignment="Center"
                           BorderBrush="{DynamicResource Secondary}">
                        <Path 
                              Width="7" Height="7" 
                              x:Name="CheckMark"
                              SnapsToDevicePixels="False" 
                              Stroke="{DynamicResource Accent}"
                              StrokeThickness="2"
                              Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                     </Border>
                  </BulletDecorator.Bullet>
                  <Viewbox Margin="3,0,0,0" HorizontalAlignment="Left">
                     <ContentPresenter RecognizesAccessKey="True"/>
                  </Viewbox>
               </BulletDecorator>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsChecked" Value="false">
                     <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                  </Trigger>
                  <Trigger Property="IsChecked" Value="{x:Null}">
                     <Setter TargetName="CheckMark" Property="Data" Value="M 0 7 L 7 0" />
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="true">
                     <Setter TargetName="Border" Property="Background" Value="{DynamicResource Backlight}" />
                  </Trigger>
                  <Trigger Property="IsPressed" Value="true">
                     <Setter TargetName="Border" Property="Background" Value="{DynamicResource Backlight}" />
                     <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Primary}" />
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter TargetName="Border" Property="Opacity" Value=".8" />
                     <Setter TargetName="Border" Property="Opacity" Value=".8" />
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- RadioButton Style -->
   <Style TargetType="{x:Type RadioButton}">
      <Setter Property="SnapsToDevicePixels" Value="true"/>
      <Setter Property="OverridesDefaultStyle" Value="true"/>
      <Setter Property="Foreground" Value="{DynamicResource Accent}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type RadioButton}">
               <BulletDecorator Background="Transparent" Width="{TemplateBinding Width}" Height="15">
                  <BulletDecorator.Bullet>
                     <Grid Width="13" Height="13" Margin="1" VerticalAlignment="Center" SnapsToDevicePixels="True">
                        <Path x:Name="Border" Fill="{DynamicResource Background}" Stroke="{DynamicResource Secondary}" StrokeThickness="1">
                           <Path.Data>
                              M3,1.5 l 6,0 3,5 -3,5 -6,0 -3,-5 Z
                           </Path.Data>
                        </Path>
                        <Path x:Name="CheckMark" Fill="{TemplateBinding Foreground}">
                           <Path.Data>
                              M4,3.5 l 4,0 2,3 -2,3 -4,0 -2,-3 Z
                           </Path.Data>
                        </Path>
                     </Grid>
                  </BulletDecorator.Bullet>
                  <Viewbox Margin="3,0,0,0" HorizontalAlignment="Left">
                     <ContentPresenter RecognizesAccessKey="True"/>
                  </Viewbox>
               </BulletDecorator>
               <ControlTemplate.Triggers>
                  <Trigger Property="IsChecked" Value="false">
                     <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="true">
                     <Setter TargetName="Border" Property="Fill" Value="{DynamicResource Backlight}" />
                  </Trigger>
                  <Trigger Property="IsPressed" Value="true">
                     <Setter TargetName="Border" Property="Fill" Value="{DynamicResource Backlight}" />
                     <Setter TargetName="Border" Property="Stroke" Value="{DynamicResource Primary}" />
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="false">
                     <Setter TargetName="Border" Property="Opacity" Value=".8" />
                     <Setter TargetName="Border" Property="Opacity" Value=".8" />
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Angle Border Style -->
   <Style TargetType="hsc:AngleBorder">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="BorderBrush" Value="{DynamicResource Backlight}"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="hsc:AngleBorder">
               <DockPanel Name="Container">
                  <Path Name="LeftEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Left"
                           Width="6" Height="18" StrokeThickness="1" Margin="0,0,-1,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="1,0">
                                    <LineSegment Point="{Binding LeftTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <Path Name="RightEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Right"
                           Width="6" Height="18" StrokeThickness="1" Margin="-1,0,0,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="-1,0">
                                    <LineSegment Point="{Binding RightTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="-1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <Border Height="18" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1">
                     <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
                  </Border>
               </DockPanel>
               <ControlTemplate.Triggers>
                  <Trigger Property="Direction" Value="None">
                     <Setter TargetName="LeftEdge" Property="Width" Value="2"/>
                     <Setter TargetName="RightEdge" Property="Width" Value="2"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Left">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Right">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Out">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="In">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                     <Setter Property="Opacity" Value=".5"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Angle TextBox Style -->
   <Style TargetType="hsc:AngleTextBox">
      <Setter Property="Background" Value="{DynamicResource Backlight}"/>
      <Setter Property="Foreground" Value="{DynamicResource Primary}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource TopToBottomBrush}"/>
      <Setter Property="MinHeight" Value="18"/>
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="hsc:AngleTextBox">
               <DockPanel Name="Container">
                  <Path Name="LeftEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Left"
                           Width="6" Height="{TemplateBinding MinHeight}" StrokeThickness="1" Margin="0,0,-1,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="1,0">
                                    <LineSegment Point="{Binding LeftTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding LeftBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <Path Name="RightEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Right"
                           Width="6" Height="{TemplateBinding MinHeight}" StrokeThickness="1" Margin="-1,0,0,0" Stretch="Fill" SnapsToDevicePixels="True">
                     <Path.Data>
                        <PathGeometry>
                           <PathGeometry.Figures>
                              <PathFigureCollection>
                                 <PathFigure StartPoint="-1,0">
                                    <LineSegment Point="{Binding RightTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="{Binding RightBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                    <LineSegment Point="-1,10"/>
                                 </PathFigure>
                              </PathFigureCollection>
                           </PathGeometry.Figures>
                        </PathGeometry>
                     </Path.Data>
                  </Path>
                  <ContentPresenter Height="{TemplateBinding MinHeight}" />
               </DockPanel>
               <ControlTemplate.Triggers>
                  <Trigger Property="Direction" Value="None">
                     <Setter TargetName="LeftEdge" Property="Width" Value="2"/>
                     <Setter TargetName="RightEdge" Property="Width" Value="2"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Left">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Right">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="Out">
                     <Setter Property="LeftMiddle" Value="-5,5"/>
                     <Setter Property="RightMiddle" Value="5,5"/>
                  </Trigger>
                  <Trigger Property="Direction" Value="In">
                     <Setter Property="LeftTop" Value="-5,0"/>
                     <Setter Property="LeftBottom" Value="-5,10"/>
                     <Setter Property="RightTop" Value="5,0"/>
                     <Setter Property="RightBottom" Value="5,10"/>
                  </Trigger>
                  <Trigger Property="IsKeyboardFocusWithin" Value="True">
                     <Setter TargetName="LeftEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="RightEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsMouseOver" Value="True">
                     <Setter TargetName="LeftEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                     <Setter TargetName="RightEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                  </Trigger>
                  <Trigger Property="IsEnabled" Value="False">
                     <Setter Property="Background" Value="{DynamicResource Background}"/>
                     <Setter Property="Foreground" Value="{DynamicResource Secondary}"/>
                     <Setter Property="Opacity" Value=".5"/>
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Angle Menu Item Style -->
   <Style TargetType="{x:Type hsc:AngleMenuItem}">
      <Style.Triggers>
         <Trigger Property="Role" Value="TopLevelHeader">
            <Setter Property="Background" Value="{DynamicResource Backlight}"/>
            <Setter Property="BorderBrush" Value="{DynamicResource Secondary}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
               <Setter.Value>
                  <ControlTemplate TargetType="{x:Type hsc:AngleMenuItem}">
                     <DockPanel>
                        <Path Name="LeftEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Left"
                                 Width="6" StrokeThickness="1" Margin="0,0,-1,0" Stretch="Fill" SnapsToDevicePixels="True">
                           <Path.Data>
                              <PathGeometry>
                                 <PathGeometry.Figures>
                                    <PathFigureCollection>
                                       <PathFigure StartPoint="1,0">
                                          <LineSegment Point="{Binding LeftTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="{Binding LeftMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="{Binding LeftBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="1,10"/>
                                       </PathFigure>
                                    </PathFigureCollection>
                                 </PathGeometry.Figures>
                              </PathGeometry>
                           </Path.Data>
                        </Path>
                        <Path Name="RightEdge" Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" DockPanel.Dock="Right"
                                 Width="6" StrokeThickness="1" Margin="-1,0,0,0" Stretch="Fill" SnapsToDevicePixels="True">
                           <Path.Data>
                              <PathGeometry>
                                 <PathGeometry.Figures>
                                    <PathFigureCollection>
                                       <PathFigure StartPoint="-1,0">
                                          <LineSegment Point="{Binding RightTop, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="{Binding RightMiddle, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="{Binding RightBottom, RelativeSource={RelativeSource TemplatedParent}}" />
                                          <LineSegment Point="-1,10"/>
                                       </PathFigure>
                                    </PathFigureCollection>
                                 </PathGeometry.Figures>
                              </PathGeometry>
                           </Path.Data>
                        </Path>
                        <Border Name="TopBottomBorder" BorderThickness="0,1" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="True"
                                Padding="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Background="{TemplateBinding Background}">
                           <Grid Name="ItemBorder" Background="{TemplateBinding Background}">
                              <ContentPresenter ContentSource="Header" RecognizesAccessKey="True" TextBlock.Foreground="{DynamicResource Primary}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                              <Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" SnapsToDevicePixels="True">
                                 <Border x:Name="SubmenuBorder" BorderThickness="1" Background="{DynamicResource Background}" BorderBrush="{DynamicResource Accent}">
                                    <StackPanel Name="ItemsPresenter" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
                                 </Border>
                              </Popup>
                           </Grid>
                        </Border>
                     </DockPanel>
                     <ControlTemplate.Triggers>
                        <Trigger Property="Direction" Value="None">
                           <Setter TargetName="LeftEdge" Property="Width" Value="2"/>
                           <Setter TargetName="RightEdge" Property="Width" Value="2"/>
                        </Trigger>
                        <Trigger Property="Direction" Value="Left">
                           <Setter Property="LeftMiddle" Value="-5,5"/>
                           <Setter Property="RightTop" Value="5,0"/>
                           <Setter Property="RightBottom" Value="5,10"/>
                        </Trigger>
                        <Trigger Property="Direction" Value="Right">
                           <Setter Property="LeftTop" Value="-5,0"/>
                           <Setter Property="LeftBottom" Value="-5,10"/>
                           <Setter Property="RightMiddle" Value="5,5"/>
                        </Trigger>
                        <Trigger Property="Direction" Value="Out">
                           <Setter Property="LeftMiddle" Value="-5,5"/>
                           <Setter Property="RightMiddle" Value="5,5"/>
                        </Trigger>
                        <Trigger Property="Direction" Value="In">
                           <Setter Property="LeftTop" Value="-5,0"/>
                           <Setter Property="LeftBottom" Value="-5,10"/>
                           <Setter Property="RightTop" Value="5,0"/>
                           <Setter Property="RightBottom" Value="5,10"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                           <Setter TargetName="ItemBorder" Property="Background" Value="{DynamicResource Backlight}" />
                           <Setter TargetName="LeftEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                           <Setter TargetName="RightEdge" Property="Stroke" Value="{DynamicResource Accent}"/>
                           <Setter TargetName="TopBottomBorder" Property="BorderBrush" Value="{DynamicResource Accent}"/>
                        </Trigger>
                     </ControlTemplate.Triggers>
                  </ControlTemplate>
               </Setter.Value>
            </Setter>
         </Trigger>
      </Style.Triggers>
   </Style>

   <!-- Text Editor Style -->
   <Style TargetType="hsc:TextEditor">
      <Setter Property="ContextMenuOverride">
         <Setter.Value>
            <ContextMenu>
               <MenuItem Command="ApplicationCommands.Cut" />
               <MenuItem Command="ApplicationCommands.Copy" />
               <MenuItem Command="ApplicationCommands.Paste" />
               <Separator />
               <MenuItem Command="ApplicationCommands.SelectAll" />
            </ContextMenu>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- Data Templates -->
   <DataTemplate DataType="{x:Type tools:ReadonlyPaletteCollection}">
      <StackPanel Orientation="Horizontal">
         <TextBlock VerticalAlignment="Center" Margin="0,0,2,0" Text="{Binding Index}" Visibility="{Binding DisplayIndex, Converter={StaticResource BoolToVisibility}}" />
         <ItemsControl SnapsToDevicePixels="True" ItemsSource="{Binding Colors}">
            <ItemsControl.ItemsPanel>
               <ItemsPanelTemplate>
                  <UniformGrid Columns="{Binding ColorWidth}" Rows="{Binding ColorHeight}" HorizontalAlignment="Center"/>
               </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
               <DataTemplate>
                  <Rectangle Margin="1" Fill="{Binding Converter={StaticResource PaletteColorConverter}}" Width="14" Height="14"/>
               </DataTemplate>
            </ItemsControl.ItemTemplate>
         </ItemsControl>
      </StackPanel>
   </DataTemplate>
   <DataTemplate DataType="{x:Type images:ReadonlyPixelViewModel}">
      <hsc:PixelImage />
   </DataTemplate>
   <DataTemplate DataType="{x:Type images:CanvasPixelViewModel}">
      <hsc:PixelImage />
   </DataTemplate>
</ResourceDictionary>