ImageViewer.xaml 6.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls"
  4. xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
  5. <Style TargetType="hc:ImageViewer">
  6. <Setter Property="Focusable" Value="False"/>
  7. <Setter Property="Background" Value="Transparent"/>
  8. <Setter Property="BorderThickness" Value="1"/>
  9. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="hc:ImageViewer">
  13. <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
  14. <Grid>
  15. <Grid.RowDefinitions>
  16. <RowDefinition/>
  17. <RowDefinition Height="Auto"/>
  18. </Grid.RowDefinitions>
  19. <hc:SimplePanel x:Name="PART_PanelMain" ClipToBounds="True" Grid.RowSpan="2">
  20. <Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="{TemplateBinding ImageHeight}" Width="{TemplateBinding ImageWidth}" Margin="{TemplateBinding ImageMargin}">
  21. <Image Name="PART_ImageMain" RenderOptions.BitmapScalingMode="NearestNeighbor" RenderTransformOrigin="0.5,0.5" Source="{TemplateBinding ImageSource}"/>
  22. </Border>
  23. </hc:SimplePanel>
  24. <Border Grid.Row="0" Grid.RowSpan="2" Width="252" Height="162" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="{DynamicResource DarkOpacityBrush}" BorderBrush="{DynamicResource BorderBrush}" BorderThickness="1">
  25. <Border.Visibility>
  26. <MultiBinding Converter="{StaticResource BooleanArr2VisibilityConverter}">
  27. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowSmallImgInternal"/>
  28. <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ShowImgMap"/>
  29. </MultiBinding>
  30. </Border.Visibility>
  31. <Canvas ClipToBounds="True" Name="PART_CanvasSmallImg" MaxWidth="250" MaxHeight="160">
  32. <Border UseLayoutRounding="True" Name="PART_BorderMove" Background="Transparent" Width="50" Height="70" BorderThickness="1" BorderBrush="Black">
  33. <Border BorderThickness="1" BorderBrush="White"/>
  34. </Border>
  35. </Canvas>
  36. </Border>
  37. <Border UseLayoutRounding="True" Name="PART_BorderBottom" Visibility="{TemplateBinding ShowToolBar, Converter={StaticResource Boolean2VisibilityConverter}}" Opacity="0" CornerRadius="4,4,0,0" Grid.Row="1" HorizontalAlignment="Center" Background="{DynamicResource DarkOpacityBrush}">
  38. <StackPanel Margin="30,10" VerticalAlignment="Center" Orientation="Horizontal">
  39. <Button Command="interactivity:ControlCommands.Save" Margin="6,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource SaveGeometry}" Padding="3"/>
  40. <Button Command="interactivity:ControlCommands.Open" Margin="6,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource WindowsGeometry}" Padding="3"/>
  41. <Border Margin="10,2" Background="White" Style="{StaticResource BorderVerticallySplitter}"/>
  42. <Button Command="interactivity:ControlCommands.Reduce" Margin="6,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource ReduceGeometry}" Padding="3"/>
  43. <TextBlock Margin="6,0" Text="{TemplateBinding ScaleStr}" Style="{StaticResource TextBlockSubTitle}" Foreground="{DynamicResource TextIconBrush}"/>
  44. <Button Command="interactivity:ControlCommands.Enlarge" Margin="6,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource EnlargeGeometry}" Padding="3"/>
  45. <Button Command="interactivity:ControlCommands.Restore" Background="Transparent" Margin="6,0" Style="{StaticResource ButtonCustom}" Foreground="{DynamicResource TextIconBrush}">
  46. <Border BorderThickness="1" BorderBrush="White" Padding="2">
  47. <TextBlock Text="1:1"/>
  48. </Border>
  49. </Button>
  50. <Border Margin="10,2" Background="White" Style="{StaticResource BorderVerticallySplitter}"/>
  51. <Button Command="interactivity:ControlCommands.RotateLeft" CommandParameter="" Margin="6,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource RotateLeftGeometry}" Padding="3"/>
  52. <Button Command="interactivity:ControlCommands.RotateRight" Margin="6,0,0,0" Foreground="{DynamicResource TextIconBrush}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource RotateRightGeometry}" Padding="3"/>
  53. <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}" hc:IconSwitchElement.Geometry="{StaticResource FullScreenGeometry}" hc:IconSwitchElement.GeometrySelected="{StaticResource FullScreenReturnGeometry}" Padding="3"/>
  54. </StackPanel>
  55. </Border>
  56. </Grid>
  57. </Border>
  58. </ControlTemplate>
  59. </Setter.Value>
  60. </Setter>
  61. </Style>
  62. </ResourceDictionary>