MainWindow.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <Window x:Class="ComPDFKitDemo.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:ComPDFKitDemo"
  7. xmlns:toolbars="clr-namespace:ComPDFKitDemo.ToolBars"
  8. xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
  9. mc:Ignorable="d"
  10. Title="ComPDFKit.Demo" Height="600" Width="1024" WindowStartupLocation="CenterScreen" UseLayoutRounding="True">
  11. <Window.Resources>
  12. <ResourceDictionary>
  13. <ResourceDictionary.MergedDictionaries>
  14. <ResourceDictionary Source="Resources/StyleResource.xaml"/>
  15. </ResourceDictionary.MergedDictionaries>
  16. </ResourceDictionary>
  17. </Window.Resources>
  18. <Grid>
  19. <Grid.RowDefinitions>
  20. <RowDefinition Height="auto"></RowDefinition>
  21. <RowDefinition Height="auto"></RowDefinition>
  22. <RowDefinition Height="*"></RowDefinition>
  23. <RowDefinition Height="auto"></RowDefinition>
  24. </Grid.RowDefinitions>
  25. <ToolBarTray Grid.Row="0" Grid.ColumnSpan="2">
  26. <ToolBar Name="toolbar_header0" >
  27. <Button Click="btnCollapsed_Clicked" Name="btn_collapse" IsEnabled="False">
  28. <Image Source="Resources\section_expanded.png" Height="16"/>
  29. <ToolTipService.ToolTip>
  30. <ToolTip Placement="Bottom">
  31. <TextBlock Text="Hide Navigation Sidebar"/>
  32. </ToolTip>
  33. </ToolTipService.ToolTip>
  34. </Button>
  35. <Button Click="btnExpand_Clicked" Name="btn_expand" IsEnabled="True">
  36. <Image Source="Resources\section_collapsed.png" Height="16"/>
  37. <ToolTipService.ToolTip>
  38. <ToolTip Placement="Bottom">
  39. <TextBlock Text="Show Navigation Sidebar"/>
  40. </ToolTip>
  41. </ToolTipService.ToolTip>
  42. </Button>
  43. </ToolBar>
  44. <ToolBar Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Name="toolbar_header1" >
  45. <Button Click="btnOpen_Clicked">
  46. <Image Source="Resources\docOpen.png" Height="32"/>
  47. <ToolTipService.ToolTip>
  48. <ToolTip Placement="Bottom">
  49. <TextBlock Text="Open"/>
  50. </ToolTip>
  51. </ToolTipService.ToolTip>
  52. </Button>
  53. <Button Name="btn_save" Click="btnSave_Clicked" IsEnabled="True">
  54. <Image Source="Resources\saveas.png" Height="32"/>
  55. <ToolTipService.ToolTip>
  56. <ToolTip Placement="Bottom">
  57. <TextBlock Text="Save"/>
  58. </ToolTip>
  59. </ToolTipService.ToolTip>
  60. </Button>
  61. </ToolBar>
  62. <ToolBar Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Name="toolbar_header2">
  63. <ToggleButton Click="PanTool_Clicked" Name="PanTool">
  64. <Image Source="Resources\hand.png" Height="32"/>
  65. <ToolTipService.ToolTip>
  66. <ToolTip Placement="Bottom">
  67. <TextBlock Text="Pan Tool"/>
  68. </ToolTip>
  69. </ToolTipService.ToolTip>
  70. </ToggleButton>
  71. <ToggleButton Click="TextSelectTool_Clicked" Name="TextSelectTool">
  72. <Image Source="Resources\texttool.gif" Height="32"/>
  73. <ToolTipService.ToolTip>
  74. <ToolTip Placement="Bottom">
  75. <TextBlock Text="Select Text"/>
  76. </ToolTip>
  77. </ToolTipService.ToolTip>
  78. </ToggleButton>
  79. <ToggleButton Click="FormEditTool_Clicked" Name="FormEditTool">
  80. <Image Source="Resources\FormEdit.png" Height="32"/>
  81. <ToolTipService.ToolTip>
  82. <ToolTip Placement="Bottom">
  83. <TextBlock Text="Form Edit"/>
  84. </ToolTip>
  85. </ToolTipService.ToolTip>
  86. </ToggleButton>
  87. <ToggleButton Click="TextEditTool_Clicked" Name="TextEditTool" Height="40" Width="40">
  88. <Image Source="Resources\annot_edit.png" Height="20"/>
  89. <ToolTipService.ToolTip>
  90. <ToolTip Placement="Bottom">
  91. <TextBlock Text="Text Edit"/>
  92. </ToolTip>
  93. </ToolTipService.ToolTip>
  94. </ToggleButton>
  95. <ToggleButton Name="SelectTool" Visibility="Collapsed" Click="AnnotDemo_Click" Tag="SelectTool" ToolTip="Select Annots">
  96. <ToggleButton.Content>
  97. <Rectangle Width="25" Height="25" StrokeThickness="2" Stroke="Red" StrokeDashArray="2,2"></Rectangle>
  98. </ToggleButton.Content>
  99. </ToggleButton>
  100. <ToggleButton Name="SnapTool" Visibility="Collapsed" Click="AnnotDemo_Click" Tag="SnapTool" Margin="10,0,0,0" ToolTip="Snap">
  101. <ToggleButton.Content>
  102. <Rectangle Width="25" Height="25" StrokeThickness="2" Stroke="Blue" StrokeDashArray="2,2"></Rectangle>
  103. </ToggleButton.Content>
  104. </ToggleButton>
  105. <ToggleButton Name="SnapEditTool" Visibility="Collapsed" Click="AnnotDemo_Click" Tag="SnapEditTool" Margin="10,0,0,0" ToolTip="SnapEdit">
  106. <ToggleButton.Content>
  107. <Rectangle Width="25" Height="25" StrokeThickness="2" Stroke="Pink" StrokeDashArray="2,2"></Rectangle>
  108. </ToggleButton.Content>
  109. </ToggleButton>
  110. <ToggleButton Name="OtherTools" Tag="Other Tools" ToolTip="Other Tools" Click="OtherTools_Click">
  111. <ToggleButton.Content>
  112. <Image Source="Resources/menu.png" Width="30" Height="30"></Image>
  113. </ToggleButton.Content>
  114. </ToggleButton>
  115. </ToolBar>
  116. <toolbars:PdfToolBar>
  117. <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
  118. <Button Padding="15,5,15,5" Margin="5,0,0,0" Click="Redo_Click" Tag="Redo" Content="Redo" IsEnabled="{Binding CanRedo,Mode=OneWay}"/>
  119. <Button Padding="15,5,15,5" Margin="5,0,0,0" Click="Undo_Click" Tag="Undo" Content="Undo" IsEnabled="{Binding CanUndo,Mode=OneWay}"/>
  120. </StackPanel>
  121. </toolbars:PdfToolBar>
  122. <toolbars:PdfToolBar>
  123. <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
  124. <Button x:Name="EnterPageEdit" Padding="5" Margin="5" Click="EnterPageEdit_Click" >Enter Page Edit</Button>
  125. <Button x:Name="ExitPageEdit" Padding="5" Margin="5" Click="ExitPageEdit_Click">Exit Page Edit</Button>
  126. </StackPanel>
  127. </toolbars:PdfToolBar>
  128. </ToolBarTray>
  129. <Grid Grid.Row="1">
  130. <WrapPanel Orientation="Horizontal" HorizontalAlignment="Center" Name="AnnotTools" Visibility="Collapsed">
  131. <ToggleButton Padding="15,5,15,5" Click="AnnotDemo_Click" Tag="Square" Margin="5,5,5,0">
  132. <ToggleButton.Content>
  133. <Rectangle Width="20" Height="20" StrokeThickness="2" Stroke="Red"></Rectangle>
  134. </ToggleButton.Content>
  135. </ToggleButton>
  136. <ToggleButton Padding="15,5,15,5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Circle">
  137. <ToggleButton.Content>
  138. <Ellipse Width="20" Height="20" StrokeThickness="2" Stroke="Red"></Ellipse>
  139. </ToggleButton.Content>
  140. </ToggleButton>
  141. <ToggleButton Padding="15,5,15,5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Line">
  142. <ToggleButton.Content>
  143. <Line Stroke="Red" StrokeThickness="2" Width="20" Height="20" X1="0" Y1="9" X2="20" Y2="9"></Line>
  144. </ToggleButton.Content>
  145. </ToggleButton>
  146. <ToggleButton Padding="15,5,15,5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="LineArrow">
  147. <ToggleButton.Content>
  148. <Path Fill="Red" Stroke="Red" Width="20" Height="20">
  149. <Path.Data>
  150. <PathGeometry>
  151. <PathGeometry.Figures>
  152. <PathFigureCollection>
  153. <PathFigure StartPoint="0,9" >
  154. <LineSegment Point="20,9"></LineSegment>
  155. </PathFigure>
  156. <PathFigure StartPoint="20,9">
  157. <LineSegment Point="15,5"></LineSegment>
  158. </PathFigure>
  159. <PathFigure StartPoint="20,9">
  160. <LineSegment Point="15,13"></LineSegment>
  161. </PathFigure>
  162. </PathFigureCollection>
  163. </PathGeometry.Figures>
  164. </PathGeometry>
  165. </Path.Data>
  166. </Path>
  167. </ToggleButton.Content>
  168. </ToggleButton>
  169. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Ink" Content="Ink"/>
  170. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Erase" Content="Erase"/>
  171. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="FreeText" Content="FreeText"/>
  172. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Highlight" Content="Highlight"/>
  173. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Underline" Content="Underline"/>
  174. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Strikeout" Content="Strikeout"/>
  175. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Squiggly" Content="Squiggly"/>
  176. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="StickyNote" Content="StickyNote"/>
  177. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Picture" Content="Picture"/>
  178. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Stamp" Content="Stamp"/>
  179. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Sign" Content="Sign"/>
  180. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Link" Content="Link"/>
  181. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Tag="Audio" Content="Audio"/>
  182. </WrapPanel>
  183. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Name="FormTools" Visibility="Collapsed">
  184. <ToggleButton Name="FormTextBox" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="TextBox">TextBox</ToggleButton>
  185. <ToggleButton Name="FormCheckBox" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="CheckBox">CheckBox</ToggleButton>
  186. <ToggleButton Name="FormRadio" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="RadioBtn">RadioButton</ToggleButton>
  187. <ToggleButton Name="FormDropDown" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="DropDown">ComboBox</ToggleButton>
  188. <ToggleButton Name="FormList" Padding="10,5,10,5" Margin="5,0,5,0" Click="FormTools_Click" Tag="List">ListBox</ToggleButton>
  189. <ToggleButton Name="FormBtn" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="PushBtn">PushButton</ToggleButton>
  190. <ToggleButton Name="FormSign" Padding="5" Margin="5,0,5,0" Click="FormTools_Click" Tag="Sign">Sign</ToggleButton>
  191. </StackPanel>
  192. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Name="OtherToolsPanel" Visibility="Collapsed">
  193. <ToggleButton Name="FormHighlightBtn" Padding="5" Margin="5,5,5,0" Click="FormHighlightBtn_Click">Highlight Form</ToggleButton>
  194. <ToggleButton Name="PageOffset" Padding="5" Margin="5,5,5,0" IsChecked="True" Click="PageOffset_ClickEvent">Page Breaks</ToggleButton>
  195. <ToggleButton Padding="5" Margin="5,5,0,0" Click="CropButton_Click" Tag="Clip" Content="Crop Page"/>
  196. <ToggleButton Padding="5" Margin="5,5,0,0" Click="AutoCrop_Click" Tag="AutoClip" Content="Auto Crop"/>
  197. <ToggleButton Padding="5" Margin="5,5,0,0" Click="ShowLink_Click" Content="ShowLink" />
  198. <ToggleButton Name="RedactionBtn" Padding="5" Margin="5,5,0,0" Click="AnnotDemo_Click" Content="Mark for Redaction" Tag="Redaction"></ToggleButton>
  199. <ToggleButton x:Name="Encryption" Padding="5" Margin="5,5,0,0" Content="Encryption" Click="Encryption_Click"/>
  200. <Popup Name="EncryptionPopup" StaysOpen="False" PlacementTarget="{Binding ElementName=Encryption}" AllowsTransparency="True">
  201. <Grid Height="auto" Width="auto" HorizontalAlignment="Left">
  202. <Border BorderThickness="0" CornerRadius="3" Background="White" Margin="3">
  203. <Border.Effect>
  204. <DropShadowEffect ShadowDepth="0" Color="#FFB6B6B6"/>
  205. </Border.Effect>
  206. <StackPanel Margin="0">
  207. <MenuItem Header="SetPassword" Click="SetPassword_Click"></MenuItem>
  208. <MenuItem Header="RemovePassword" Click="RemovePassword_Click"></MenuItem>
  209. </StackPanel>
  210. </Border>
  211. </Grid>
  212. </Popup>
  213. </StackPanel>
  214. </Grid>
  215. <Grid Grid.Row="2" Name="PDFGrid" UseLayoutRounding="True">
  216. <dragablz:TabablzControl Name="PDFTab" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" BorderBrush="Silver"
  217. UseLayoutRounding="True" SelectionChanged="PDFTab_SelectionChanged" ClosingItemCallback="btnClose_Clicked">
  218. <dragablz:TabablzControl.InterTabController>
  219. <dragablz:InterTabController />
  220. </dragablz:TabablzControl.InterTabController>
  221. <dragablz:TabablzControl.ItemContainerStyle>
  222. <Style TargetType="dragablz:DragablzItem">
  223. <Setter Property="Template">
  224. <Setter.Value>
  225. <ControlTemplate TargetType="dragablz:DragablzItem">
  226. <Grid x:Name="templateRoot">
  227. <Grid.ColumnDefinitions>
  228. <ColumnDefinition Width="*"></ColumnDefinition>
  229. <ColumnDefinition Width="auto"></ColumnDefinition>
  230. </Grid.ColumnDefinitions>
  231. <Border x:Name="Title" Background="LightSkyBlue" BorderBrush="Silver" BorderThickness="1" CornerRadius="5,5,0,0">
  232. <Grid>
  233. <Grid.ColumnDefinitions>
  234. <ColumnDefinition Width="*"></ColumnDefinition>
  235. <ColumnDefinition Width="auto"></ColumnDefinition>
  236. </Grid.ColumnDefinitions>
  237. <TextBlock Name="TextBlock" Foreground="Black">
  238. <ContentPresenter x:Name="contentPresenter" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="{TemplateBinding ContentControl.Content}" Margin="6,2,6,2" />
  239. </TextBlock>
  240. <Thumb HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" x:Name="PART_Thumb" Background="Transparent">
  241. <Thumb.Template>
  242. <ControlTemplate>
  243. <Grid Background="Transparent"/>
  244. </ControlTemplate>
  245. </Thumb.Template>
  246. </Thumb>
  247. <Button Grid.Column="1" Command="{x:Static dragablz:TabablzControl.CloseItemCommand}"
  248. CommandParameter="{Binding RelativeSource={RelativeSource TemplatedParent}}">
  249. <Button.Template>
  250. <ControlTemplate>
  251. <Grid>
  252. <Ellipse Width="15" Height="15" Fill="{TemplateBinding Background}"/>
  253. <Path x:Name="Path" Data="M0.5,71 L70,0.5 M0.5,1 L70,70.5" Width="6" Height="6" Stretch="Uniform" Stroke="{TemplateBinding Foreground}"
  254. StrokeThickness="1.5" StrokeStartLineCap="Square" StrokeEndLineCap="Square" SnapsToDevicePixels="True" />
  255. </Grid>
  256. </ControlTemplate>
  257. </Button.Template>
  258. </Button>
  259. </Grid>
  260. </Border>
  261. </Grid>
  262. <ControlTemplate.Triggers>
  263. <Trigger Property="IsSelected" Value="True">
  264. <Setter TargetName="Title" Property="Background" Value="LightGray"/>
  265. <Setter TargetName="Title" Property="BorderThickness" Value="1,1,1,0"/>
  266. <Setter TargetName="TextBlock" Property="FontWeight" Value="Bold"/>
  267. </Trigger>
  268. <Trigger Property="IsSelected" Value="False">
  269. <Setter TargetName="Title" Property="Background" Value="LightSkyBlue"/>
  270. </Trigger>
  271. <Trigger Property="dragablz:TabablzControl.IsWrappingTabItem" Value="True">
  272. <Setter TargetName="contentPresenter" Property="Content" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.Header}" />
  273. </Trigger>
  274. </ControlTemplate.Triggers>
  275. </ControlTemplate>
  276. </Setter.Value>
  277. </Setter>
  278. </Style>
  279. </dragablz:TabablzControl.ItemContainerStyle>
  280. </dragablz:TabablzControl>
  281. </Grid>
  282. <Grid Grid.Row="3" Background="#EEF5FD">
  283. <Grid.ColumnDefinitions>
  284. <ColumnDefinition Width="1*"/>
  285. <ColumnDefinition Width="Auto"/>
  286. <ColumnDefinition Width="1*" />
  287. </Grid.ColumnDefinitions>
  288. <ToolBarTray x:Name="ToolbarBottom" Grid.Column="1" IsEnabled="False">
  289. <toolbars:PdfToolBarViewMode x:Name="ViewModelTool"></toolbars:PdfToolBarViewMode>
  290. <toolbars:PdfToolBarPages x:Name="PagesTool"></toolbars:PdfToolBarPages>
  291. <toolbars:PdfToolBarSizes x:Name="FitPageTool"></toolbars:PdfToolBarSizes>
  292. <toolbars:PdfToolBarZoom x:Name="ZoomTool"></toolbars:PdfToolBarZoom>
  293. </ToolBarTray>
  294. </Grid>
  295. </Grid>
  296. </Window>