CompressDialog.xaml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <Window x:Class="ComPDFKit.Controls.Compress.CompressDialog"
  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:ComPDFKit.Controls.Compress"
  7. mc:Ignorable="d"
  8. Title="CompressWPFDialog" Height="450" Width="890" ResizeMode="NoResize"
  9. ShowInTaskbar="False"
  10. WindowStartupLocation="CenterOwner"
  11. WindowStyle="SingleBorderWindow">
  12. <Window.Resources>
  13. <ResourceDictionary>
  14. <local:MaxWidthToTextTrimmingConverter x:Key="MaxWidthToTextTrimmingConverter" />
  15. <Style x:Key="LeftAlignedHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
  16. <Setter Property="HorizontalContentAlignment" Value="Left" />
  17. </Style>
  18. <Style x:Key="DisabledButtonStyle" TargetType="{x:Type Button}">
  19. <Setter Property="BorderThickness" Value="1" />
  20. <Setter Property="Padding" Value="5" />
  21. <Setter Property="Width" Value="100" />
  22. <Setter Property="Height" Value="40" />
  23. <Style.Triggers>
  24. <Trigger Property="IsEnabled" Value="False">
  25. <Setter Property="Foreground" Value="Gray" />
  26. </Trigger>
  27. </Style.Triggers>
  28. </Style>
  29. <Style x:Key="ResizableGridViewColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
  30. <Setter Property="Template">
  31. <Setter.Value>
  32. <ControlTemplate TargetType="GridViewColumnHeader">
  33. <Grid x:Name="Root" Background="Transparent">
  34. <Grid.ColumnDefinitions>
  35. <ColumnDefinition Width="*" />
  36. <ColumnDefinition Width="Auto" />
  37. </Grid.ColumnDefinitions>
  38. <ContentPresenter Grid.Column="0" VerticalAlignment="Center" />
  39. <Thumb
  40. x:Name="PART_HeaderGripper"
  41. Grid.Column="1"
  42. Width="5"
  43. HorizontalAlignment="Right"
  44. Cursor="SizeWE"
  45. DragDelta="PART_HeaderGripper_DragDelta" />
  46. </Grid>
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. </Style>
  51. <Style x:Key="RoundButtonStyle" TargetType="{x:Type Button}">
  52. <Setter Property="Background" Value="White" />
  53. <Setter Property="BorderBrush" Value="Black" />
  54. <Setter Property="BorderThickness" Value="1" />
  55. <Setter Property="Padding" Value="5" />
  56. <Setter Property="Margin" Value="12,8" />
  57. <Setter Property="Width" Value="100" />
  58. <Setter Property="Height" Value="40" />
  59. <Setter Property="Template">
  60. <Setter.Value>
  61. <ControlTemplate TargetType="{x:Type Button}">
  62. <Border
  63. x:Name="border"
  64. Background="{TemplateBinding Background}"
  65. BorderBrush="{TemplateBinding BorderBrush}"
  66. BorderThickness="{TemplateBinding BorderThickness}"
  67. CornerRadius="0">
  68. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
  69. </Border>
  70. <ControlTemplate.Triggers>
  71. <Trigger Property="IsPressed" Value="True">
  72. <Setter TargetName="border" Property="Background" Value="White" />
  73. <Setter TargetName="border" Property="BorderBrush" Value="LightGray" />
  74. </Trigger>
  75. <Trigger Property="IsEnabled" Value="False">
  76. <Setter TargetName="border" Property="Opacity" Value="0.5" />
  77. </Trigger>
  78. </ControlTemplate.Triggers>
  79. </ControlTemplate>
  80. </Setter.Value>
  81. </Setter>
  82. </Style>
  83. <Style x:Key="HeadStyle" TargetType="{x:Type GridViewColumnHeader}">
  84. <Setter Property="OverridesDefaultStyle" Value="False" />
  85. <Setter Property="HorizontalContentAlignment" Value="Left" />
  86. <Setter Property="FontSize" Value="14" />
  87. <Setter Property="Template">
  88. <Setter.Value>
  89. <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
  90. <Grid Name="g" Background="Transparent">
  91. <Border Name="bd" Padding="{TemplateBinding Padding}">
  92. <Grid>
  93. <!-- Gripper 控件 -->
  94. <Thumb
  95. x:Name="PART_HeaderGripper"
  96. Width="5"
  97. HorizontalAlignment="Right"
  98. Background="White"
  99. BorderBrush="LightGray"
  100. Cursor="SizeWE"
  101. Visibility="Collapsed" />
  102. <ContentPresenter Margin="5,3,0,3" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
  103. </Grid>
  104. </Border>
  105. </Grid>
  106. <ControlTemplate.Triggers>
  107. <Trigger Property="IsMouseOver" Value="True">
  108. <Setter TargetName="g" Property="Background" Value="LightGray" />
  109. <Setter TargetName="g" Property="Opacity" Value="0.7" />
  110. <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Visible" />
  111. <Setter TargetName="PART_HeaderGripper" Property="Background" Value="LightGray" />
  112. <Setter TargetName="PART_HeaderGripper" Property="Opacity" Value="0.5" />
  113. </Trigger>
  114. </ControlTemplate.Triggers>
  115. </ControlTemplate>
  116. </Setter.Value>
  117. </Setter>
  118. </Style>
  119. <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
  120. <Style.Setters>
  121. <Setter Property="HorizontalAlignment" Value="Stretch" />
  122. <Setter Property="SnapsToDevicePixels" Value="True" />
  123. <Setter Property="Foreground" Value="Black" />
  124. <Setter Property="Template">
  125. <Setter.Value>
  126. <ControlTemplate TargetType="{x:Type ListViewItem}">
  127. <Border
  128. x:Name="bd"
  129. Padding="{TemplateBinding Padding}"
  130. BorderBrush="LightGray"
  131. Background="Transparent"
  132. BorderThickness="1"
  133. SnapsToDevicePixels="True">
  134. <GridViewRowPresenter
  135. Margin="0,2"
  136. Columns="{TemplateBinding GridView.ColumnCollection}"
  137. Content="{TemplateBinding Content}" />
  138. </Border>
  139. <ControlTemplate.Triggers>
  140. <Trigger Property="IsSelected" Value="True">
  141. <Trigger.Setters>
  142. <Setter TargetName="bd" Property="Background" Value="LightGray" />
  143. <Setter TargetName="bd" Property="Opacity" Value="0.8" />
  144. </Trigger.Setters>
  145. </Trigger>
  146. <Trigger Property="IsMouseOver" Value="True">
  147. <Trigger.Setters>
  148. <Setter TargetName="bd" Property="Background" Value="LightGray" />
  149. <Setter TargetName="bd" Property="Opacity" Value="0.7" />
  150. <Setter TargetName="bd" Property="BorderBrush" Value="LightGray" />
  151. </Trigger.Setters>
  152. </Trigger>
  153. </ControlTemplate.Triggers>
  154. </ControlTemplate>
  155. </Setter.Value>
  156. </Setter>
  157. </Style.Setters>
  158. </Style>
  159. <Style x:Key="BigCustomRadioButtonStyle" TargetType="{x:Type RadioButton}">
  160. <Setter Property="Template">
  161. <Setter.Value>
  162. <ControlTemplate TargetType="{x:Type RadioButton}">
  163. <Grid>
  164. <Border x:Name="border">
  165. <Grid Background="Transparent">
  166. <Grid.ColumnDefinitions>
  167. <ColumnDefinition Width="Auto"/>
  168. <ColumnDefinition Width="*"/>
  169. </Grid.ColumnDefinitions>
  170. <Border x:Name="radioButtonBorder" Grid.Column="0" BorderBrush="Black" Width="18" Height="18" Margin="0" BorderThickness="1.4" CornerRadius="20" SnapsToDevicePixels="True">
  171. <Path x:Name="checkMark" Fill="Black" StrokeThickness="2" Visibility="Collapsed" Data="M0 5C0 2.23858 2.23858 0 5 0C7.76142 0 10 2.23858 10 5C10 7.76142 7.76142 10 5 10C2.23858 10 0 7.76142 0 5Z" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  172. </Border>
  173. <ContentPresenter Grid.Column="1" Margin="5,0,0,0" VerticalAlignment="Center" RecognizesAccessKey="True"/>
  174. </Grid>
  175. </Border>
  176. </Grid>
  177. <ControlTemplate.Triggers>
  178. <Trigger Property="IsChecked" Value="True">
  179. <Setter TargetName="checkMark" Property="Visibility" Value="Visible"/>
  180. </Trigger>
  181. <Trigger Property="IsMouseOver" Value="True">
  182. <Setter TargetName="radioButtonBorder" Property="Background" Value="#E1E1E1"/>
  183. </Trigger>
  184. <Trigger Property="IsPressed" Value="True">
  185. <Setter TargetName="radioButtonBorder" Property="Background" Value="#E1E1E1"/>
  186. </Trigger>
  187. <Trigger Property="IsEnabled" Value="False">
  188. <Setter TargetName="radioButtonBorder" Property="Opacity" Value="0.3"/>
  189. </Trigger>
  190. </ControlTemplate.Triggers>
  191. </ControlTemplate>
  192. </Setter.Value>
  193. </Setter>
  194. </Style>
  195. </ResourceDictionary>
  196. </Window.Resources>
  197. <Grid>
  198. <Grid>
  199. <Grid.RowDefinitions>
  200. <RowDefinition Height="50" />
  201. <RowDefinition Height="*" />
  202. <RowDefinition Height="50" />
  203. </Grid.RowDefinitions>
  204. <Grid.ColumnDefinitions>
  205. <ColumnDefinition Width="640" />
  206. <ColumnDefinition Width="*" />
  207. </Grid.ColumnDefinitions>
  208. <DockPanel LastChildFill="True">
  209. <Button
  210. Margin="12,0,0,0"
  211. Name="btnAddFile"
  212. MinWidth="112"
  213. Padding="8,0,8,0"
  214. Height="32"
  215. Click="btnAddFile_Click"
  216. Content=" Add File"
  217. DockPanel.Dock="Left"
  218. BorderBrush="#33000000" Background="#E1E1E1" BorderThickness="1" Style="{StaticResource DisabledButtonStyle}" />
  219. <StackPanel Name="flowLayoutPanel2" DockPanel.Dock="Right">
  220. <Label
  221. Name="lbTotalFiles"
  222. Width="120"
  223. Height="32"
  224. Margin="0,5"
  225. HorizontalAlignment="Right"
  226. VerticalContentAlignment="Center"
  227. Content="Total 10 Files" />
  228. </StackPanel>
  229. </DockPanel>
  230. <StackPanel Name="panel1" Grid.Row="1" >
  231. <ListView
  232. VerticalContentAlignment="Top"
  233. HorizontalAlignment="Left"
  234. Margin="12,0,0,0"
  235. Name="CompressListView"
  236. Width="620"
  237. Height="250"
  238. AllowDrop="True"
  239. DragOver="ConverterListView_DragOver"
  240. Drop="ConverterListView_Drop"
  241. ItemContainerStyle="{StaticResource ListViewItemStyle}"
  242. Loaded="ConverterListView_Loaded"
  243. PreviewMouseLeftButtonDown="ConverterListView_PreviewMouseLeftButtonDown"
  244. SizeChanged="ConverterListView_SizeChanged"
  245. MouseMove="ConverterListView_MouseMove"
  246. PreviewMouseUp="ConverterListView_PreviewMouseUp"
  247. SelectionChanged="ConverterListView_SelectionChanged">
  248. <ListView.View>
  249. <GridView AllowsColumnReorder="False" ColumnHeaderContainerStyle="{StaticResource HeadStyle}">
  250. <GridViewColumn
  251. x:Name="FileName"
  252. Width="180"
  253. Header="Name">
  254. <GridViewColumn.CellTemplate>
  255. <DataTemplate>
  256. <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
  257. <Image
  258. Width="20"
  259. Height="20"
  260. Margin="5"
  261. Source="../../Resources/Image/PDFicon.png"/>
  262. <TextBlock
  263. x:Name="TxbName"
  264. HorizontalAlignment="Center"
  265. VerticalAlignment="Center"
  266. SizeChanged="TxbName_SizeChanged"
  267. Text="{Binding Name}"
  268. TextAlignment="Left" TextTrimming="CharacterEllipsis">
  269. <TextBlock.ToolTip>
  270. <ToolTip>
  271. <TextBlock Text="{Binding Name}" />
  272. </ToolTip>
  273. </TextBlock.ToolTip>
  274. </TextBlock>
  275. </StackPanel>
  276. </DataTemplate>
  277. </GridViewColumn.CellTemplate>
  278. </GridViewColumn>
  279. <GridViewColumn
  280. x:Name="SizeHeader"
  281. Width="80"
  282. Header="Size">
  283. <GridViewColumn.CellTemplate>
  284. <DataTemplate>
  285. <TextBlock Text="{Binding Size}" TextTrimming="CharacterEllipsis">
  286. <TextBlock.ToolTip>
  287. <ToolTip>
  288. <TextBlock Text="{Binding Size}" />
  289. </ToolTip>
  290. </TextBlock.ToolTip>
  291. </TextBlock>
  292. </DataTemplate>
  293. </GridViewColumn.CellTemplate>
  294. </GridViewColumn>
  295. <GridViewColumn
  296. x:Name="PathHeader"
  297. Width="250"
  298. Header="Path">
  299. <GridViewColumn.CellTemplate>
  300. <DataTemplate>
  301. <TextBlock
  302. HorizontalAlignment="Left"
  303. VerticalAlignment="Center"
  304. Text="{Binding Path}"
  305. TextAlignment="Left" TextTrimming="CharacterEllipsis">
  306. <TextBlock.ToolTip>
  307. <ToolTip>
  308. <TextBlock Text="{Binding Path}" />
  309. </ToolTip>
  310. </TextBlock.ToolTip>
  311. </TextBlock>
  312. </DataTemplate>
  313. </GridViewColumn.CellTemplate>
  314. </GridViewColumn>
  315. <GridViewColumn
  316. x:Name="ProgressHeader"
  317. Width="50"
  318. Header="Progress">
  319. <GridViewColumn.CellTemplate>
  320. <DataTemplate>
  321. <TextBlock Text="{Binding Progress}" />
  322. </DataTemplate>
  323. </GridViewColumn.CellTemplate>
  324. </GridViewColumn>
  325. </GridView>
  326. </ListView.View>
  327. </ListView>
  328. <WrapPanel Margin="0,12,0,0">
  329. <Button
  330. Margin="12,0,0,0"
  331. Name="btnRemove"
  332. MinWidth="112"
  333. Padding="8,0,8,0"
  334. Height="32"
  335. Click="btnRemove_Click"
  336. Content="Delete"
  337. BorderBrush="#33000000" Background="#E1E1E1" BorderThickness="1" Style="{StaticResource DisabledButtonStyle}"
  338. />
  339. <Button
  340. Name="btnMoveUp"
  341. Width="150"
  342. Height="32"
  343. Margin="10,5"
  344. Content="MoveUp"
  345. IsEnabled="False" Style="{StaticResource DisabledButtonStyle}"
  346. BorderBrush="#33000000" Background="#E1E1E1" BorderThickness="1" Click="btnMoveUp_Click" Visibility="Collapsed"/>
  347. <Button
  348. Name="btnMoveDown"
  349. Width="150"
  350. Height="32"
  351. Margin="10,5"
  352. Content="Move Down"
  353. IsEnabled="False"
  354. BorderBrush="#33000000" Background="#E1E1E1" BorderThickness="1" Click="btnMoveDown_Click" Style="{StaticResource DisabledButtonStyle}" Visibility="Collapsed"/>
  355. </WrapPanel>
  356. </StackPanel>
  357. <GroupBox
  358. Grid.Row="0"
  359. Grid.RowSpan="2"
  360. Grid.Column="1"
  361. Margin="8,40,20,0"
  362. Name="groupBox1"
  363. Width="200"
  364. Height="262"
  365. VerticalAlignment="Top">
  366. <GroupBox.Header>
  367. <TextBlock Name="groupBox1Text" Text="Optimization Quality" FontWeight="DemiBold"></TextBlock>
  368. </GroupBox.Header>
  369. <StackPanel>
  370. <RadioButton
  371. Name="rbtnLow"
  372. Margin="8,8,0,0"
  373. Checked="rbtnAllPage_Checked"
  374. Content="Low"
  375. GroupName="GroupPageRange" Style="{StaticResource BigCustomRadioButtonStyle}"/>
  376. <RadioButton
  377. Name="rbtnMedium"
  378. Margin="8,8"
  379. Checked="rbtnCurrentPage_Checked"
  380. Content="Medium"
  381. GroupName="GroupPageRange" Style="{StaticResource BigCustomRadioButtonStyle}"/>
  382. <RadioButton
  383. Name="rbtnHigh"
  384. Margin="8,0"
  385. Checked="rbtnOldPageOnly_Checked"
  386. Content="High"
  387. GroupName="GroupPageRange" Style="{StaticResource BigCustomRadioButtonStyle}"/>
  388. <StackPanel Orientation="Horizontal">
  389. <RadioButton
  390. Name="rbtnCustom"
  391. Margin="8,8"
  392. Checked="RbtnEvenPageOnly_Checked"
  393. Content="Custom"
  394. GroupName="GroupPageRange" Style="{StaticResource BigCustomRadioButtonStyle}"/>
  395. <StackPanel Orientation="Horizontal" IsEnabled="{Binding ElementName=rbtnCustom,Path=IsChecked}">
  396. <TextBox Name="txtQuality" Width="50" Height="28" PreviewTextInput="TextBox_PreviewTextInput" TextChanged="TextBox_TextChanged" InputMethod.IsInputMethodEnabled="False" Padding="0,5,0,0" Text="100"></TextBox>
  397. <TextBlock Height="15" Margin="8,0,0,0">%</TextBlock>
  398. </StackPanel>
  399. </StackPanel>
  400. </StackPanel>
  401. </GroupBox>
  402. <WrapPanel
  403. Width="300"
  404. HorizontalAlignment="Right"
  405. DockPanel.Dock="Right" Grid.Row="2" Grid.ColumnSpan="2">
  406. <Button
  407. Name="btnCompress"
  408. Style="{StaticResource DisabledButtonStyle}"
  409. BorderBrush="#FA477EDE" Background="#E1E1E1" BorderThickness="1"
  410. MinWidth="112"
  411. Padding="8,0,8,0"
  412. Height="32"
  413. Margin="30,0,2,0"
  414. HorizontalAlignment="Right"
  415. VerticalContentAlignment="Center"
  416. IsEnabled="False"
  417. Click="btnCompress_Click">
  418. Compress
  419. </Button>
  420. <Button
  421. Name="btnCancel"
  422. MinWidth="112"
  423. Padding="8,0,8,0"
  424. Height="32"
  425. Margin="10,0,10,0"
  426. HorizontalAlignment="Right"
  427. VerticalContentAlignment="Center"
  428. Click="btnCancel_Click" Style="{StaticResource DisabledButtonStyle}"
  429. BorderBrush="#33000000" Background="#E1E1E1" BorderThickness="1">
  430. Cancel
  431. </Button>
  432. </WrapPanel>
  433. </Grid>
  434. </Grid>
  435. </Window>