PreviewControl.xaml 7.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <UserControl x:Class="ComPDFKit.Controls.PDFControl.PreviewControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:ComPDFKit.Controls.PDFControl"
  7. xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
  8. mc:Ignorable="d"
  9. d:DesignHeight="449" d:DesignWidth="248" Loaded="UserControl_Loaded">
  10. <UserControl.Resources>
  11. <ResourceDictionary>
  12. <Style x:Key="TransparentButtonStyle" TargetType="{x:Type Button}">
  13. <Setter Property="BorderThickness" Value="0" />
  14. <Setter Property="Template">
  15. <Setter.Value>
  16. <ControlTemplate TargetType="Button">
  17. <Border Name="border">
  18. <ContentPresenter />
  19. </Border>
  20. <ControlTemplate.Triggers>
  21. <Trigger Property="IsMouseOver" Value="True">
  22. <Setter TargetName="border" Property="Background" Value="#1a000000" />
  23. </Trigger>
  24. <Trigger Property="IsPressed" Value="True">
  25. <Setter TargetName="border" Property="Background" Value="#5a000000" />
  26. </Trigger>
  27. </ControlTemplate.Triggers>
  28. </ControlTemplate>
  29. </Setter.Value>
  30. </Setter>
  31. </Style>
  32. <Style x:Key="PageButtonStyle" TargetType="{x:Type Button}">
  33. <Setter Property="BorderThickness" Value="0"></Setter>
  34. <Setter Property="Template">
  35. <Setter.Value>
  36. <ControlTemplate TargetType="Button">
  37. <Border Name="border" Background="#E1E1E1">
  38. <ContentPresenter />
  39. </Border>
  40. <ControlTemplate.Triggers>
  41. <Trigger Property="IsMouseOver" Value="True">
  42. <Setter TargetName="border" Property="Background" Value="#C1C1C1" />
  43. </Trigger>
  44. <Trigger Property="IsPressed" Value="True">
  45. <Setter TargetName="border" Property="Background" Value="#A1A1A1" />
  46. </Trigger>
  47. </ControlTemplate.Triggers>
  48. </ControlTemplate>
  49. </Setter.Value>
  50. </Setter>
  51. </Style>
  52. <common:CommonResourceConverter x:Key="CommonResourceConverter" />
  53. </ResourceDictionary>
  54. </UserControl.Resources>
  55. <Grid>
  56. <Grid.RowDefinitions>
  57. <RowDefinition Height="auto"></RowDefinition>
  58. <RowDefinition></RowDefinition>
  59. <RowDefinition Height="auto"></RowDefinition>
  60. </Grid.RowDefinitions>
  61. <Grid Margin="0,0,0,10">
  62. <TextBlock Text="{Binding Converter={StaticResource CommonResourceConverter},ConverterParameter=Title_Preview}" FontWeight="DemiBold" FontFamily="Microsoft YaHei" FontSize="14"></TextBlock>
  63. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
  64. <Button x:Name="ZoomInBtn" Height="20" Width="20" Style="{StaticResource TransparentButtonStyle}" Margin="0,0,10,0" Click="ScaleBtn_Click">
  65. <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="M0,6.5 C0,2.91015 2.91015,0 6.5,0 C10.0899,0 13,2.91015 13,6.5 C13,8.12212 12.4058,9.60545 11.4232,10.7442 L15.5,14.821 L14.821,15.5 L10.7442,11.4232 C9.60545,12.4058 8.12212,13 6.5,13 C2.91015,13 0,10.0899 0,6.5 Z M12,6.5 C12,3.46243 9.53757,1 6.5,1 C3.46243,1 1,3.46243 1,6.5 C1,9.53757 3.46243,12 6.5,12 C9.53757,12 12,9.53757 12,6.5 Z M10,6 V7 H3 V6 H10 Z"
  66. Fill="Black" />
  67. </Button>
  68. <Button x:Name="ZoomOutBtn" Height="20" Width="20" Style="{StaticResource TransparentButtonStyle}" Click="ScaleBtn_Click">
  69. <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="M6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.12212 13 9.60545 12.4058 10.7442 11.4232L14.821 15.5L15.5 14.821L11.4232 10.7442C12.4058 9.60545 13 8.12212 13 6.5C13 2.91015 10.0899 0 6.5 0ZM6.5 1C9.53757 1 12 3.46243 12 6.5C12 9.53757 9.53757 12 6.5 12C3.46243 12 1 9.53757 1 6.5C1 3.46243 3.46243 1 6.5 1ZM10 6H7V3H6V6H3V7H6V10H7V7H10V6Z"
  70. Fill="Black" />
  71. </Button>
  72. </StackPanel>
  73. </Grid>
  74. <Border Grid.Row="1" x:Name="ImageGd" Background="#1A000000" ClipToBounds="True" BorderThickness="1" BorderBrush="#000000">
  75. <ScrollViewer x:Name="ImageSv" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  76. <Image x:Name="Image" Source="{Binding ImageSource}" Stretch="None" MouseLeftButtonDown="Image_MouseLeftButtonDown" MouseLeftButtonUp="Image_MouseLeftButtonUp" MouseMove="Image_MouseMove">
  77. <Image.LayoutTransform>
  78. <ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}"></ScaleTransform>
  79. </Image.LayoutTransform>
  80. </Image>
  81. </ScrollViewer>
  82. </Border>
  83. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" Margin="0,8,0,0">
  84. <Button x:Name="PrePageBtn" Height="28" Width="28" Margin="0,0,16,0" Style="{StaticResource PageButtonStyle}" Click="PageBtn_Click">
  85. <Path Height="16" Width="16" Data="M11.2978 14L12 13.2733L6.90446 8L12 2.72673L11.2978 2L5.5 8L11.2978 14Z"
  86. Fill="Black" />
  87. </Button>
  88. <TextBox x:Name="CurrentIndexTxt" Text="{Binding CurrentIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="32" Width="48" Margin="0,0,8,0" PreviewTextInput="CurrentIndexTxt_PreviewTextInput" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" InputMethod.IsInputMethodEnabled="False" CommandManager.CanExecute="CurrentIndexTxt_CanExecute"></TextBox>
  89. <TextBlock Text="/" FontSize="14" VerticalAlignment="Center" FontFamily="Microsoft YaHei"></TextBlock>
  90. <TextBlock Text="{Binding PageCount}" Margin="5,0,0,0" FontSize="14" VerticalAlignment="Center" FontFamily="Microsoft YaHei"></TextBlock>
  91. <Button x:Name="NextPageBtn" Height="28" Width="28" Margin="16,0,0,0" Style="{StaticResource PageButtonStyle}" Click="PageBtn_Click">
  92. <Path Height="16" Width="16" Data="M6.20223 14L5.5 13.2733L10.5955 8L5.5 2.72673L6.20223 2L12 8L6.20223 14Z"
  93. Fill="Black" />
  94. </Button>
  95. </StackPanel>
  96. </Grid>
  97. </UserControl>