<Application x:Class="LiveDraw.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:LiveDraw"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:LiveDraw="clr-namespace:AntFu7.LiveDraw"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="IconDataDictionary.xaml"/>
            </ResourceDictionary.MergedDictionaries>

            <Color x:Key="FakeTransparentColor" >#01000000</Color>
            <Color x:Key="TrueTransparentColor" >Transparent</Color>
            <Color x:Key="QuartertransparentGrayColor">#3F727272</Color>
            <Color x:Key="SemitransparentGrayColor">#7F727272</Color>
            <Color x:Key="TriquartertransparentGrayColor" >#3F727272</Color>
            <Color x:Key="FunctionalButtonBackgroundColor" >#7F000000</Color>
            <Color x:Key="FunctionalButtonHoverColor" >#7F212121</Color>
            <Color x:Key="FunctionalButtonActiveColor" >#7F515151</Color>

            <SolidColorBrush x:Key="FakeTransparent" Color="{StaticResource FakeTransparentColor}"/>
            <SolidColorBrush x:Key="TrueTransparent" Color="{StaticResource TrueTransparentColor}"/>
            <SolidColorBrush x:Key="QuartertransparentGray" Color="{StaticResource QuartertransparentGrayColor}" />
            <SolidColorBrush x:Key="SemitransparentGray" Color="{StaticResource SemitransparentGrayColor}" />
            <SolidColorBrush x:Key="TriquartertransparentGray" Color="{StaticResource TriquartertransparentGrayColor}" />
            <SolidColorBrush x:Key="FunctionalButtonBackground" Color="{StaticResource FunctionalButtonBackgroundColor}" />
            <SolidColorBrush x:Key="FunctionalButtonHover" Color="{StaticResource FunctionalButtonHoverColor}" />
            <SolidColorBrush x:Key="FunctionalButtonActive" Color="{StaticResource FunctionalButtonActiveColor}" />

            <Duration x:Key="Duration1">0:0:0:0.1</Duration>
            <Duration x:Key="Duration2">0:0:0:0.2</Duration>
            <Duration x:Key="Duration3">0:0:0:0.3</Duration>
            <Duration x:Key="Duration4">0:0:0:0.4</Duration>
            <Duration x:Key="Duration5">0:0:0:0.5</Duration>
            <Duration x:Key="Duration7">0:0:0:0.7</Duration>
            <Duration x:Key="Duration10">0:0:0:1</Duration>

            <Thickness x:Key="ElementMarginSmall">2</Thickness>
            <Thickness x:Key="ElementMarginMiddle">5</Thickness>
            <Thickness x:Key="ElementMarginLarge">10</Thickness>

            <sys:Double x:Key="ColorPickerSmall">35</sys:Double>
            <sys:Double x:Key="ColorPickerMiddle">55</sys:Double>
            <sys:Double x:Key="ColorPickerLarge">75</sys:Double>

            <CornerRadius x:Key="ColorPickerNormalCorner">18</CornerRadius>
            <CornerRadius x:Key="ColorPickerHoverCorner">12</CornerRadius>

            <FontFamily x:Key="InterfaceFont">Consolas</FontFamily>

            <sys:Double x:Key="VerticalModeFlowPanel">180</sys:Double>
            <sys:Double x:Key="VerticalModeColorPickersPanel">40</sys:Double>
            <sys:Double x:Key="VerticalModeGrip">70</sys:Double>

            <sys:Double x:Key="HorizontalModeFlowPanel">430</sys:Double>
            <sys:Double x:Key="HorizontalModeColorPickersPanel">430</sys:Double>
            <sys:Double x:Key="HorizontalModeGrip">200</sys:Double>
            
            <ControlTemplate x:Key="SliderHorizontal" TargetType="{x:Type Slider}">
                <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
                    <Grid>
                        <Border x:Name="TrackBackground" Height="4.0" Margin="5,0" VerticalAlignment="center" Background="#FFB7B7B7" CornerRadius="1"/>
                        <Track x:Name="PART_Track">
                            <Track.Thumb>
                                <Thumb x:Name="Thumb" Focusable="False" Height="13" Foreground="{TemplateBinding Foreground}" OverridesDefaultStyle="True" VerticalAlignment="Center" Width="{Binding RelativeSource={RelativeSource Self},Path=Height}">
                                    <Thumb.Template>
                                        <ControlTemplate>
                                            <Grid>
                                                <Border CornerRadius="10" Background="#FF6B6B6B"/>
                                            </Grid>
                                        </ControlTemplate>
                                    </Thumb.Template>
                                </Thumb>
                            </Track.Thumb>
                        </Track>
                    </Grid>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard TargetName="Thumb" TargetProperty="Height">
                                    <DoubleAnimation Duration="{StaticResource Duration1}" To="16"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard TargetName="Thumb" TargetProperty="Height">
                                    <DoubleAnimation Duration="{StaticResource Duration3}" To="13"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style x:Key="ButtonContent" TargetType="{x:Type ContentPresenter}">
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="VerticalAlignment" Value="Center" />
            </Style>
            <Style x:Key="FunctionalButton" TargetType="LiveDraw:ActivableButton">
                <Setter Property="Background" Value="{StaticResource FunctionalButtonBackground}"/>
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="LiveDraw:ActivableButton">
                            <Grid Background="{StaticResource FakeTransparent}">
                                <Border Background="{TemplateBinding Background}" Margin="{StaticResource ElementMarginSmall}" CornerRadius="5">
                                    <ContentPresenter Style="{StaticResource ButtonContent}" Margin="{TemplateBinding Padding}"/>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource FunctionalButtonHoverColor}" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource FunctionalButtonBackgroundColor}" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                    <Trigger Property="IsActived" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource FunctionalButtonActiveColor}" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <ColorAnimation Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)" To="{StaticResource FunctionalButtonBackgroundColor}" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="ColorPicker" TargetType="LiveDraw:ColorPicker">
                <Setter Property="Cursor" Value="Pen"/>
                <Setter Property="Width" Value="{StaticResource ColorPickerSmall}"/>
                <Setter Property="Height" Value="{Binding RelativeSource={RelativeSource Self},Path=Width}"/>
                <Setter Property="Size" Value="Small"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="LiveDraw:ColorPicker">
                            <Grid Background="{StaticResource FakeTransparent}">
                                <Border x:Name="ControlBorder" Margin="{StaticResource ElementMarginMiddle}" Background="{TemplateBinding Background}" CornerRadius="{StaticResource ColorPickerNormalCorner}">
                                    <Path x:Name="CheckedIcon" Fill="White" Stretch="Uniform" Height="0" Data="{DynamicResource IconChecked}"/>
                                </Border>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard TargetName="ControlBorder" TargetProperty="CornerRadius">
                                                <LiveDraw:CornerRadiusAnimation Duration="{StaticResource Duration2}" To="{StaticResource ColorPickerHoverCorner}"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard TargetName="ControlBorder" TargetProperty="CornerRadius">
                                                <LiveDraw:CornerRadiusAnimation Duration="{StaticResource Duration4}" To="{StaticResource ColorPickerNormalCorner}"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                                <Trigger Property="IsActived" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard TargetName="CheckedIcon" TargetProperty="Height">
                                                <DoubleAnimation To="12" Duration="{StaticResource Duration1}"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard TargetName="CheckedIcon" TargetProperty="Height">
                                                <DoubleAnimation To="0" Duration="{StaticResource Duration3}"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <ControlTemplate x:Key="ResponseButtonTemplate" TargetType="Button">
                <Grid Background="{StaticResource FakeTransparent}">
                    <Border x:Name="Backborder" Background="{TemplateBinding Background}" CornerRadius="5" Width="0" Height="{Binding Path=Width,RelativeSource={RelativeSource Self}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    <ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="Button.IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="Backborder" Storyboard.TargetProperty="Width" From="0" To="20" Duration="{StaticResource Duration3}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="Backborder" Storyboard.TargetProperty="Width" From="20"  To="0" Duration="{StaticResource Duration3}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
            <Style x:Key="ResponseButton" TargetType="Button">
                <Setter Property="Width" Value="25"/>
                <Setter Property="Height" Value ="25"/>
                <Setter Property ="Template" Value="{StaticResource ResponseButtonTemplate}"/>
            </Style>
            <Style x:Key="SpinningButton" TargetType="Button" BasedOn="{StaticResource ResponseButton}">
                <Setter Property="MaxWidth" Value ="360"/>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard >
                                    <DoubleAnimation Storyboard.TargetProperty="MaxWidth" From="360" To="540" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetProperty="MaxWidth" From="360" To="540" Duration="{StaticResource Duration5}"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</Application>
