CPDFScalingUI.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <UserControl x:Class="ComPDFKit.Controls.PDFControlUI.CPDFScalingUI"
  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:cpdfcommon="clr-namespace:ComPDFKit.Controls.Common"
  7. mc:Ignorable="d"
  8. d:DesignHeight="30" d:DesignWidth="162">
  9. <UserControl.Resources>
  10. <ResourceDictionary>
  11. <ResourceDictionary.MergedDictionaries>
  12. <ResourceDictionary Source="../../../Asset/Styles/ToggleButtonStyle.xaml"></ResourceDictionary>
  13. <ResourceDictionary Source="../../../Asset/Styles/ButtonStyle.xaml"></ResourceDictionary>
  14. </ResourceDictionary.MergedDictionaries>
  15. <cpdfcommon:CommonResourceConverter x:Key="CommonResourceConverter"></cpdfcommon:CommonResourceConverter>
  16. <SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
  17. <SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
  18. <SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
  19. <Style x:Key="LimitedNumberBoxWithUnit" TargetType="{x:Type TextBox}">
  20. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
  21. <Setter Property="BorderBrush" Value="Transparent"/>
  22. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  23. <Setter Property="BorderThickness" Value="1"/>
  24. <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
  25. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  26. <Setter Property="VerticalContentAlignment" Value="Center"/>
  27. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  28. <Setter Property="AllowDrop" Value="true"/>
  29. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  30. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  31. <Setter Property="Template">
  32. <Setter.Value>
  33. <ControlTemplate TargetType="{x:Type TextBox}">
  34. <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
  35. <Grid>
  36. <Grid.ColumnDefinitions>
  37. <ColumnDefinition Width="*"/>
  38. <ColumnDefinition Width="11"/>
  39. </Grid.ColumnDefinitions>
  40. <ScrollViewer Grid.Column="0" x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Margin="5,0,0,0"/>
  41. <TextBlock Grid.Column="1" Text="%" HorizontalAlignment="Right" VerticalAlignment="Center"/>
  42. </Grid>
  43. </Border>
  44. </ControlTemplate>
  45. </Setter.Value>
  46. </Setter>
  47. </Style>
  48. <Style x:Key="TransparentToggleButton" TargetType="{x:Type ToggleButton}">
  49. <Setter Property="Background" Value="Transparent"/>
  50. <Setter Property="BorderBrush" Value="Transparent"/>
  51. <Setter Property="Template">
  52. <Setter.Value>
  53. <ControlTemplate TargetType="{x:Type ToggleButton}">
  54. <Border x:Name="border"
  55. Background="{TemplateBinding Background}"
  56. BorderBrush="{TemplateBinding BorderBrush}"
  57. BorderThickness="{TemplateBinding BorderThickness}"
  58. Padding="{TemplateBinding Padding}">
  59. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  60. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  61. RecognizesAccessKey="True"/>
  62. </Border>
  63. <ControlTemplate.Triggers>
  64. <Trigger Property="IsChecked" Value="True">
  65. <Setter TargetName="border" Property="Opacity" Value="0"/>
  66. </Trigger>
  67. <Trigger Property="IsMouseOver" Value="True">
  68. <Setter TargetName="border" Property="Opacity" Value="0"/>
  69. </Trigger>
  70. <Trigger Property="IsPressed" Value="True">
  71. <Setter TargetName="border" Property="Opacity" Value="0"/>
  72. </Trigger>
  73. </ControlTemplate.Triggers>
  74. </ControlTemplate>
  75. </Setter.Value>
  76. </Setter>
  77. </Style>
  78. <Style x:Key="PresetComboBox" TargetType="{x:Type ComboBox}">
  79. <Setter Property="Template">
  80. <Setter.Value>
  81. <ControlTemplate TargetType="{x:Type ComboBox}">
  82. <Border x:Name="border" BorderBrush="{StaticResource TextBox.Static.Border}" BorderThickness="1" Background="#FFFFFF">
  83. <Grid>
  84. <Grid.ColumnDefinitions>
  85. <ColumnDefinition></ColumnDefinition>
  86. <ColumnDefinition Width="15"></ColumnDefinition>
  87. </Grid.ColumnDefinitions>
  88. <Grid Grid.Column="1">
  89. <Path Fill="#CDCDCD" Stroke="#CDCDCD" Grid.Column="1" Height="4.8" Width="7.38" Stretch="Fill">
  90. <Path.Data>
  91. M0.5 0.510248L4.5041 5.5L8.5 0.5L0.5 0.510248Z
  92. </Path.Data>
  93. </Path>
  94. </Grid>
  95. <Grid Grid.Column="0" Grid.ColumnSpan="2">
  96. <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
  97. ClickMode="Press" Style="{StaticResource TransparentToggleButton}"></ToggleButton>
  98. <Popup Name="popup"
  99. IsOpen="{TemplateBinding IsDropDownOpen}"
  100. Placement="Bottom" AllowsTransparency="True" PopupAnimation="Fade" VerticalOffset="1">
  101. <Border MinWidth="{TemplateBinding ActualWidth}"
  102. MaxHeight="{TemplateBinding MaxDropDownHeight}">
  103. <ScrollViewer MaxHeight="{TemplateBinding MaxDropDownHeight}"
  104. HorizontalScrollBarVisibility="Auto"
  105. VerticalScrollBarVisibility="Auto">
  106. <Border BorderBrush ="LightGray" BorderThickness="1">
  107. <StackPanel Background="#FFFFFF" MinHeight="20"
  108. IsItemsHost="True"/>
  109. </Border>
  110. </ScrollViewer>
  111. </Border>
  112. </Popup>
  113. </Grid>
  114. </Grid>
  115. </Border>
  116. <ControlTemplate.Triggers>
  117. <Trigger Property="IsMouseOver" Value="true">
  118. <Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
  119. </Trigger>
  120. </ControlTemplate.Triggers>
  121. </ControlTemplate>
  122. </Setter.Value>
  123. </Setter>
  124. </Style>
  125. </ResourceDictionary>
  126. </UserControl.Resources>
  127. <Grid Height="30" Width="160" HorizontalAlignment="Left">
  128. <Grid.ColumnDefinitions>
  129. <ColumnDefinition Width="72"></ColumnDefinition>
  130. <ColumnDefinition Width="*"></ColumnDefinition>
  131. </Grid.ColumnDefinitions>
  132. <Grid>
  133. <Grid.ColumnDefinitions>
  134. <ColumnDefinition Width="1*"></ColumnDefinition>
  135. <ColumnDefinition Width="20"></ColumnDefinition>
  136. </Grid.ColumnDefinitions>
  137. <ComboBox Grid.ColumnSpan="2" x:Name="ZoomComboBox" Background="#FFFFFF" Style="{StaticResource PresetComboBox}" SelectionChanged="ZoomComboBox_SelectionChanged" ></ComboBox>
  138. <TextBox x:Name="ZoomTextBox" Style="{StaticResource LimitedNumberBoxWithUnit}" HorizontalContentAlignment="Center" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="TextBox_PreviewTextInput" PreviewKeyDown="TextBox_PreviewKeyDown" TextChanged="TextBox_TextChanged" LostFocus="ZoomTextBox_LostFocus">
  139. </TextBox>
  140. </Grid>
  141. <StackPanel Grid.Column="1" Orientation="Horizontal" >
  142. <Button x:Name="ScaleDecreaseButton" ToolTip="{Binding Converter={StaticResource CommonResourceConverter},ConverterParameter=Tooltip_ZoomOut}"
  143. Style="{StaticResource LightButtonStyle}" Height="30" Width="30" Margin="20,0,0,0" Background="Transparent" BorderThickness="0" Click="ScaleDecreaseButton_Click">
  144. <Button.Content>
  145. <Rectangle Width="12" Height="2" Fill="#0E1114"></Rectangle>
  146. </Button.Content>
  147. </Button>
  148. <Button x:Name="ScaleIncreaseButton" ToolTip="{Binding Converter={StaticResource CommonResourceConverter},ConverterParameter=Tooltip_ZoomIn}"
  149. Style="{StaticResource LightButtonStyle}" Height="30" Width="30" BorderThickness="0" Background="Transparent" Margin="10,0,0,0" Click="ScaleIncreaseButton_Click">
  150. <Button.Content>
  151. <Path Fill="#0E1114">
  152. <Path.Data>
  153. M7.625 6.375V0.75H6.375V6.375H0.75V7.625H6.375V13.25H7.625V7.625H13.25V6.375H7.625Z
  154. </Path.Data>
  155. </Path>
  156. </Button.Content>
  157. </Button>
  158. </StackPanel>
  159. </Grid>
  160. </UserControl>