CPDFScalingUI.xaml 11 KB

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