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

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Button.xaml"/>
        <ResourceDictionary Source="TextBlock.xaml"/>
        <ResourceDictionary Source="Border.xaml"/>
        <ResourceDictionary Source="ToggleButton.xaml"/>
        <ResourceDictionary Source="../Basic/Converters.xaml"/>
        <ResourceDictionary Source="../Basic/Paths.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="controls:ImageViewer">
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="MinWidth" Value="400"/>
        <Setter Property="MinHeight" Value="250"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ImageViewer">
                    <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <controls:SimplePanel x:Name="PART_PanelMain" ClipToBounds="True" Grid.RowSpan="2">
                                <Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="{TemplateBinding ImageHeight}" Width="{TemplateBinding ImageWidth}" Margin="{TemplateBinding ImageMargin}">
                                    <Image Name="PART_ImageMain" RenderOptions.BitmapScalingMode="NearestNeighbor" RenderTransformOrigin="0.5,0.5" Source="{TemplateBinding ImageSource}"/>
                                </Border>
                            </controls:SimplePanel>
                            <Border Grid.Row="0" Grid.RowSpan="2" Width="252" Height="162" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="{DynamicResource DarkOpacityBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
                                <Border.Visibility>
                                    <MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowSmallImgInternal"/>
                                        <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowImgMap"/>
                                    </MultiBinding>
                                </Border.Visibility>
                                <Canvas ClipToBounds="True" Name="PART_CanvasSmallImg" MaxWidth="250" MaxHeight="160">
                                    <Border UseLayoutRounding="True" Name="PART_BorderMove" Background="Transparent" Width="50" Height="70" BorderThickness="1" BorderBrush="Black">
                                        <Border BorderThickness="1" BorderBrush="White"/>
                                    </Border>
                                </Canvas>
                            </Border>
                            <Border UseLayoutRounding="True" Name="PART_BorderBottom" Opacity="0" CornerRadius="4,4,0,0" Grid.Row="1" HorizontalAlignment="Center" Background="{DynamicResource DarkOpacityBrush}">
                                <StackPanel Margin="30,10" VerticalAlignment="Center" Orientation="Horizontal">
                                    <Button Command="interactivity:ControlCommands.Save" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource SaveGeometry}" Padding="3"/>
                                    <Button Command="interactivity:ControlCommands.Open" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource WindowsGeometry}" Padding="3"/>

                                    <Border Margin="10,2" Background="White" Style="{StaticResource BorderVerticallySplitter}"/>

                                    <Button Command="interactivity:ControlCommands.Reduce" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource ReduceGeometry}" Padding="3"/>
                                    <TextBlock Margin="6,0" Text="{TemplateBinding ScaleStr}" Style="{StaticResource TextBlockSubTitle}" Foreground="{DynamicResource TextIconBrush}"/>
                                    <Button Command="interactivity:ControlCommands.Enlarge" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource EnlargeGeometry}" Padding="3"/>
                                    <Button Command="interactivity:ControlCommands.Restore" Background="Transparent" Margin="6,0" Style="{StaticResource ButtonCustom}" Foreground="White">
                                        <Border BorderThickness="1" BorderBrush="White" Padding="2">
                                            <TextBlock Text="1:1"/>
                                        </Border>
                                    </Button>
                                    <Border Margin="10,2" Background="White" Style="{StaticResource BorderVerticallySplitter}"/>
                                    <Button Command="interactivity:ControlCommands.RotateLeft" CommandParameter="" Margin="6,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3"/>
                                    <Button Command="interactivity:ControlCommands.RotateRight" Margin="6,0,0,0" Style="{StaticResource ButtonIcon}" controls:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3" RenderTransformOrigin="0.5,0.5">
                                        <Button.RenderTransform>
                                            <TransformGroup>
                                                <ScaleTransform ScaleY="1" ScaleX="-1"/>
                                            </TransformGroup>
                                        </Button.RenderTransform>
                                    </Button>
                                    <ToggleButton Visibility="{TemplateBinding ShowFullScreenButton,Converter={StaticResource Boolean2VisibilityConverter}}" Foreground="{DynamicResource TextIconBrush}" IsChecked="{Binding IsFullScreen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" Margin="12,0,6,0" Style="{StaticResource ToggleButtonIconTransparent}" controls:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" controls:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>

                                </StackPanel>
                            </Border>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>