<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:properties="clr-namespace:JuliusSweetland.OptiKey.Properties"
                    xmlns:valueConverters="clr-namespace:JuliusSweetland.OptiKey.UI.ValueConverters"
                    xmlns:windows="clr-namespace:JuliusSweetland.OptiKey.UI.Windows"
                    xmlns:controls="clr-namespace:JuliusSweetland.OptiKey.UI.Controls"
                    xmlns:behaviours="clr-namespace:JuliusSweetland.OptiKey.UI.Behaviours"
                    xmlns:enums="clr-namespace:JuliusSweetland.OptiKey.Enums">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/OptiKey;component/Resources/Themes/Colours/Android.xaml" />
        <ResourceDictionary Source="/OptiKey;component/Resources/Icons/KeySymbols.xaml" />
        <ResourceDictionary>
            <SolidColorBrush x:Key="WindowBorderBrush" Color="{StaticResource Grey}" />
            
            <SolidColorBrush x:Key="KeyDefaultForegroundBrush" Color="{StaticResource Black}" />
            <SolidColorBrush x:Key="KeyDefaultBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="KeyDefaultBackgroundBrush" Color="{StaticResource White}" />

            <SolidColorBrush x:Key="KeyHoverForegroundBrush" Color="{StaticResource Red}" />
            <SolidColorBrush x:Key="KeySelectionProgressBrush" Color="{StaticResource Red}" />
            <SolidColorBrush x:Key="CapturingMultiKeySelectionBrush" Color="{StaticResource Red}" />

            <StaticResource x:Key="KeySelectionForeground" ResourceKey="Blue"/>
            <StaticResource x:Key="KeySelectionBorder" ResourceKey="Grey"/>
            <StaticResource x:Key="KeySelectionBackground" ResourceKey="Grey"/>
            
            <SolidColorBrush x:Key="KeyDownStateIsDownForegroundBrush" Color="{StaticResource Blue}" />
            <SolidColorBrush x:Key="KeyDownStateIsDownBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="KeyDownStateIsDownBackgroundBrush" Color="{StaticResource White}" />

            <SolidColorBrush x:Key="KeyDownStateIsLockedDownForegroundBrush" Color="{StaticResource Blue}" />
            <SolidColorBrush x:Key="KeyDownStateIsLockedDownBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="KeyDownStateIsLockedDownBackgroundBrush" Color="{StaticResource White}" />

            <SolidColorBrush x:Key="KeyDisabledForegroundBrush" Color="{StaticResource LightGrey}" />
            <SolidColorBrush x:Key="KeyDisabledBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="KeyDisabledBackgroundBrush" Color="{StaticResource White}" />

            <StaticResource x:Key="ScratchpadCaretBackgroundBrush" ResourceKey="Blue"/>
            <SolidColorBrush x:Key="ScratchpadForegroundBrush" Color="{StaticResource Blue}" />
            <SolidColorBrush x:Key="ScratchpadBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="ScratchpadBackgroundBrush" Color="{StaticResource White}" />
            
            <SolidColorBrush x:Key="ScratchpadDisabledForegroundBrush" Color="{StaticResource LightGrey}" />
            <SolidColorBrush x:Key="ScratchpadDisabledBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="ScratchpadDisabledBackgroundBrush" Color="{StaticResource White}" />

            <SolidColorBrush x:Key="QuestionForegroundBrush" Color="{StaticResource Black}" />
            <SolidColorBrush x:Key="QuestionBackgroundBrush" Color="{StaticResource White}" />
            
            <SolidColorBrush x:Key="DebugTextForegroundBrush" Color="{StaticResource Green}" />

            <SolidColorBrush x:Key="CursorDefaultStrokeBrush" Color="{StaticResource Black}" />
            <SolidColorBrush x:Key="CursorDefaultFillBrush" Color="{StaticResource White}" />
            <StaticResource x:Key="PointSelectionForeground" ResourceKey="Blue"/>
            <SolidColorBrush x:Key="PointSelectionProgressBrush" Color="{StaticResource Red}" />

            <SolidColorBrush x:Key="ToastNotificationForegroundBrush" Color="{StaticResource Black}" />
            <SolidColorBrush x:Key="ToastNotificationBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="ToastNotificationBackgroundBrush" Color="{StaticResource White}" />

            <SolidColorBrush x:Key="ToastErrorNotificationForegroundBrush" Color="{StaticResource Black}" />
            <SolidColorBrush x:Key="ToastErrorNotificationBorderBrush" Color="{StaticResource Grey}" />
            <SolidColorBrush x:Key="ToastErrorNotificationBackgroundBrush" Color="{StaticResource Red}" />

            <valueConverters:LengthDividedBySpan x:Key="LengthDividedBySpan" />
            <valueConverters:FontSizeToFitLines x:Key="FontSizeToFitLines" />

            <Style x:Key="MainWindowStyle" TargetType="{x:Type windows:MainWindow}" BasedOn="{StaticResource {x:Type Window}}">
                <Setter Property="BorderBrush" Value="{StaticResource WindowBorderBrush}" />
                <Setter Property="BorderThickness" Value="2" />
            </Style>
            
            <Style x:Key="KeyTextStyle" TargetType="{x:Type TextBlock}">
                <Setter Property="Foreground" Value="{StaticResource KeyDefaultForegroundBrush}" />
                <Setter Property="TextAlignment" Value="Center" />
                <Setter Property="Text" Value="{Binding Path=ShiftUpText, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}}" />
                <Setter Property="FontFamily" Value="{Binding Source={x:Static properties:Settings.Default}, Path=FontFamily}" />
                <Setter Property="FontWeight" Value="{Binding Source={x:Static properties:Settings.Default}, Path=FontWeight}" />
                <Setter Property="FontStretch" Value="{Binding Source={x:Static properties:Settings.Default}, Path=FontStretch}" />
                <Setter Property="Visibility" Value="Hidden" />
                <Setter Property="behaviours:KeyBehaviours.BeginAnimationOnKeySelectionEvent">
                    <Setter.Value>
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)" 
                                                          Duration="0:0:0.2" FillBehavior="Stop">
                                <DiscreteColorKeyFrame Value="{StaticResource KeySelectionForeground}" KeyTime="0:0:0" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <!--If there is text, but no symbol then always display the text-->
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding Path=HasText, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" Value="True" />
                            <Condition Binding="{Binding Path=HasSymbol, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False" />
                        </MultiDataTrigger.Conditions>
                        <MultiDataTrigger.Setters>
                            <Setter Property="Visibility" Value="Visible" />
                        </MultiDataTrigger.Setters>
                    </MultiDataTrigger>

                    <!--Is there text and a symbol then only display the text when the key is current)-->
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding Path=HasText, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" Value="True" />
                            <Condition Binding="{Binding Path=HasSymbol, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" Value="True" />
                            <Condition Binding="{Binding Path=IsCurrent, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="True" />
                        </MultiDataTrigger.Conditions>
                        <MultiDataTrigger.Setters>
                            <Setter Property="Visibility" Value="Visible" />
                        </MultiDataTrigger.Setters>
                    </MultiDataTrigger>

                    <!--This key is in a key down state of Down-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.Down}">
                        <Setter Property="Foreground" Value="{StaticResource KeyDownStateIsDownForegroundBrush}" />
                    </DataTrigger>

                    <!--This key is in a key down state of Locked Down-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.LockedDown}">
                        <Setter Property="Foreground" Value="{StaticResource KeyDownStateIsDownForegroundBrush}" />
                    </DataTrigger>

                    <!--The Shift key is down-->
                    <DataTrigger Binding="{Binding Path=DisplayShiftDownText, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="True">
                        <Setter Property="Text" Value="{Binding Path=ShiftDownText, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" />
                    </DataTrigger>

                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="Foreground" Value="{StaticResource KeyDisabledForegroundBrush}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="KeySymbolStyle" TargetType="{x:Type Path}">
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="Margin" Value="2" />
                <Setter Property="Data" Value="{Binding Path=SymbolGeometry, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" />
                <Setter Property="Fill" Value="{StaticResource KeyDefaultForegroundBrush}" />
                <Setter Property="Visibility" Value="Collapsed" />
                <Setter Property="behaviours:KeyBehaviours.BeginAnimationOnKeySelectionEvent">
                    <Setter.Value>
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)" 
                                                          Duration="0:0:0.2" FillBehavior="Stop">
                                <DiscreteColorKeyFrame Value="{StaticResource KeySelectionForeground}" KeyTime="0:0:0" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <!--Is there a symbol to display-->
                    <DataTrigger Binding="{Binding Path=HasSymbol, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>

                    <!--Collapse symbol to promote key's Text if there is Text and the key is current-->
                    <MultiDataTrigger>
                        <MultiDataTrigger.Conditions>
                            <Condition Binding="{Binding Path=HasText, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" Value="True" />
                            <Condition Binding="{Binding Path=IsCurrent, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="True" />
                        </MultiDataTrigger.Conditions>
                        <MultiDataTrigger.Setters>
                            <Setter Property="Visibility" Value="Collapsed" />
                        </MultiDataTrigger.Setters>
                    </MultiDataTrigger>
                    
                    <!--This key is in a key down state of Down-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.Down}">
                        <Setter Property="Fill" Value="{StaticResource KeyDownStateIsDownForegroundBrush}" />
                    </DataTrigger>

                    <!--This key is in a key down state of Locked Down-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.LockedDown}">
                        <Setter Property="Fill" Value="{StaticResource KeyDownStateIsLockedDownForegroundBrush}" />
                    </DataTrigger>

                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="Fill" Value="{StaticResource KeyDisabledForegroundBrush}" />
                    </DataTrigger>

                    <!--Symbol Orientation to right-->
                    <DataTrigger Binding="{Binding Path=SymbolOrientation, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:SymbolOrientations.Right}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="90"/>
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>

                    <!--Symbol Orientation to bottom-->
                    <DataTrigger Binding="{Binding Path=SymbolOrientation, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:SymbolOrientations.Bottom}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="180"/>
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>

                    <!--Symbol Orientation to left-->
                    <DataTrigger Binding="{Binding Path=SymbolOrientation, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:SymbolOrientations.Left}">
                        <Setter Property="LayoutTransform">
                            <Setter.Value>
                                <TransformGroup>
                                    <RotateTransform Angle="270"/>
                                </TransformGroup>
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="KeyLockIconStyle" TargetType="{x:Type Path}">
                <Setter Property="Visibility" Value="Hidden" />
                <Setter Property="Fill" Value="{StaticResource KeyDownStateIsLockedDownForegroundBrush}" />
                <Setter Property="Stretch" Value="Uniform" />
                <Setter Property="Margin" Value="1" />
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Setter Property="Data" Value="{StaticResource PadlockIcon}" />
                <Style.Triggers>
                    <!--This key is in a key down state of Locked Down-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.LockedDown}">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>

                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="Fill" Value="{StaticResource KeyDisabledForegroundBrush}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="KeySelectionProgressStyle" TargetType="{x:Type controls:ProgressIndicator}">
                <Setter Property="Fill" Value="{StaticResource KeySelectionProgressBrush}" />
                <Setter Property="MaxValue" Value="1" />
                <Setter Property="Value" Value="{Binding Path=SelectionProgress, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}, Mode=OneWay}" />
                <Style.Triggers>
                    <!--Progress is 0-->
                    <Trigger Property="Value" Value="0">
                        <Setter Property="Visibility" Value="Hidden" />
                    </Trigger>

                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="Visibility" Value="Hidden" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="KeyBorderStyle" TargetType="{x:Type Border}">
                <Setter Property="Padding" Value="2" />
                <Setter Property="BorderThickness" Value="1" />
                <Setter Property="BorderBrush" Value="{StaticResource KeyDefaultBorderBrush}" />
                <Setter Property="Background" Value="{StaticResource KeyDefaultBackgroundBrush}" />
                <Setter Property="behaviours:KeyBehaviours.BeginAnimationOnKeySelectionEvent">
                    <Setter.Value>
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" 
                                                                   Duration="0:0:0.2" FillBehavior="Stop">
                                <DiscreteColorKeyFrame Value="{StaticResource KeySelectionBorder}" KeyTime="0:0:0" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" 
                                                                   Duration="0:0:0.2" FillBehavior="Stop">
                                <DiscreteColorKeyFrame Value="{StaticResource KeySelectionBackground}" KeyTime="0:0:0" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <!--This key is in a key down state of On-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.Down}">
                        <Setter Property="BorderBrush" Value="{StaticResource KeyDownStateIsDownBorderBrush}" />
                        <Setter Property="Background" Value="{StaticResource KeyDownStateIsDownBackgroundBrush}" />
                    </DataTrigger>

                    <!--This key is in a key down state of Lock-->
                    <DataTrigger Binding="{Binding Path=KeyDownState, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="{x:Static enums:KeyDownStates.LockedDown}">
                        <Setter Property="BorderBrush" Value="{StaticResource KeyDownStateIsLockedDownBorderBrush}" />
                        <Setter Property="Background" Value="{StaticResource KeyDownStateIsLockedDownBackgroundBrush}" />
                    </DataTrigger>

                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="BorderBrush" Value="{StaticResource KeyDisabledBorderBrush}" />
                        <Setter Property="Background" Value="{StaticResource KeyDisabledBackgroundBrush}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="KeyBorderHighlightStyle" TargetType="{x:Type Border}">
                <Setter Property="BorderThickness" Value="5" />
                <Setter Property="BorderBrush" Value="{StaticResource KeyHoverForegroundBrush}" />
                <Setter Property="Effect">
                    <Setter.Value>
                        <BlurEffect Radius="5.0" KernelType="Gaussian"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Visibility" Value="Collapsed" />
                <Style.Triggers>
                    <!--Is Key Enabled-->
                    <DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="False">
                        <Setter Property="BorderBrush" Value="{StaticResource KeyDisabledForegroundBrush}" />
                    </DataTrigger>

                    <!--Make visible when this key is current-->
                    <DataTrigger Binding="{Binding Path=IsCurrent, RelativeSource={RelativeSource AncestorType=controls:Key}}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type controls:Key}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:Key}">
                            <Grid>
                                <Border Style="{StaticResource KeyBorderStyle}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="1*" />
                                            <RowDefinition Height="2*" />
                                            <RowDefinition Height="1*" />
                                        </Grid.RowDefinitions>
                                        <ContentControl Grid.RowSpan="3">
                                            <!--Enforce size limits of one key high/wide using the Span info on the key-->
                                            <ContentControl.MaxWidth>
                                                <MultiBinding Converter="{StaticResource LengthDividedBySpan}">
                                                    <MultiBinding.Bindings>
                                                        <Binding Path="ActualWidth" RelativeSource="{RelativeSource AncestorType={x:Type Grid}}" />
                                                        <Binding Path="WidthSpan" RelativeSource="{RelativeSource AncestorType={x:Type controls:Key}}" />
                                                    </MultiBinding.Bindings>
                                                </MultiBinding>
                                            </ContentControl.MaxWidth>
                                            <ContentControl.MaxHeight>
                                                <MultiBinding Converter="{StaticResource LengthDividedBySpan}">
                                                    <MultiBinding.Bindings>
                                                        <Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType={x:Type Grid}}" />
                                                        <Binding Path="HeightSpan" RelativeSource="{RelativeSource AncestorType={x:Type controls:Key}}" />
                                                    </MultiBinding.Bindings>
                                                </MultiBinding>
                                            </ContentControl.MaxHeight>
                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="1*" />
                                                    <ColumnDefinition Width="4*" />
                                                    <ColumnDefinition Width="1*" />
                                                </Grid.ColumnDefinitions>
                                                <controls:ProgressIndicator Grid.ColumnSpan="3" 
                                                                            Style="{StaticResource KeySelectionProgressStyle}" />
                                                <Viewbox Grid.Column="0" Grid.ColumnSpan="3">
                                                    <Viewbox.Style>
                                                        <Style TargetType="{x:Type Viewbox}">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Path=HasSymbol, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}}" Value="True">
                                                                    <Setter Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </Viewbox.Style>
                                                    <Grid>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition SharedSizeGroup="{Binding Path=SharedSizeGroup, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}}" />
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock Style="{StaticResource KeyTextStyle}" VerticalAlignment="Center" Margin="5,0,5,0" />
                                                    </Grid>
                                                </Viewbox>
                                                <Viewbox Grid.Column="1">
                                                    <Grid>
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition SharedSizeGroup="{Binding Path=SharedSizeGroup, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}}" />
                                                        </Grid.ColumnDefinitions>
                                                        <TextBlock VerticalAlignment="Center">
                                                            <TextBlock.Style>
                                                                <Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource KeyTextStyle}">
                                                                    <Setter Property="Visibility" Value="Visible" />
                                                                    <Style.Triggers>
                                                                        <DataTrigger Binding="{Binding Path=HasSymbol, RelativeSource={RelativeSource AncestorType={x:Type controls:Key}}}" Value="True">
                                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                                        </DataTrigger>
                                                                    </Style.Triggers>
                                                                </Style>
                                                            </TextBlock.Style>
                                                        </TextBlock>
                                                        <Path Style="{StaticResource KeySymbolStyle}" Width="64" Height="64" VerticalAlignment="Center" />
                                                    </Grid>
                                                </Viewbox>
                                            </Grid>
                                        </ContentControl>
                                        <Path Grid.Row="2" Style="{StaticResource KeyLockIconStyle}" />
                                    </Grid>
                                </Border>
                                <Border Style="{StaticResource KeyBorderHighlightStyle}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type controls:Scratchpad}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:Scratchpad}">
                            <Border BorderThickness="1">
                                <Border.Style>
                                    <Style TargetType="{x:Type Border}">
                                        <Setter Property="BorderBrush" Value="{StaticResource ScratchpadBorderBrush}" />
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding DataContext.ScratchpadIsDisabled, RelativeSource={RelativeSource AncestorType=controls:KeyboardHost}}" Value="True">
                                                <Setter Property="BorderBrush" Value="{StaticResource ScratchpadDisabledBorderBrush}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Border.Style>
                                <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"
                                              behaviours:ScrollViewerBehaviours.AutoScrollToEndOnPropertyOrCollectionChanged="{TemplateBinding Text}">
                                    <Grid>
                                        <TextBox x:Name="ScratchpadTextBox"
                                             Text="{TemplateBinding Text}"
                                             behaviours:TextBoxBehaviours.CaretElement="{Binding ElementName=ScratchpadCaret}"
                                             TextWrapping="Wrap"
                                             IsReadOnly="True"
                                             CaretBrush="Transparent" 
                                             Padding="0" Margin="0" BorderThickness="0"
                                             MaxWidth="{Binding Path=ActualWidth, RelativeSource={RelativeSource AncestorType=ScrollViewer}}"
                                             FontFamily="{Binding Source={x:Static properties:Settings.Default}, Path=FontFamily}"
                                             FontWeight="{Binding Source={x:Static properties:Settings.Default}, Path=FontWeight}"
                                             FontStretch="{Binding Source={x:Static properties:Settings.Default}, Path=FontStretch}">
                                            <TextBox.FontSize>
                                                <MultiBinding Converter="{StaticResource FontSizeToFitLines}">
                                                    <MultiBinding.Bindings>
                                                        <Binding Path="ScratchpadNumberOfLines" Source="{x:Static properties:Settings.Default}" />
                                                        <Binding Path="ActualHeight" RelativeSource="{RelativeSource AncestorType={x:Type ScrollViewer}}" />
                                                        <Binding Path="FontFamily" RelativeSource="{RelativeSource Self}" />
                                                    </MultiBinding.Bindings>
                                                </MultiBinding>
                                            </TextBox.FontSize>
                                            <TextBox.Style>
                                                <Style TargetType="{x:Type TextBox}">
                                                    <Setter Property="Foreground" Value="{StaticResource ScratchpadForegroundBrush}" />
                                                    <Setter Property="Background" Value="{StaticResource ScratchpadBackgroundBrush}" />
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding DataContext.ScratchpadIsDisabled, RelativeSource={RelativeSource AncestorType=controls:KeyboardHost}}" Value="True">
                                                            <Setter Property="Foreground" Value="{StaticResource ScratchpadDisabledForegroundBrush}" />
                                                            <Setter Property="Background" Value="{StaticResource ScratchpadDisabledBackgroundBrush}" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBox.Style>
                                        </TextBox>
                                        <Canvas>
                                            <Border x:Name="ScratchpadCaret" 
                                                    Canvas.Left="0" Canvas.Top="0" 
                                                    Width="5" 
                                                    Height="{Binding FontSize, ElementName=ScratchpadTextBox}" 
                                                    Background="{StaticResource ScratchpadForegroundBrush}">
                                                <Border.Style>
                                                    <Style TargetType="{x:Type Border}">
                                                        <Style.Triggers>
                                                            <EventTrigger RoutedEvent="Border.Loaded">
                                                                <BeginStoryboard>
                                                                    <Storyboard  x:Name="CaretStoryBoard" RepeatBehavior="Forever">
                                                                        <ColorAnimationUsingKeyFrames 
                                                                    Storyboard.TargetProperty="Background.Color"
                                                                    Duration="0:0:0:1"
                                                                    FillBehavior="HoldEnd">
                                                                            <ColorAnimationUsingKeyFrames.KeyFrames >
                                                                                <DiscreteColorKeyFrame KeyTime="0:0:0.750" Value="Transparent" />
                                                                                <DiscreteColorKeyFrame KeyTime="0:0:0.000" Value="{StaticResource ScratchpadCaretBackgroundBrush}"/>
                                                                            </ColorAnimationUsingKeyFrames.KeyFrames>
                                                                        </ColorAnimationUsingKeyFrames>
                                                                    </Storyboard>
                                                                </BeginStoryboard>
                                                            </EventTrigger>
                                                            <DataTrigger Binding="{Binding DataContext.ScratchpadIsDisabled, RelativeSource={RelativeSource AncestorType=controls:KeyboardHost}}" Value="True">
                                                                <Setter Property="Visibility" Value="Collapsed" />
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </Border.Style>
                                            </Border>
                                        </Canvas>
                                    </Grid>
                                </ScrollViewer>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type controls:QuestionText}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:QuestionText}">
                            <controls:TextBlockScaler Margin="5">
                                <TextBlock Text="{TemplateBinding Text}"
                                           TextWrapping="Wrap"
                                           TextAlignment="Center"
                                           FontFamily="{Binding Source={x:Static properties:Settings.Default}, Path=FontFamily}"
                                           FontWeight="{Binding Source={x:Static properties:Settings.Default}, Path=FontWeight}"
                                           FontStretch="{Binding Source={x:Static properties:Settings.Default}, Path=FontStretch}"
                                           Foreground="{StaticResource QuestionForegroundBrush}"
                                           Background="{StaticResource QuestionBackgroundBrush}" />
                            </controls:TextBlockScaler>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style x:Key="CursorIconStyle" TargetType="{x:Type Path}">
                <Setter Property="Stroke" Value="{StaticResource CursorDefaultStrokeBrush}" />
                <Setter Property="Fill" Value="{StaticResource CursorDefaultFillBrush}" />
                <Setter Property="Stretch" Value="Fill" />
                <Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
                <Setter Property="Data" Value="{StaticResource CursorIcon}" />
                <Setter Property="behaviours:CursorBehaviours.BeginAnimationOnPointSelectionEvent">
                    <Setter.Value>
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Path.Fill).(SolidColorBrush.Color)" 
                                                          Duration="0:0:0.2" FillBehavior="Stop">
                                <DiscreteColorKeyFrame Value="{StaticResource PointSelectionForeground}" KeyTime="0:0:0" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=CursorPointPosition, RelativeSource={RelativeSource AncestorType=controls:CursorPopup}}" Value="{x:Static enums:CursorPointPositions.ToTopRight}">
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <ScaleTransform ScaleX="-1" />
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=CursorPointPosition, RelativeSource={RelativeSource AncestorType=controls:CursorPopup}}" Value="{x:Static enums:CursorPointPositions.ToBottomLeft}">
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <ScaleTransform ScaleY="-1" />
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=CursorPointPosition, RelativeSource={RelativeSource AncestorType=controls:CursorPopup}}" Value="{x:Static enums:CursorPointPositions.ToBottomRight}">
                        <Setter Property="RenderTransform">
                            <Setter.Value>
                                <ScaleTransform ScaleX="-1" ScaleY="-1" />
                            </Setter.Value>
                        </Setter>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="PointSelectionProgressStyle" TargetType="{x:Type controls:ProgressIndicator}">
                <Setter Property="Fill" Value="{StaticResource PointSelectionProgressBrush}" />
                <Setter Property="MaxValue" Value="1" />
                <Setter Property="Value" Value="{Binding Path=SelectionProgress, RelativeSource={RelativeSource AncestorType={x:Type controls:CursorPopup}}, Mode=OneWay}" />
                <Style.Triggers>
                    <!--Progress is 0-->
                    <Trigger Property="Value" Value="0">
                        <Setter Property="Visibility" Value="Hidden" />
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style TargetType="{x:Type controls:Cursor}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:Cursor}">
                            <Grid>
                                <Path Style="{StaticResource CursorIconStyle}" />
                                <controls:ProgressIndicator Style="{StaticResource PointSelectionProgressStyle}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type controls:ToastNotification}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type controls:ToastNotification}">
                            <Viewbox Stretch="Uniform">
                                <Border BorderThickness="2" CornerRadius="10">
                                    <Border.Style>
                                        <Style TargetType="Border">
                                            <Setter Property="BorderBrush" Value="{StaticResource ToastNotificationBorderBrush}" />
                                            <Setter Property="Background" Value="{StaticResource ToastNotificationBackgroundBrush}" />
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding Path=NotificationType, RelativeSource={RelativeSource AncestorType={x:Type controls:ToastNotificationPopup}}, Mode=OneWay}" Value="{x:Static enums:NotificationTypes.Error}">
                                                    <Setter Property="BorderBrush" Value="{StaticResource ToastErrorNotificationBorderBrush}" />
                                                    <Setter Property="Background" Value="{StaticResource ToastErrorNotificationBackgroundBrush}" />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </Border.Style>
                                    <StackPanel Margin="20">
                                        <TextBlock TextWrapping="Wrap" FontWeight="Bold" Margin="5" HorizontalAlignment="Center" TextAlignment="Center" FontSize="25"
                                                   Text="{Binding Path=Title, RelativeSource={RelativeSource AncestorType={x:Type controls:ToastNotificationPopup}}, Mode=OneWay}">
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock">
                                                    <Setter Property="Foreground" Value="{StaticResource ToastNotificationForegroundBrush}" />
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding Path=NotificationType, RelativeSource={RelativeSource AncestorType={x:Type controls:ToastNotificationPopup}}, Mode=OneWay}" Value="{x:Static enums:NotificationTypes.Error}">
                                                            <Setter Property="Foreground" Value="{StaticResource ToastErrorNotificationForegroundBrush}" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                        <TextBlock TextWrapping="Wrap" Margin="5" HorizontalAlignment="Center" TextAlignment="Center" FontSize="16"
                                                   Text="{Binding Path=Content, RelativeSource={RelativeSource AncestorType={x:Type controls:ToastNotificationPopup}}, Mode=OneWay}">
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock">
                                                    <Setter Property="Foreground" Value="{StaticResource ToastNotificationForegroundBrush}" />
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding Path=NotificationType, RelativeSource={RelativeSource AncestorType={x:Type controls:ToastNotificationPopup}}, Mode=OneWay}" Value="{x:Static enums:NotificationTypes.Error}">
                                                            <Setter Property="Foreground" Value="{StaticResource ToastErrorNotificationForegroundBrush}" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                    </StackPanel>
                                </Border>
                            </Viewbox>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
