PreviewControl.xaml 6.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <UserControl x:Class="Compdfkit_Tools.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_Tools.PDFControl"
  7. mc:Ignorable="d"
  8. d:DesignHeight="449" d:DesignWidth="248" Loaded="UserControl_Loaded">
  9. <UserControl.Resources>
  10. <ResourceDictionary>
  11. <Style x:Key="TransparentButtonStyle" TargetType="{x:Type Button}">
  12. <Setter Property="BorderThickness" Value="0" />
  13. <Setter Property="Template">
  14. <Setter.Value>
  15. <ControlTemplate TargetType="Button">
  16. <Border Name="border">
  17. <ContentPresenter />
  18. </Border>
  19. <ControlTemplate.Triggers>
  20. <Trigger Property="IsMouseOver" Value="True">
  21. <Setter TargetName="border" Property="Background" Value="#1a000000" />
  22. </Trigger>
  23. <Trigger Property="IsPressed" Value="True">
  24. <Setter TargetName="border" Property="Background" Value="#5a000000" />
  25. </Trigger>
  26. </ControlTemplate.Triggers>
  27. </ControlTemplate>
  28. </Setter.Value>
  29. </Setter>
  30. </Style>
  31. <Style x:Key="PageButtonStyle" TargetType="{x:Type Button}">
  32. <Setter Property="BorderThickness" Value="0"></Setter>
  33. <Setter Property="Template">
  34. <Setter.Value>
  35. <ControlTemplate TargetType="Button">
  36. <Border Name="border" Background="#E1E1E1">
  37. <ContentPresenter />
  38. </Border>
  39. <ControlTemplate.Triggers>
  40. <Trigger Property="IsMouseOver" Value="True">
  41. <Setter TargetName="border" Property="Background" Value="#C1C1C1" />
  42. </Trigger>
  43. <Trigger Property="IsPressed" Value="True">
  44. <Setter TargetName="border" Property="Background" Value="#A1A1A1" />
  45. </Trigger>
  46. </ControlTemplate.Triggers>
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. </Style>
  51. </ResourceDictionary>
  52. </UserControl.Resources>
  53. <Grid>
  54. <Grid.RowDefinitions>
  55. <RowDefinition Height="auto"></RowDefinition>
  56. <RowDefinition></RowDefinition>
  57. <RowDefinition Height="auto"></RowDefinition>
  58. </Grid.RowDefinitions>
  59. <Grid Margin="0,0,0,10">
  60. <TextBlock Text="Preview" FontWeight="DemiBold" FontFamily="Segoe UI" FontSize="14"></TextBlock>
  61. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
  62. <Button x:Name="ZoomInBtn" Height="20" Width="20" Style="{StaticResource TransparentButtonStyle}" Margin="0,0,10,0" Click="ScaleBtn_Click">
  63. <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"
  64. Fill="Black" />
  65. </Button>
  66. <Button x:Name="ZoomOutBtn" Height="20" Width="20" Style="{StaticResource TransparentButtonStyle}" Click="ScaleBtn_Click">
  67. <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"
  68. Fill="Black" />
  69. </Button>
  70. </StackPanel>
  71. </Grid>
  72. <Border Grid.Row="1" x:Name="ImageGd" Background="#1A000000" ClipToBounds="True" BorderThickness="1" BorderBrush="#000000">
  73. <ScrollViewer x:Name="ImageSv" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  74. <Image x:Name="Image" Source="{Binding ImageSource}" Stretch="None" MouseLeftButtonDown="Image_MouseLeftButtonDown" MouseLeftButtonUp="Image_MouseLeftButtonUp" MouseMove="Image_MouseMove">
  75. <Image.LayoutTransform>
  76. <ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}"></ScaleTransform>
  77. </Image.LayoutTransform>
  78. </Image>
  79. </ScrollViewer>
  80. </Border>
  81. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" Margin="0,8,0,0">
  82. <Button x:Name="PrePageBtn" Height="28" Width="28" Margin="0,0,16,0" Style="{StaticResource PageButtonStyle}" Click="PageBtn_Click">
  83. <Path Height="16" Width="16" Data="M11.2978 14L12 13.2733L6.90446 8L12 2.72673L11.2978 2L5.5 8L11.2978 14Z"
  84. Fill="Black" />
  85. </Button>
  86. <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>
  87. <TextBlock Text="/" FontSize="14" VerticalAlignment="Center" FontFamily="Segoe UI"></TextBlock>
  88. <TextBlock Text="{Binding PageCount}" Margin="5,0,0,0" FontSize="14" VerticalAlignment="Center" FontFamily="Segoe UI"></TextBlock>
  89. <Button x:Name="NextPageBtn" Height="28" Width="28" Margin="16,0,0,0" Style="{StaticResource PageButtonStyle}" Click="PageBtn_Click">
  90. <Path Height="16" Width="16" Data="M6.20223 14L5.5 13.2733L10.5955 8L5.5 2.72673L6.20223 2L12 8L6.20223 14Z"
  91. Fill="Black" />
  92. </Button>
  93. </StackPanel>
  94. </Grid>
  95. </UserControl>