PageEditContent.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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:pageedit="clr-namespace:PDF_Office.Model.PageEdit"
  13. xmlns:pageedit1="clr-namespace:PDF_Office.ViewModels.PageEdit"
  14. xmlns:prism="http://prismlibrary.com/"
  15. xmlns:wpftk="clr-namespace:WpfToolkit.Controls;assembly=VirtualizingWrapPanel"
  16. Name="PageEdit"
  17. d:DataContext="{d:DesignInstance Type=pageedit1:PageEditContentViewModel}"
  18. d:DesignHeight="450"
  19. d:DesignWidth="800"
  20. prism:ViewModelLocator.AutoWireViewModel="True"
  21. IsVisibleChanged="PageEdit_IsVisibleChanged"
  22. mc:Ignorable="d">
  23. <UserControl.Resources>
  24. <ResourceDictionary>
  25. <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
  26. <DataTemplate x:Key="PageEditListBoxItemTemplate" DataType="{x:Type pageedit:PageEditItem}">
  27. <StackPanel>
  28. <Border
  29. Name="BdBorder"
  30. VerticalAlignment="Top"
  31. BorderBrush="Transparent"
  32. BorderThickness="2"
  33. CornerRadius="0">
  34. <Grid
  35. Width="{Binding ItemSize.Width}"
  36. Height="{Binding ItemSize.Height}"
  37. Margin="1"
  38. Background="Gray">
  39. <Image Source="{Binding Image}" Stretch="Uniform" />
  40. <Border
  41. Width="10"
  42. Height="10"
  43. Margin="0,10,10,0"
  44. HorizontalAlignment="Right"
  45. VerticalAlignment="Top"
  46. Background="Yellow"
  47. Visibility="{Binding HaveBookMark, Converter={StaticResource BoolToVisibleConvert}}" />
  48. </Grid>
  49. </Border>
  50. <Border
  51. Name="BdPageNum"
  52. Margin="0,4,0,0"
  53. HorizontalAlignment="Center"
  54. VerticalAlignment="Bottom"
  55. Background="Transparent">
  56. <StackPanel
  57. Name="StkpnlButtom"
  58. Width="auto"
  59. MinWidth="50"
  60. HorizontalAlignment="Center"
  61. Background="Transparent">
  62. <TextBlock
  63. Width="auto"
  64. Height="22"
  65. Margin="0,4"
  66. HorizontalAlignment="Center"
  67. FontSize="14"
  68. Text="{Binding PageNumber}" />
  69. <TextBlock
  70. Width="auto"
  71. Height="22"
  72. HorizontalAlignment="Center"
  73. FontSize="14"
  74. Text="{Binding PageSize}"
  75. Visibility="{Binding ShowPageSize, Converter={StaticResource BoolToVisibleConvert}}" />
  76. </StackPanel>
  77. </Border>
  78. </StackPanel>
  79. <DataTemplate.Triggers>
  80. <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
  81. <Setter TargetName="BdBorder" Property="BorderBrush" Value="Blue" />
  82. <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
  83. <Setter TargetName="BdPageNum" Property="Background" Value="Blue" />
  84. <Setter TargetName="BdPageNum" Property="CornerRadius" Value="4" />
  85. </DataTrigger>
  86. <MultiDataTrigger>
  87. <MultiDataTrigger.Conditions>
  88. <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsMouseOver}" Value="True" />
  89. <Condition Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="False" />
  90. </MultiDataTrigger.Conditions>
  91. <MultiDataTrigger.Setters>
  92. <Setter TargetName="BdBorder" Property="BorderBrush" Value="Blue" />
  93. <Setter TargetName="BdBorder" Property="CornerRadius" Value="4" />
  94. </MultiDataTrigger.Setters>
  95. </MultiDataTrigger>
  96. </DataTemplate.Triggers>
  97. </DataTemplate>
  98. </ResourceDictionary>
  99. </UserControl.Resources>
  100. <Border BorderBrush="#F2F2F2" BorderThickness="0,1,0,0">
  101. <Grid>
  102. <Grid.RowDefinitions>
  103. <RowDefinition Height="40" />
  104. <RowDefinition />
  105. </Grid.RowDefinitions>
  106. <Grid Background="#FFFFFF">
  107. <StackPanel
  108. Name="StkpnlCenter"
  109. HorizontalAlignment="Center"
  110. Orientation="Horizontal">
  111. <Grid>
  112. <ComboBox
  113. Width="117"
  114. Height="23"
  115. ItemsSource="{Binding PageRangeItems}"
  116. SelectedIndex="{Binding ComboxSelectIndex, Mode=TwoWay}" />
  117. <TextBlock
  118. Width="90"
  119. Height="20"
  120. Margin="1,0"
  121. HorizontalAlignment="Left"
  122. VerticalAlignment="Center"
  123. Background="White"
  124. Text="{Binding TbPageRange}"
  125. Visibility="{Binding TbPageRangeVisibility}" />
  126. <TextBox
  127. Width="90"
  128. Height="20"
  129. Margin="1,0"
  130. HorizontalAlignment="Left"
  131. Background="White"
  132. InputMethod.IsInputMethodEnabled="False"
  133. IsVisibleChanged="TextBox_IsVisibleChanged"
  134. Visibility="{Binding TxtPageInputVisibility}">
  135. <i:Interaction.Triggers>
  136. <i:EventTrigger EventName="PreviewKeyDown">
  137. <i:InvokeCommandAction Command="{Binding PreviewKeyDown}" PassEventArgsToCommand="True" />
  138. </i:EventTrigger>
  139. <i:EventTrigger EventName="KeyDown">
  140. <i:InvokeCommandAction Command="{Binding KeyDown}" PassEventArgsToCommand="True" />
  141. </i:EventTrigger>
  142. </i:Interaction.Triggers>
  143. </TextBox>
  144. </Grid>
  145. <Button
  146. Width="20"
  147. Height="20"
  148. Margin="5"
  149. Command="{Binding LeftRotateCommand}">
  150. <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">
  151. <Path.RenderTransform>
  152. <TransformGroup>
  153. <TranslateTransform X="10.000000" Y="8.000000" />
  154. <ScaleTransform ScaleX="-1" ScaleY="1" />
  155. <TranslateTransform X="25.000000" Y="-8.000000" />
  156. </TransformGroup>
  157. </Path.RenderTransform>
  158. </Path>
  159. </Button>
  160. <Button
  161. Width="20"
  162. Height="20"
  163. Margin="5"
  164. Command="{Binding RightRotateCommand}">
  165. <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" />
  166. </Button>
  167. <Separator
  168. Width="1"
  169. Height="24"
  170. Margin="5,0"
  171. BorderBrush="#33000000"
  172. BorderThickness="5"
  173. Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
  174. <Button
  175. Height="20"
  176. Margin="5"
  177. Command="{Binding InsertCommand}"
  178. Content="插入" />
  179. <Button
  180. Height="20"
  181. Margin="5"
  182. Command="{Binding ExtractCommand}"
  183. Content="提取" />
  184. <Button
  185. Height="20"
  186. Margin="5"
  187. Command="{Binding ReplaceCommand}"
  188. Content="替换" />
  189. <Button
  190. Height="20"
  191. Margin="5"
  192. Command="{Binding SplitCommand}"
  193. Content="拆分" />
  194. <Button
  195. Height="20"
  196. Margin="5"
  197. Command="{Binding ReverseCommand}"
  198. Content="倒序" />
  199. <Separator
  200. Width="1"
  201. Height="24"
  202. Margin="5,0"
  203. BorderBrush="#33000000"
  204. BorderThickness="5"
  205. Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}" />
  206. <Button
  207. Height="20"
  208. Margin="5"
  209. Command="{Binding DeleteCommand}"
  210. Content="删除" />
  211. </StackPanel>
  212. <StackPanel
  213. Name="StkpnlRight"
  214. HorizontalAlignment="Right"
  215. Orientation="Horizontal">
  216. <Button
  217. Width="25"
  218. Height="25"
  219. Margin="4"
  220. Command="{Binding ZoomInCommand}">
  221. <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" />
  222. </Button>
  223. <Button
  224. Width="25"
  225. Height="25"
  226. Margin="4"
  227. Command="{Binding ZoomOutCommand}">
  228. <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" />
  229. </Button>
  230. </StackPanel>
  231. </Grid>
  232. <ListBox
  233. Name="ListPageEdit"
  234. Grid.Row="1"
  235. Padding="0"
  236. AllowDrop="True"
  237. ItemTemplate="{StaticResource PageEditListBoxItemTemplate}"
  238. ItemsSource="{Binding PageEditItems}"
  239. ScrollBar.Scroll="ListPageEdit_Scroll"
  240. ScrollViewer.ScrollChanged="ListPageEdit_ScrollChanged"
  241. SelectedIndex="{Binding ListSelectedIndex, Mode=TwoWay}"
  242. SelectionMode="Extended">
  243. <!-- 此处要用循环模式,否则滚动时容易误触发EndSscroll 从而频繁拿图导致卡顿 -->
  244. <ListBox.ItemContainerStyle>
  245. <Style TargetType="{x:Type ListBoxItem}">
  246. <Setter Property="Template" Value="{StaticResource ListBoxItemControlTemplate}" />
  247. <Setter Property="Margin" Value="0,10" />
  248. <Setter Property="Visibility" Value="{Binding Visible}" />
  249. <Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay}" />
  250. </Style>
  251. </ListBox.ItemContainerStyle>
  252. <ListBox.ItemsPanel>
  253. <ItemsPanelTemplate>
  254. <!-- item间距自适应 -->
  255. <wpftk:VirtualizingWrapPanel />
  256. </ItemsPanelTemplate>
  257. </ListBox.ItemsPanel>
  258. <i:Interaction.Triggers>
  259. <i:EventTrigger EventName="SelectionChanged">
  260. <i:InvokeCommandAction Command="{Binding SelectionChangedCommand}" PassEventArgsToCommand="True" />
  261. </i:EventTrigger>
  262. </i:Interaction.Triggers>
  263. </ListBox>
  264. <cus:ToastControl
  265. Grid.Row="1"
  266. Width="auto"
  267. Height="auto"
  268. Margin="0,0,0,200"
  269. VerticalAlignment="Bottom"
  270. Background="#89000000"
  271. BeginTime="0:0:0:3"
  272. CornerRadius="4"
  273. FontSize="14"
  274. Foreground="White"
  275. StringContent="Press Esc To Exit Full Mode"
  276. Visibility="{Binding ShowTip}"
  277. Duration="0:0:0:3" />
  278. <ProgressBar
  279. Grid.Row="1"
  280. Width="400"
  281. Height="50"
  282. IsIndeterminate="True"
  283. Visibility="{Binding IsLoading}" />
  284. </Grid>
  285. </Border>
  286. </UserControl>