PageEditContent.xaml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <UserControl
  2. x:Class="PDF_Office.Views.PageEdit.PageEditContent"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:convert="clr-namespace:PDF_Office.DataConvert"
  6. xmlns:cus="clr-namespace:PDF_Office.CustomControl"
  7. xmlns:cussys="clr-namespace:PDF_Office.CustomControl.SystemControl"
  8. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  9. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  10. xmlns:local="clr-namespace:PDF_Office.Views.PageEdit"
  11. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  12. xmlns:model="clr-namespace:PDF_Office.Model"
  13. xmlns:pageedit="clr-namespace:PDF_Office.Model.PageEdit"
  14. xmlns:pageedit1="clr-namespace:PDF_Office.ViewModels.PageEdit"
  15. xmlns:prism="http://prismlibrary.com/"
  16. xmlns:wpftk="clr-namespace:WpfToolkit.Controls;assembly=VirtualizingWrapPanel"
  17. Name="PageEdit"
  18. d:DataContext="{d:DesignInstance Type=pageedit1:PageEditContentViewModel}"
  19. d:DesignHeight="450"
  20. d:DesignWidth="800"
  21. prism:ViewModelLocator.AutoWireViewModel="True"
  22. IsVisibleChanged="PageEdit_IsVisibleChanged"
  23. mc:Ignorable="d">
  24. <UserControl.Resources>
  25. <ResourceDictionary>
  26. <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
  27. <DataTemplate x:Key="PageEditListBoxItemTemplate" DataType="{x:Type pageedit:PageEditItem}">
  28. <StackPanel>
  29. <Border
  30. Name="BdBorder"
  31. VerticalAlignment="Top"
  32. BorderBrush="Transparent"
  33. BorderThickness="2"
  34. CornerRadius="0">
  35. <Grid
  36. Width="{Binding ItemSize.Width}"
  37. Height="{Binding ItemSize.Height}"
  38. Margin="1"
  39. Background="Gray">
  40. <Image Source="{Binding Image}" Stretch="Uniform" />
  41. <Border
  42. Width="10"
  43. Height="10"
  44. Margin="0,10,10,0"
  45. HorizontalAlignment="Right"
  46. VerticalAlignment="Top"
  47. Background="Yellow"
  48. Visibility="{Binding HaveBookMark, Converter={StaticResource BoolToVisibleConvert}}" />
  49. </Grid>
  50. </Border>
  51. <Border
  52. Name="BdPageNum"
  53. Margin="0,4,0,0"
  54. HorizontalAlignment="Center"
  55. VerticalAlignment="Bottom"
  56. Background="Transparent">
  57. <StackPanel
  58. Name="StkpnlButtom"
  59. Width="auto"
  60. MinWidth="50"
  61. HorizontalAlignment="Center"
  62. Background="Transparent">
  63. <TextBlock
  64. Width="auto"
  65. Height="22"
  66. Margin="0,4"
  67. HorizontalAlignment="Center"
  68. FontSize="14"
  69. Text="{Binding PageNumber}" />
  70. <TextBlock
  71. Width="auto"
  72. Height="22"
  73. HorizontalAlignment="Center"
  74. FontSize="14"
  75. Text="{Binding PageSize}"
  76. Visibility="{Binding ShowPageSize, Converter={StaticResource BoolToVisibleConvert}}" />
  77. </StackPanel>
  78. </Border>
  79. </StackPanel>
  80. <DataTemplate.Triggers>
  81. <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
  82. <Setter TargetName="BdBorder" Property="BorderBrush" Value="Blue" />
  83. <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
  84. <Setter TargetName="BdPageNum" Property="Background" Value="Blue" />
  85. <Setter TargetName="BdPageNum" Property="CornerRadius" Value="4" />
  86. </DataTrigger>
  87. <MultiDataTrigger>
  88. <MultiDataTrigger.Conditions>
  89. <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsMouseOver}" Value="True" />
  90. <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False" />
  91. </MultiDataTrigger.Conditions>
  92. <MultiDataTrigger.Setters>
  93. <Setter TargetName="BdBorder" Property="BorderBrush" Value="Blue" />
  94. <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
  95. </MultiDataTrigger.Setters>
  96. </MultiDataTrigger>
  97. </DataTemplate.Triggers>
  98. </DataTemplate>
  99. </ResourceDictionary>
  100. </UserControl.Resources>
  101. <Border BorderBrush="#F2F2F2" BorderThickness="0,1,0,0">
  102. <Grid>
  103. <Grid.RowDefinitions>
  104. <RowDefinition Height="40" />
  105. <RowDefinition />
  106. </Grid.RowDefinitions>
  107. <Grid Background="#FFFFFF">
  108. <StackPanel
  109. Name="StkpnlCenter"
  110. HorizontalAlignment="Center"
  111. Orientation="Horizontal">
  112. <Grid>
  113. <ComboBox
  114. Width="117"
  115. Height="23"
  116. ItemsSource="{Binding PageRangeItems}"
  117. SelectedIndex="{Binding ComboxSelectIndex, Mode=TwoWay}" />
  118. <TextBlock
  119. Width="90"
  120. Height="20"
  121. Margin="1,0"
  122. HorizontalAlignment="Left"
  123. VerticalAlignment="Center"
  124. Background="White"
  125. Text="{Binding TbPageRange}"
  126. Visibility="{Binding TbPageRangeVisibility}" />
  127. <TextBox
  128. Width="90"
  129. Height="20"
  130. Margin="1,0"
  131. HorizontalAlignment="Left"
  132. Background="White"
  133. InputMethod.IsInputMethodEnabled="False"
  134. IsVisibleChanged="TextBox_IsVisibleChanged"
  135. Visibility="{Binding TxtPageInputVisibility}">
  136. <i:Interaction.Triggers>
  137. <i:EventTrigger EventName="PreviewKeyDown">
  138. <i:InvokeCommandAction Command="{Binding PreviewKeyDown}" PassEventArgsToCommand="True" />
  139. </i:EventTrigger>
  140. <i:EventTrigger EventName="KeyDown">
  141. <i:InvokeCommandAction Command="{Binding KeyDown}" PassEventArgsToCommand="True" />
  142. </i:EventTrigger>
  143. </i:Interaction.Triggers>
  144. </TextBox>
  145. </Grid>
  146. <Button
  147. Width="20"
  148. Height="20"
  149. Margin="5"
  150. Command="{Binding LeftRotateCommand}">
  151. <Path Data="M8,0.5 C11.5898509,0.5 14.5,3.43884135 14.5,7.06408587 C14.5,10.6893304 11.5898509,13.6281717 8,13.6281717 C7.71394437,13.6281717 7.4302177,13.6094794 7.15010992,13.5725129 L8.35355339,14.7859216 L7.64644661,15.5 L5.29289322,13.1232421 L7.64644661,10.7464841 L8.35355339,11.4605625 L7.25820051,12.5682882 C7.50239929,12.6015049 7.7500379,12.6183124 8,12.6183124 C11.0375661,12.6183124 13.5,10.1316005 13.5,7.06408587 C13.5,3.99657128 11.0375661,1.50985937 8,1.50985937 C5.03652085,1.50985937 2.62046086,3.87674756 2.5043672,6.84069777 L2.5,7.06408587 L1.5,7.06408587 C1.5,3.43884135 4.41014913,0.5 8,0.5 Z M8,5.54929683 C8.82842712,5.54929683 9.5,6.22749098 9.5,7.06408587 C9.5,7.90068077 8.82842712,8.57887492 8,8.57887492 C7.17157288,8.57887492 6.5,7.90068077 6.5,7.06408587 C6.5,6.22749098 7.17157288,5.54929683 8,5.54929683 Z M8,6.55915619 C7.72385763,6.55915619 7.5,6.78522091 7.5,7.06408587 C7.5,7.34295084 7.72385763,7.56901556 8,7.56901556 C8.27614237,7.56901556 8.5,7.34295084 8.5,7.06408587 C8.5,6.78522091 8.27614237,6.55915619 8,6.55915619 Z" Fill="Black">
  152. <Path.RenderTransform>
  153. <TransformGroup>
  154. <TranslateTransform X="10.000000" Y="8.000000" />
  155. <ScaleTransform ScaleX="-1" ScaleY="1" />
  156. <TranslateTransform X="25.000000" Y="-8.000000" />
  157. </TransformGroup>
  158. </Path.RenderTransform>
  159. </Path>
  160. </Button>
  161. <Button
  162. Width="20"
  163. Height="20"
  164. Margin="5"
  165. Command="{Binding RightRotateCommand}">
  166. <Path Data="M8,0.5 C11.5898509,0.5 14.5,3.43884135 14.5,7.06408587 C14.5,10.6893304 11.5898509,13.6281717 8,13.6281717 C7.71394437,13.6281717 7.4302177,13.6094794 7.15010992,13.5725129 L8.35355339,14.7859216 L7.64644661,15.5 L5.29289322,13.1232421 L7.64644661,10.7464841 L8.35355339,11.4605625 L7.25820051,12.5682882 C7.50239929,12.6015049 7.7500379,12.6183124 8,12.6183124 C11.0375661,12.6183124 13.5,10.1316005 13.5,7.06408587 C13.5,3.99657128 11.0375661,1.50985937 8,1.50985937 C5.03652085,1.50985937 2.62046086,3.87674756 2.5043672,6.84069777 L2.5,7.06408587 L1.5,7.06408587 C1.5,3.43884135 4.41014913,0.5 8,0.5 Z M8,5.54929683 C8.82842712,5.54929683 9.5,6.22749098 9.5,7.06408587 C9.5,7.90068077 8.82842712,8.57887492 8,8.57887492 C7.17157288,8.57887492 6.5,7.90068077 6.5,7.06408587 C6.5,6.22749098 7.17157288,5.54929683 8,5.54929683 Z M8,6.55915619 C7.72385763,6.55915619 7.5,6.78522091 7.5,7.06408587 C7.5,7.34295084 7.72385763,7.56901556 8,7.56901556 C8.27614237,7.56901556 8.5,7.34295084 8.5,7.06408587 C8.5,6.78522091 8.27614237,6.55915619 8,6.55915619 Z" Fill="Black" />
  167. </Button>
  168. <Separator
  169. Width="1"
  170. Height="24"
  171. Margin="5,0"
  172. BorderBrush="#33000000"
  173. BorderThickness="5"
  174. Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
  175. <Menu
  176. Width="65"
  177. Height="20"
  178. Margin="5">
  179. <MenuItem
  180. Width="65"
  181. Height="20"
  182. Header="插入">
  183. <MenuItem
  184. Command="{Binding InsertCommand}"
  185. CommandParameter="{x:Static model:ParameterNames.InsertType_File}"
  186. Header="插入文件" />
  187. <MenuItem
  188. Command="{Binding InsertCommand}"
  189. CommandParameter="{x:Static model:ParameterNames.InsertType_Blank}"
  190. Header="插入空白页" />
  191. <MenuItem
  192. Command="{Binding InsertCommand}"
  193. CommandParameter="{x:Static model:ParameterNames.InsertType_Custom}"
  194. Header="插入自定义页面" />
  195. </MenuItem>
  196. </Menu>
  197. <Button
  198. Height="20"
  199. Margin="5"
  200. Command="{Binding ExtractCommand}"
  201. Content="提取" />
  202. <Button
  203. Height="20"
  204. Margin="5"
  205. Command="{Binding ReplaceCommand}"
  206. Content="替换" />
  207. <Button
  208. Height="20"
  209. Margin="5"
  210. Command="{Binding SplitCommand}"
  211. Content="拆分" />
  212. <Button
  213. Height="20"
  214. Margin="5"
  215. Command="{Binding ReverseCommand}"
  216. Content="倒序" />
  217. <Separator
  218. Width="1"
  219. Height="24"
  220. Margin="5,0"
  221. BorderBrush="#33000000"
  222. BorderThickness="5"
  223. Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
  224. <Button
  225. Height="20"
  226. Margin="5"
  227. Command="{Binding DeleteCommand}"
  228. Content="删除" />
  229. </StackPanel>
  230. <StackPanel
  231. Name="StkpnlRight"
  232. HorizontalAlignment="Right"
  233. Orientation="Horizontal">
  234. <Button
  235. Width="25"
  236. Height="25"
  237. Margin="4"
  238. Command="{Binding ZoomInCommand}">
  239. <Path Data="M6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.12212 13 9.60545 12.4058 10.7442 11.4232L14.821 15.5L15.5 14.821L11.4232 10.7442C12.4058 9.60545 13 8.12212 13 6.5C13 2.91015 10.0899 0 6.5 0ZM6.5 1C9.53757 1 12 3.46243 12 6.5C12 9.53757 9.53757 12 6.5 12C3.46243 12 1 9.53757 1 6.5C1 3.46243 3.46243 1 6.5 1ZM10 6H7V3H6V6H3V7H6V10H7V7H10V6Z" Fill="Black" />
  240. </Button>
  241. <Button
  242. Width="25"
  243. Height="25"
  244. Margin="4"
  245. Command="{Binding ZoomOutCommand}">
  246. <Path Data="M0 6.5C0 2.91015 2.91015 0 6.5 0C10.0899 0 13 2.91015 13 6.5C13 8.12212 12.4058 9.60545 11.4232 10.7442L15.5 14.821L14.821 15.5L10.7442 11.4232C9.60545 12.4058 8.12212 13 6.5 13C2.91015 13 0 10.0899 0 6.5ZM12 6.5C12 3.46243 9.53757 1 6.5 1C3.46243 1 1 3.46243 1 6.5C1 9.53757 3.46243 12 6.5 12C9.53757 12 12 9.53757 12 6.5ZM10 6V7H3V6H10Z" Fill="Black" />
  247. </Button>
  248. </StackPanel>
  249. </Grid>
  250. <ListBox
  251. Name="ListPageEdit"
  252. Grid.Row="1"
  253. Padding="0"
  254. AllowDrop="True"
  255. Background="#E7E9EC"
  256. ItemTemplate="{StaticResource PageEditListBoxItemTemplate}"
  257. ItemsSource="{Binding PageEditItems}"
  258. PreviewMouseLeftButtonDown="ListPageEdit_PreviewMouseLeftButtonDown"
  259. PreviewMouseLeftButtonUp="ListPageEdit_PreviewMouseLeftButtonUp"
  260. PreviewMouseMove="ListPageEdit_PreviewMouseMove"
  261. ScrollBar.Scroll="ListPageEdit_Scroll"
  262. ScrollViewer.ScrollChanged="ListPageEdit_ScrollChanged"
  263. SelectedIndex="{Binding ListSelectedIndex, Mode=TwoWay}"
  264. SelectionMode="Extended">
  265. <!-- 此处要用循环模式,否则滚动时容易误触发EndSscroll 从而频繁拿图导致卡顿 -->
  266. <ListBox.ItemContainerStyle>
  267. <Style TargetType="{x:Type ListBoxItem}">
  268. <Setter Property="Template" Value="{StaticResource ListBoxItemControlTemplate}" />
  269. <Setter Property="Margin" Value="0,10" />
  270. <Setter Property="Visibility" Value="{Binding Visible}" />
  271. <Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay}" />
  272. <Setter Property="HorizontalContentAlignment" Value="Center" />
  273. <Setter Property="VerticalContentAlignment" Value="Center" />
  274. </Style>
  275. </ListBox.ItemContainerStyle>
  276. <ListBox.ItemsPanel>
  277. <ItemsPanelTemplate>
  278. <!-- item间距自适应 -->
  279. <wpftk:VirtualizingWrapPanel />
  280. </ItemsPanelTemplate>
  281. </ListBox.ItemsPanel>
  282. <i:Interaction.Triggers>
  283. <i:EventTrigger EventName="SelectionChanged">
  284. <i:InvokeCommandAction Command="{Binding SelectionChangedCommand}" PassEventArgsToCommand="True" />
  285. </i:EventTrigger>
  286. </i:Interaction.Triggers>
  287. </ListBox>
  288. <!-- 框选的矩形框 -->
  289. <Rectangle
  290. Name="RectChoose"
  291. Grid.Row="1"
  292. HorizontalAlignment="Left"
  293. VerticalAlignment="Top"
  294. Fill="#AACCEE"
  295. Opacity="0.3"
  296. Stroke="#AACCEE"
  297. StrokeThickness="2" />
  298. <cus:ToastControl
  299. Grid.Row="1"
  300. Width="auto"
  301. Height="auto"
  302. Margin="0,0,0,200"
  303. VerticalAlignment="Bottom"
  304. Background="#89000000"
  305. BeginTime="0:0:0:3"
  306. CornerRadius="4"
  307. FontSize="14"
  308. Foreground="White"
  309. StringContent="Press Esc To Exit Full Mode"
  310. Visibility="{Binding ShowTip}"
  311. Duration="0:0:0:3" />
  312. <ProgressBar
  313. Grid.Row="1"
  314. Width="400"
  315. Height="50"
  316. IsIndeterminate="True"
  317. Visibility="{Binding IsLoading}" />
  318. </Grid>
  319. </Border>
  320. </UserControl>