<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:hc="clr-namespace:HandyControl.Controls"
                    xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
                    xmlns:themes="clr-namespace:HandyControl.Themes">

    <ResourceDictionary.MergedDictionaries>
        <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Styles/Button.xaml"/>
        <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Basic/Converters.xaml"/>
        <themes:SharedResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Basic/Geometries.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <LinearGradientBrush x:Key="ResizeGripperForeground" EndPoint="1,0.75" StartPoint="0,0.25">
        <GradientStop Color="#FFFFFF" Offset="0.3"/>
        <GradientStop Color="#BBC5D7" Offset="0.75"/>
        <GradientStop Color="#6D83A9" Offset="1"/>
    </LinearGradientBrush>

    <Style TargetType="ResizeGrip">
        <Setter Property="MinWidth" Value="11"/>
        <Setter Property="MinHeight" Value="11"/>
        <Setter Property="Width" Value="11"/>
        <Setter Property="Height" Value="11"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ResizeGrip">
                    <hc:SimplePanel Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                        <Path Width="11" Height="11" Data="M 9,0 L 11,0 L 11,11 L 0,11 L 0,9 L 3,9 L 3,6 L 6,6 L 6,3 L 9,3 z" HorizontalAlignment="Right" VerticalAlignment="Bottom">
                            <Path.Fill>
                                <DrawingBrush TileMode="Tile" Viewbox="0,0,3,3" Viewport="0,0,3,3" ViewportUnits="Absolute" ViewboxUnits="Absolute">
                                    <DrawingBrush.Drawing>
                                        <DrawingGroup>
                                            <GeometryDrawing Brush="{StaticResource ResizeGripperForeground}">
                                                <GeometryDrawing.Geometry>
                                                    <RectangleGeometry Rect="0,0,2,2"/>
                                                </GeometryDrawing.Geometry>
                                            </GeometryDrawing>
                                        </DrawingGroup>
                                    </DrawingBrush.Drawing>
                                </DrawingBrush>
                            </Path.Fill>
                        </Path>
                    </hc:SimplePanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="Window">
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
    </Style>

    <Style x:Key="WindowWin10" TargetType="hc:Window">
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="#262e2f"/>
        <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="UseLayoutRounding" Value="True"/>
        <Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
        <Setter Property="NonClientAreaForeground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="CloseButtonBackground" Value="Transparent"/>
        <Setter Property="CloseButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="CloseButtonHoverBackground" Value="#e81123"/>
        <Setter Property="CloseButtonHoverForeground" Value="White"/>
        <Setter Property="OtherButtonBackground" Value="Transparent"/>
        <Setter Property="OtherButtonForeground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="OtherButtonHoverBackground" Value="{DynamicResource DarkMaskBrush}"/>
        <Setter Property="OtherButtonHoverForeground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="hc:Window">
                    <Border SnapsToDevicePixels="True" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <Grid Margin="{TemplateBinding Padding}">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Grid Background="{TemplateBinding NonClientAreaBackground}" Name="PART_NonClientArea" TextElement.Foreground="{TemplateBinding NonClientAreaForeground}">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <StackPanel Name="ButtonPanel" WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
                                    <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" Name="ButtonMin" Height="29" Style="{StaticResource ButtonIcon}" Width="45" hc:IconElement.Geometry="{StaticResource WindowMinGeometry}" BorderThickness="1,0,1,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
                                    <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" Name="ButtonMax" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource WindowMaxGeometry}" BorderThickness="1,0,1,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
                                    <Button Background="{TemplateBinding OtherButtonBackground}" Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" Name="ButtonRestore" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" BorderThickness="1,0,1,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
                                    <Button Background="{TemplateBinding CloseButtonBackground}" Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" Name="ButtonClose" Height="29" Style="{StaticResource ButtonIcon}" Width="46" hc:IconElement.Geometry="{StaticResource CloseGeometry}" BorderThickness="1,0,0,0" hc:IconElement.Width="10" hc:IconElement.Height="10"/>
                                </StackPanel>
                                <Grid Grid.Column="0">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Button Name="ButtonIcon" Visibility="{TemplateBinding Icon,Converter={StaticResource Object2VisibilityConverter}}" Command="{x:Static SystemCommands.ShowSystemMenuCommand}" Background="Transparent" Margin="10,0,0,0" WindowChrome.IsHitTestVisibleInChrome="True" Style="{StaticResource ButtonCustom}" VerticalAlignment="Center">
                                        <interactivity:Interaction.Triggers>
                                            <interactivity:EventTrigger EventName="MouseDoubleClick">
                                                <interactivity:InvokeCommandAction Command="{x:Static SystemCommands.CloseWindowCommand}" />
                                            </interactivity:EventTrigger>
                                        </interactivity:Interaction.Triggers>
                                        <Image IsHitTestVisible="False" Source="{TemplateBinding Icon}" VerticalAlignment="Center" Width="16" Height="16"/>
                                    </Button>
                                    <TextBlock Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center">
                                        <TextBlock.Visibility>
                                            <MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
                                                <MultiBinding.Bindings>
                                                    <Binding Path="ShowTitle" RelativeSource="{RelativeSource TemplatedParent}"/>
                                                    <Binding Path="Title" RelativeSource="{RelativeSource TemplatedParent}" Converter="{StaticResource Object2BooleanConverter}"/>
                                                </MultiBinding.Bindings>
                                            </MultiBinding>
                                        </TextBlock.Visibility>
                                    </TextBlock>
                                    <ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
                                </Grid>
                            </Grid>
                            <AdornerDecorator Grid.Row="1">
                                <ContentPresenter ClipToBounds="True"/>
                            </AdornerDecorator>
                            <ResizeGrip Width="10" Height="10" x:Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="1" IsTabStop="False" Visibility="Collapsed" WindowChrome.ResizeGripDirection="BottomRight" />
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsActive" Value="False">
                            <Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
                            <Setter Property="Opacity" Value=".8" TargetName="ButtonPanel"/>
                        </Trigger>
                        <Trigger Property="WindowState" Value="Maximized">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
                            <Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
                        </Trigger>
                        <Trigger Property="WindowState" Value="Normal">
                            <Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="NoResize">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
                        </Trigger>
                        <Trigger Property="ResizeMode" Value="CanMinimize">
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
                            <Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
                            <Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
                            <Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
                            <Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
                            <Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBackground,RelativeSource={RelativeSource TemplatedParent}}"/>
                            <Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource TemplatedParent}}"/>
                        </Trigger>
                        <Trigger Property="WindowStyle" Value="None">
                            <Setter Property="ShowNonClientArea" Value="False"/>
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
                                <Condition Property="WindowState" Value="Normal" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="WindowBlur" BasedOn="{StaticResource WindowWin10}" TargetType="hc:BlurWindow">
        <Setter Property="Background" Value="Transparent"/>
    </Style>

    <Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="hc:GlowWindow">
        <Setter Property="ActiveGlowColor" Value="#262e2f"/>
        <Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
        <Setter Property="BorderThickness" Value="0"/>
    </Style>

    <Style TargetType="hc:ImageBrowser">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="MinHeight" Value="250"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="Black"/>
        <Setter Property="ResizeMode" Value="NoResize"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="hc:ImageBrowser">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="Storyboard1">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_PanelTop">
                                <EasingDoubleKeyFrame KeyTime="0:0:.1" Value="1"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="Storyboard2">
                            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_PanelTop">
                                <EasingDoubleKeyFrame KeyTime="0:0:.4" Value="0"/>
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <hc:ImageViewer x:Name="PART_ImageViewer" ShowImgMap="True" BorderThickness="0" Background="#dd000000"/>
                        <hc:SimplePanel x:Name="PART_PanelTop" Opacity="0" Background="{DynamicResource DarkOpacityBrush}" VerticalAlignment="Top" Grid.Row="0">
                            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
                                <TextBlock Text="{Binding ImgPath,ElementName=PART_ImageViewer}" Foreground="White" Margin="10,0,0,0"/>
                                <TextBlock Text="{Binding ImgSize,ElementName=PART_ImageViewer,Converter={StaticResource Long2FileSizeConverter}}" Foreground="White" Margin="30,0,0,0"/>
                            </StackPanel>
                            <Button Command="interactivity:ControlCommands.Close" WindowChrome.IsHitTestVisibleInChrome="True" Background="Red" Padding="14" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"/>
                        </hc:SimplePanel>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="PART_ImageViewer" Property="ShowCloseButton" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsFullScreen" Value="True">
                <Setter Property="WindowState" Value="Maximized"/>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>
