MainWindow.xaml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <Window x:Class="PDFViewer.MainWindow"
  2. x:Name="Window"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:local="clr-namespace:PDFViewer"
  8. mc:Ignorable="d"
  9. AllowDrop="True"
  10. Style="{DynamicResource WindowStyle}"
  11. BorderBrush="#0079cb"
  12. xmlns:cpdfcommon="clr-namespace:ComPDFKit.Controls.Common;assembly=ComPDFKit.Controls"
  13. xmlns:cpdftools="clr-namespace:ComPDFKit.Controls.PDFControl;assembly=ComPDFKit.Controls"
  14. xmlns:dragablz="clr-namespace:Dragablz;assembly=Dragablz"
  15. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  16. BorderThickness="{Binding RelativeSource={RelativeSource Mode=Self},Path=WindowState,Converter={StaticResource WindowStateToThicknessConverter}}"
  17. Title="{Binding AppInfo}" Height="720" Width="1200" MinWidth="780">
  18. <Window.Resources>
  19. <cpdfcommon:HomePageHeightConverter x:Key="HomePageHeightConverter"></cpdfcommon:HomePageHeightConverter>
  20. <cpdfcommon:HeightToTopMarginConverter x:Key="HeightToTopMarginConverter"></cpdfcommon:HeightToTopMarginConverter>
  21. <cpdfcommon:BoolToVisibleConverter x:Key="BoolToVisibleConverter"></cpdfcommon:BoolToVisibleConverter>
  22. <cpdfcommon:BoolToColorConverter x:Key="BoolToColorConverter"></cpdfcommon:BoolToColorConverter>
  23. <Style x:Key="WindowStyle" TargetType="{x:Type Window}">
  24. <Setter Property="WindowChrome.WindowChrome">
  25. <Setter.Value>
  26. <WindowChrome
  27. CaptionHeight="32"
  28. CornerRadius="0"
  29. GlassFrameThickness="0"
  30. ResizeBorderThickness="5"
  31. UseAeroCaptionButtons="False" />
  32. </Setter.Value>
  33. </Setter>
  34. <Setter Property="Template">
  35. <Setter.Value>
  36. <ControlTemplate TargetType="{x:Type Window}">
  37. <Border
  38. Background="{TemplateBinding Background}"
  39. BorderBrush="{TemplateBinding BorderBrush}"
  40. BorderThickness="{TemplateBinding BorderThickness}">
  41. <AdornerDecorator>
  42. <ContentPresenter x:Name="win_content" />
  43. </AdornerDecorator>
  44. </Border>
  45. </ControlTemplate>
  46. </Setter.Value>
  47. </Setter>
  48. </Style>
  49. <ControlTemplate x:Key="CloseFileButton" TargetType="{x:Type ButtonBase}">
  50. <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
  51. BorderBrush="{TemplateBinding Border.BorderBrush}"
  52. Background="{TemplateBinding Panel.Background}"
  53. Name="border"
  54. CornerRadius="15"
  55. SnapsToDevicePixels="True">
  56. <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#777777">
  57. <Path.RenderTransform>
  58. <TransformGroup>
  59. <TranslateTransform X="8" Y="-8"/>
  60. <RotateTransform Angle="45"/>
  61. <TranslateTransform X="-4" Y="-5"/>
  62. </TransformGroup>
  63. </Path.RenderTransform>
  64. <Path.Data>
  65. M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814
  66. L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
  67. </Path.Data>
  68. </Path>
  69. </Border>
  70. <ControlTemplate.Triggers>
  71. <Trigger Property="Button.IsDefaulted" Value="True">
  72. <Setter Property="Path.Fill" TargetName="content" Value="#777777" />
  73. </Trigger>
  74. <Trigger Property="UIElement.IsMouseOver" Value="True">
  75. <Setter Property="Path.Fill" TargetName="content" Value="#efefef" />
  76. <Setter Property="Background" TargetName="border" Value="#8f000000" />
  77. </Trigger>
  78. <Trigger Property="ButtonBase.IsPressed" Value="True">
  79. <Setter Property="Path.Fill" TargetName="content" Value="#000000" />
  80. </Trigger>
  81. </ControlTemplate.Triggers>
  82. </ControlTemplate>
  83. <ControlTemplate x:Key="AddFileButton" TargetType="{x:Type ButtonBase}">
  84. <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
  85. BorderBrush="{TemplateBinding Border.BorderBrush}"
  86. Background="{TemplateBinding Panel.Background}"
  87. Name="border"
  88. CornerRadius="15"
  89. SnapsToDevicePixels="True">
  90. <Path Name="content" VerticalAlignment="Center" HorizontalAlignment="Center" Fill="#FFFFFF">
  91. <Path.RenderTransform>
  92. <TransformGroup>
  93. <TranslateTransform X="-1.5" Y="-1"/>
  94. </TransformGroup>
  95. </Path.RenderTransform>
  96. <Path.Data>
  97. M9.48528137,2.98528137 L9.48428137,8.48428137 L14.9852814,8.48528137 L14.9852814,9.48528137 L9.48428137,9.48428137 L9.48528137,14.9852814 L8.48528137,14.9852814
  98. L8.48428137,9.48428137 L2.98528137,9.48528137 L2.98528137,8.48528137 L8.48428137,8.48428137 L8.48528137,2.98528137 L9.48528137,2.98528137 Z
  99. </Path.Data>
  100. </Path>
  101. </Border>
  102. <ControlTemplate.Triggers>
  103. <Trigger Property="Button.IsDefaulted" Value="True">
  104. <Setter Property="Path.Fill" TargetName="content" Value="#666666" />
  105. </Trigger>
  106. <Trigger Property="UIElement.IsMouseOver" Value="True">
  107. <Setter Property="BorderBrush" TargetName="border" Value="#5affffff" />
  108. <Setter Property="BorderThickness" TargetName="border" Value="2" />
  109. </Trigger>
  110. <Trigger Property="ButtonBase.IsPressed" Value="True">
  111. <Setter Property="Background" TargetName="border" Value="#5affffff" />
  112. </Trigger>
  113. </ControlTemplate.Triggers>
  114. </ControlTemplate>
  115. <Style x:Key="HomePageButtonStyle" TargetType="{x:Type cpdfcommon:HomePageButton}">
  116. <Setter Property="Template">
  117. <Setter.Value>
  118. <ControlTemplate TargetType="{x:Type cpdfcommon:HomePageButton}">
  119. <Border x:Name="border"
  120. Background="Transparent"
  121. BorderThickness="0"
  122. SnapsToDevicePixels="True"
  123. Margin="0,3,3,3"
  124. CornerRadius="5">
  125. <ContentPresenter x:Name="contentPresenter"
  126. Margin="0"
  127. HorizontalAlignment="Center"
  128. VerticalAlignment="Center"
  129. Focusable="False"
  130. RecognizesAccessKey="True" />
  131. </Border>
  132. <ControlTemplate.Triggers>
  133. <Trigger Property="IsMouseOver" Value="true">
  134. <Setter TargetName="border" Property="Background" Value="#5Affffff" />
  135. </Trigger>
  136. <Trigger Property="IsToggled" Value="true">
  137. <Setter TargetName="border" Property="Background" Value="#ffffff" />
  138. </Trigger>
  139. </ControlTemplate.Triggers>
  140. </ControlTemplate>
  141. </Setter.Value>
  142. </Setter>
  143. </Style>
  144. <Style x:Key="DragablzItemStyle" TargetType="{x:Type dragablz:DragablzItem}">
  145. <Setter Property="Template">
  146. <Setter.Value>
  147. <ControlTemplate TargetType="dragablz:DragablzItem">
  148. <Grid x:Name="templateRoot">
  149. <Grid.ColumnDefinitions>
  150. <ColumnDefinition Width="*" />
  151. <ColumnDefinition Width="auto" />
  152. </Grid.ColumnDefinitions>
  153. <Border x:Name="TitleBd" Width="184" Height="32" Margin="0,3,0,0" CornerRadius="5,5,0,0">
  154. <Grid Background="Transparent">
  155. <Grid.ColumnDefinitions>
  156. <ColumnDefinition Width="auto" />
  157. <ColumnDefinition Width="auto" />
  158. <ColumnDefinition Width="*" MinWidth="10" />
  159. <ColumnDefinition Width="auto" />
  160. </Grid.ColumnDefinitions>
  161. <Border x:Name="InnerTitleBd" Grid.ColumnSpan="4" BorderBrush="#5Affffff" CornerRadius="3" BorderThickness="1,0,1,0" Margin="2,1,2,4"></Border>
  162. <TextBlock x:Name="TextTitle" Grid.Column="1" MaxWidth="140" Margin="8,4,0,4" FontWeight="DemiBold" FontFamily="Microsoft YaHei,Microsoft YaHei" Text="{Binding FileName}" TextTrimming="WordEllipsis" />
  163. <Thumb x:Name="PART_Thumb" Grid.ColumnSpan="3" HorizontalAlignment="Stretch" VerticalContentAlignment="Stretch" Background="Transparent" FontFamily="Microsoft YaHei,Microsoft YaHei" ToolTip="{Binding FileName}">
  164. <Thumb.Template>
  165. <ControlTemplate>
  166. <Grid Background="Transparent" />
  167. </ControlTemplate>
  168. </Thumb.Template>
  169. </Thumb>
  170. <Button x:Name="CloseFileButton" Grid.Column="3" Width="18" Height="18" Margin="0,4,8,4" Background="Transparent" BorderThickness="0" Template="{StaticResource CloseFileButton}" Click="CloseFileButton_Click" ToolTip="Close file"></Button>
  171. </Grid>
  172. </Border>
  173. </Grid>
  174. <ControlTemplate.Triggers>
  175. <Trigger Property="IsSelected" Value="True">
  176. <Setter TargetName="TitleBd" Property="Background" Value="#FFFFFF" />
  177. <Setter TargetName="TitleBd" Property="BorderThickness" Value="1,1,1,0" />
  178. <Setter TargetName="TitleBd" Property="Margin" Value="0,3,0,-1" />
  179. <Setter TargetName="TextTitle" Property="Foreground" Value="Black" />
  180. </Trigger>
  181. <Trigger Property="IsMouseOver" Value="True">
  182. <Setter TargetName="TitleBd" Property="Background" Value="#FFFFFF" />
  183. <Setter TargetName="TitleBd" Property="BorderThickness" Value="1,1,1,0" />
  184. <Setter TargetName="TextTitle" Property="Foreground" Value="Black" />
  185. </Trigger>
  186. <Trigger Property="IsSelected" Value="False">
  187. <Setter TargetName="TitleBd" Property="Background" Value="TransParent" />
  188. <Setter TargetName="TitleBd" Property="BorderThickness" Value="1,1,1,0" />
  189. <Setter TargetName="TextTitle" Property="Foreground" Value="White" />
  190. </Trigger>
  191. <MultiDataTrigger>
  192. <MultiDataTrigger.Conditions>
  193. <Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="false" />
  194. <Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}" Value="true" />
  195. </MultiDataTrigger.Conditions>
  196. <Setter TargetName="InnerTitleBd" Property="Background" Value="#5Affffff" />
  197. <Setter TargetName="TextTitle" Property="Foreground" Value="White" />
  198. </MultiDataTrigger>
  199. </ControlTemplate.Triggers>
  200. </ControlTemplate>
  201. </Setter.Value>
  202. </Setter>
  203. </Style>
  204. <Style x:Key="TitleBarButtonStyle" TargetType="Button">
  205. <Setter Property="Foreground" Value="#FFFFFF" />
  206. <Setter Property="Padding" Value="0" />
  207. <Setter Property="Margin" Value="0" />
  208. <Setter Property="VerticalAlignment" Value="Top" />
  209. <Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True" />
  210. <Setter Property="IsTabStop" Value="False" />
  211. <Setter Property="Width" Value="36" />
  212. <Setter Property="Height" Value="30" />
  213. <Setter Property="Template">
  214. <Setter.Value>
  215. <ControlTemplate TargetType="{x:Type Button}">
  216. <Border x:Name="border"
  217. Background="Transparent"
  218. BorderThickness="0"
  219. SnapsToDevicePixels="True">
  220. <ContentPresenter x:Name="contentPresenter"
  221. Margin="0"
  222. HorizontalAlignment="Center"
  223. VerticalAlignment="Center"
  224. Focusable="False"
  225. RecognizesAccessKey="True" />
  226. </Border>
  227. <ControlTemplate.Triggers>
  228. <Trigger Property="IsMouseOver" Value="true">
  229. <Setter TargetName="border" Property="Background" Value="#1AE9E9E9" />
  230. </Trigger>
  231. <Trigger Property="IsPressed" Value="true">
  232. <Setter TargetName="border" Property="Background" Value="#1AEDEDED" />
  233. </Trigger>
  234. </ControlTemplate.Triggers>
  235. </ControlTemplate>
  236. </Setter.Value>
  237. </Setter>
  238. </Style>
  239. <Style x:Key="TitleBarCloseButtonStyle" BasedOn="{StaticResource TitleBarButtonStyle}" TargetType="Button">
  240. <Setter Property="Template">
  241. <Setter.Value>
  242. <ControlTemplate TargetType="{x:Type Button}">
  243. <Border x:Name="border"
  244. Background="Transparent"
  245. BorderThickness="0"
  246. SnapsToDevicePixels="True">
  247. <ContentPresenter x:Name="contentPresenter"
  248. Margin="0"
  249. HorizontalAlignment="Center"
  250. VerticalAlignment="Center"
  251. Focusable="False"
  252. RecognizesAccessKey="True" />
  253. </Border>
  254. <ControlTemplate.Triggers>
  255. <Trigger Property="IsMouseOver" Value="true">
  256. <Setter TargetName="border" Property="Background" Value="#C42B1C" />
  257. </Trigger>
  258. <Trigger Property="IsPressed" Value="true">
  259. <Setter TargetName="border" Property="Background" Value="#C84031" />
  260. </Trigger>
  261. </ControlTemplate.Triggers>
  262. </ControlTemplate>
  263. </Setter.Value>
  264. </Setter>
  265. </Style>
  266. </Window.Resources>
  267. <Grid>
  268. <Grid Background="#273C62" Margin="0,-1,0,0">
  269. <dragablz:TabablzControl Name="TabControl" ItemContainerStyle="{StaticResource DragablzItemStyle}" WindowChrome.IsHitTestVisibleInChrome="True">
  270. <dragablz:TabablzControl.HeaderPrefixContent>
  271. <Grid Margin="10,0,0,0">
  272. <StackPanel Orientation="Horizontal">
  273. <cpdfcommon:HomePageButton Style="{StaticResource HomePageButtonStyle}" x:Name="HomePageButton" Width="170" IsToggled="False" Toggled="HomePageButton_Toggled" QueryLock="HomePageButton_QueryLock">
  274. <Grid>
  275. <StackPanel Orientation="Horizontal">
  276. <Viewbox Width="20" Height="20" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  277. <Grid>
  278. <Path Data="M0 1.71429C0 0.767513 0.767512 0 1.71429 0H13.7143C14.6611 0 15.4286 0.767512 15.4286 1.71429V16.2857H1.71429C0.767512 16.2857 0 15.5182 0 14.5714V1.71429Z" Fill="#3863F1"/>
  279. <Path Data="M10.857 3.71387C7.3855 3.71387 4.57129 6.52808 4.57129 9.99958C4.57129 13.4711 7.3855 16.2853 10.857 16.2853H15.4284V3.71387H10.857ZM10.857 7.71384C9.59459 7.71384 8.57125 8.73719 8.57125 9.99955C8.57125 11.2619 9.5946 12.2853 10.857 12.2853H15.4284V7.71384H10.857Z" Fill="White"/>
  280. <Path Data="M18.2856 3.71387H15.4284L15.4284 7.71385H10.857C9.59465 7.71385 8.5713 8.7372 8.5713 9.99956C8.5713 11.2619 9.59465 12.2853 10.857 12.2853H15.4284L15.4284 16.2853L4.57129 16.2853V18.2853C4.57129 19.2321 5.3388 19.9996 6.28558 19.9996H18.2856C19.2324 19.9996 19.9999 19.2321 19.9999 18.2853V5.42815C19.9999 4.48138 19.2324 3.71387 18.2856 3.71387Z" Fill="#31BC98"/>
  281. </Grid>
  282. </Viewbox>
  283. <TextBlock Margin="10,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" FontFamily="Microsoft YaHei" FontSize="12" FontWeight="DemiBold" Text="{Binding AppInfo}">
  284. <TextBlock.Foreground>
  285. <Binding Path="IsToggled" ElementName="HomePageButton" Converter="{StaticResource BoolToColorConverter}"></Binding>
  286. </TextBlock.Foreground>
  287. </TextBlock>
  288. </StackPanel>
  289. </Grid>
  290. </cpdfcommon:HomePageButton>
  291. </StackPanel>
  292. </Grid>
  293. </dragablz:TabablzControl.HeaderPrefixContent>
  294. <dragablz:TabablzControl.InterTabController>
  295. <dragablz:InterTabController />
  296. </dragablz:TabablzControl.InterTabController>
  297. <dragablz:TabablzControl.HeaderSuffixContent>
  298. <Grid Name="TitleBarGrid" MinHeight="32" SnapsToDevicePixels="True">
  299. <Grid.ColumnDefinitions>
  300. <ColumnDefinition Width="auto"></ColumnDefinition>
  301. <ColumnDefinition Width="*"></ColumnDefinition>
  302. <ColumnDefinition Width="auto"></ColumnDefinition>
  303. </Grid.ColumnDefinitions>
  304. <Button x:Name="addBtn" Width="25" Height="25" Margin="9,0,0,0" HorizontalAlignment="Left" Background="Transparent" BorderThickness="0"
  305. Click="DefaultAddButton_Click" Template="{StaticResource AddFileButton}">
  306. </Button>
  307. <Grid Grid.Column="2" HorizontalAlignment="Right">
  308. <StackPanel Orientation="Horizontal" Margin="0,-2,0,0">
  309. <Button x:Name="SettingsBtn" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="SettingsBtn_Click">
  310. <Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
  311. <Grid>
  312. <Path Data="M12 1.00391H4L0 8.00391L4 15.0039H12L16 8.00391L12 1.00391ZM11.4684 2.00293L14.8486 8.00293L11.4684 14.0029H4.53037L1.15015 8.00293L4.53037 2.00293H11.4684ZM8 4.9991C6.34315 4.9991 5 6.34224 5 7.9991C5 9.65595 6.34315 10.9991 8 10.9991C9.65685 10.9991 11 9.65595 11 7.9991C11 6.34224 9.65685 4.9991 8 4.9991ZM7.99992 6.17C9.0102 6.17 9.82919 6.98899 9.82919 7.99926C9.82919 9.00954 9.0102 9.82853 7.99992 9.82853C6.98965 9.82853 6.17065 9.00954 6.17065 7.99926C6.17065 6.98899 6.98965 6.17 7.99992 6.17" Fill="White"/>
  313. </Grid>
  314. </Viewbox>
  315. </Button>
  316. <Button x:Name="MinimizeButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MinimizeButton_Click">
  317. <Path Width="36" Height="32"
  318. Data="M 13,15 H 23"
  319. Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
  320. StrokeThickness="1" />
  321. </Button>
  322. <Button x:Name="MaximizeRestoreButton" Style="{StaticResource TitleBarButtonStyle}" Width="36" Height="32" Click="MaximizeRestoreButton_Click">
  323. <Path Width="36" Height="32"
  324. Data="{Binding ElementName=Window, Path=WindowState, Converter={StaticResource WindowStateToPathConverter}}"
  325. Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
  326. StrokeThickness="1" />
  327. </Button>
  328. <Button x:Name="CloseButton" Style="{StaticResource TitleBarCloseButtonStyle}" Width="36" Height="32" Click="CloseButton_Click">
  329. <Path Width="36" Height="32"
  330. Data="M 13,11 22,20 M 13,20 22,11"
  331. Stroke="{Binding Path=Foreground,RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
  332. StrokeThickness="1" />
  333. </Button>
  334. </StackPanel>
  335. </Grid>
  336. </Grid>
  337. </dragablz:TabablzControl.HeaderSuffixContent>
  338. </dragablz:TabablzControl>
  339. <ContentControl x:Name="customContentControl">
  340. <ContentControl.Margin>
  341. <Binding Path="ActualHeight" ElementName="TitleBarGrid" Converter="{StaticResource HeightToTopMarginConverter}" />
  342. </ContentControl.Margin>
  343. <ContentControl.Height>
  344. <MultiBinding Converter="{StaticResource HomePageHeightConverter}">
  345. <Binding ElementName="TabControl" Path="ActualHeight"></Binding>
  346. <Binding ElementName="TitleBarGrid" Path="ActualHeight"></Binding>
  347. </MultiBinding>
  348. </ContentControl.Height>
  349. <ContentControl.Visibility>
  350. <Binding Path="IsToggled" ElementName="HomePageButton" Converter="{StaticResource BoolToVisibleConverter}"></Binding>
  351. </ContentControl.Visibility>
  352. <cpdftools:HomePageControl x:Name="HomePageControl" Visibility="{Binding ElementName=customContentControl, Path=Visibility}"></cpdftools:HomePageControl>
  353. </ContentControl>
  354. </Grid>
  355. <Border Name="PopupBorder" Background="#A0000000" Visibility="Collapsed">
  356. <cpdfcommon:PasswordDialog x:Name="PasswordUI" Visibility="Collapsed"></cpdfcommon:PasswordDialog>
  357. </Border>
  358. </Grid>
  359. </Window>