OutLineControl.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <UserControl
  2. x:Class="PDF_Master.Views.BOTA.OutLineControl"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:bota="clr-namespace:PDF_Master.ViewModels.BOTA"
  6. xmlns:customcontrol="clr-namespace:PDF_Master.CustomControl"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:local="clr-namespace:PDF_Master.Views.BOTA"
  9. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  10. xmlns:model="clr-namespace:PDF_Master.Model.BOTA"
  11. xmlns:mainPageLoader="clr-namespace:PDF_Master.Strings.MainPage"
  12. d:DataContext="{d:DesignInstance Type=bota:OutLineControlViewModel}"
  13. mc:Ignorable="d">
  14. <UserControl.Resources>
  15. <ResourceDictionary>
  16. <ResourceDictionary.MergedDictionaries>
  17. <ResourceDictionary Source="pack://application:,,,/PDF Master;component/Styles/OutLineItemStyle.xaml" />
  18. </ResourceDictionary.MergedDictionaries>
  19. </ResourceDictionary>
  20. </UserControl.Resources>
  21. <Grid Background="Transparent">
  22. <Grid.RowDefinitions>
  23. <RowDefinition Height="48" />
  24. <RowDefinition />
  25. </Grid.RowDefinitions>
  26. <Border BorderBrush="{StaticResource color.field.border.norm}" BorderThickness="0,0,0,1">
  27. <Grid x:Name="Header">
  28. <TextBlock
  29. x:Name="TxtTitle"
  30. Text="{Binding T_Title}"
  31. Margin="16,0,0,0"
  32. HorizontalAlignment="Left"
  33. VerticalAlignment="Center"
  34. FontFamily="Segoe UI"
  35. FontSize="14"
  36. FontWeight="SemiBold"/>
  37. <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
  38. <customcontrol:PathButton
  39. x:Name="BtnAdd"
  40. Width="32"
  41. Height="32"
  42. HorizontalContentAlignment="Center"
  43. Click="BtnAdd_Click"
  44. CornerRadius="4"
  45. Icon="{StaticResource Ic_AddButtonPath}"
  46. IconFill="#616469"
  47. IconHeight="16"
  48. IconMouseOver="{StaticResource Ic_AddButtonPath}"
  49. IconMouseOverFill="#616469"
  50. IconPress="{StaticResource Ic_AddButtonPath}"
  51. IconPressFill="#616469"
  52. IconWidth="16"
  53. MouseDownBackground="{StaticResource color.item-state.sel.bg.lv3}"
  54. MouseDownBorderBrush="{StaticResource color.item-state.sel.border.lv3}"
  55. MouseOverBackground="{StaticResource color.item-state.hov.bg}" />
  56. <customcontrol:PathButton
  57. x:Name="BtnMore"
  58. Width="32"
  59. Height="32"
  60. HorizontalContentAlignment="Center"
  61. Click="BtnMore_Click"
  62. CornerRadius="4"
  63. Icon="{StaticResource Ic_MoreButtonPath}"
  64. IconFill="#616469"
  65. IconHeight="16"
  66. IconMouseOver="{StaticResource Ic_MoreButtonPath}"
  67. IconMouseOverFill="#616469"
  68. IconPress="{StaticResource Ic_MoreButtonPath}"
  69. IconPressFill="#616469"
  70. IconWidth="16"
  71. MouseDownBackground="{StaticResource color.item-state.sel.bg.lv3}"
  72. MouseDownBorderBrush="{StaticResource color.item-state.sel.border.lv3}"
  73. MouseOverBackground="{StaticResource color.item-state.hov.bg}">
  74. <customcontrol:PathButton.ContextMenu>
  75. <ContextMenu Name="MenuMore">
  76. <ContextMenu.ItemContainerStyle>
  77. <Style BasedOn="{StaticResource GlobalMenuItem}" TargetType="MenuItem">
  78. <Setter Property="Padding" Value="-25,7,-40,7" />
  79. <Setter Property="VerticalContentAlignment" Value="Center" />
  80. </Style>
  81. </ContextMenu.ItemContainerStyle>
  82. <MenuItem
  83. Name="MenuExpandAll"
  84. Header="{Binding T_Expand}"
  85. Command="{Binding ExpandAllCommand}"
  86. CommandParameter="{Binding Outlinelist}" />
  87. <MenuItem
  88. Name="MenuCollapseAll"
  89. Header="{Binding T_Collapse}"
  90. Command="{Binding CollapseAllCommand}"
  91. CommandParameter="{Binding Outlinelist}"/>
  92. <MenuItem
  93. Name="MenuDeleteAll"
  94. Header="{Binding T_RemoveAll}"
  95. Command="{Binding DeleteAllCommand}" />
  96. </ContextMenu>
  97. </customcontrol:PathButton.ContextMenu>
  98. </customcontrol:PathButton>
  99. </StackPanel>
  100. </Grid>
  101. </Border>
  102. <StackPanel
  103. x:Name="FirstOulineLine"
  104. Margin="10,0"
  105. VerticalAlignment="Bottom"
  106. Orientation="Horizontal"
  107. Visibility="{Binding IsInsertHead, Converter={StaticResource BoolToVisible}}">
  108. <Ellipse
  109. Width="8"
  110. Height="8"
  111. HorizontalAlignment="Stretch"
  112. VerticalAlignment="Bottom"
  113. Fill="White"
  114. Stroke="#FF0078D7"
  115. StrokeThickness="1.5" />
  116. <Rectangle
  117. Width="{Binding ElementName=Header, Path=ActualWidth}"
  118. Height="1.5"
  119. Margin="-1,0,0,2"
  120. HorizontalAlignment="Stretch"
  121. VerticalAlignment="Bottom"
  122. Fill="#FF0078D7"
  123. StrokeDashArray="2" />
  124. </StackPanel>
  125. <Grid
  126. Grid.Row="1"
  127. DragLeave="Grid_DragLeave"
  128. DragOver="Grid_DragOver">
  129. <StackPanel
  130. x:Name="NoOutlineStackPanel"
  131. VerticalAlignment="Center"
  132. Visibility="{Binding Outlinelist.Count, Converter={StaticResource ListCountToVisible}}">
  133. <Image
  134. Width="128"
  135. Height="128"
  136. Source="pack://application:,,,/PDF Master;component/Resources/BOTA/no_outline.png" />
  137. <TextBlock
  138. Height="22"
  139. HorizontalAlignment="Center"
  140. FontFamily="Segoe UI"
  141. FontSize="14"
  142. Text="No outline found" />
  143. <TextBlock
  144. Width="168"
  145. HorizontalAlignment="Center"
  146. FontFamily="Segoe UI"
  147. FontSize="12"
  148. Foreground="#94989C"
  149. Text="Please right-click on the selected page and select Add Outline, or click the Add button on the upper right to create a outline."
  150. TextWrapping="Wrap" />
  151. </StackPanel>
  152. <TreeView
  153. x:Name="OutlineView"
  154. Grid.Row="1"
  155. AllowDrop="True"
  156. Background="Transparent"
  157. BorderThickness="0"
  158. Drop="OutlineView_Drop"
  159. ItemsSource="{Binding Outlinelist}"
  160. PreviewMouseDoubleClick="OutlineView_PreviewMouseDoubleClick"
  161. PreviewMouseLeftButtonUp="OutlineView_PreviewMouseLeftButtonUp"
  162. PreviewMouseMove="OutlineView_PreviewMouseMove"
  163. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  164. VirtualizingPanel.ScrollUnit="Pixel"
  165. Visibility="{Binding ElementName=NoOutlineStackPanel, Path=Visibility, Converter={StaticResource UnVisivleConvert}}">
  166. <TreeView.ItemTemplate>
  167. <HierarchicalDataTemplate DataType="{x:Type model:OutlineNode}" ItemsSource="{Binding Path=Chlidlist}">
  168. <Grid>
  169. <Grid.ContextMenu>
  170. <ContextMenu>
  171. <MenuItem
  172. x:Name="AddMenu"
  173. Click="AddMenu_Click"
  174. Header="{x:Static mainPageLoader:MainPage.Outline_Add}" />
  175. <MenuItem
  176. x:Name="AddChlidMenu"
  177. Click="AddChlidMenu_Click"
  178. Header="{x:Static mainPageLoader:MainPage.Outline_AddSub}" />
  179. <MenuItem
  180. x:Name="AddParentMenu"
  181. Click="AddParentMenu_Click"
  182. Header="{x:Static mainPageLoader:MainPage.Outline_AddLevel}"
  183. IsEnabled="{Binding CanAddParent}" />
  184. <MenuItem
  185. x:Name="DeleteMenu"
  186. Click="DeleteMenu_Click"
  187. Header="{x:Static mainPageLoader:MainPage.Outline_Delete}" />
  188. <MenuItem
  189. x:Name="RenameMenu"
  190. Click="RenameMenu_Click"
  191. Header="{x:Static mainPageLoader:MainPage.Outline_Rename}" />
  192. <MenuItem
  193. x:Name="ChangeDestinationMenu"
  194. Click="ChangeDestinationMenu_Click"
  195. Header="{x:Static mainPageLoader:MainPage.Outline_Change}" />
  196. <MenuItem
  197. x:Name="UpgradeMenu"
  198. Click="UpgradeMenu_Click"
  199. Header="{x:Static mainPageLoader:MainPage.Outline_Up}"
  200. IsEnabled="{Binding CanUp}" />
  201. <MenuItem
  202. x:Name="DowngradeMenu"
  203. Click="DowngradeMenu_Click"
  204. Header="{x:Static mainPageLoader:MainPage.Outline_Down}"
  205. IsEnabled="{Binding CanDown}" />
  206. </ContextMenu>
  207. </Grid.ContextMenu>
  208. <Grid x:Name="ContentPanel">
  209. <Grid.ToolTip>
  210. <!-- 圆角 https://wpf.2000things.com/2012/05/11/556-clipping-to-a-border-using-an-opacity-mask -->
  211. <ToolTip
  212. Width="320"
  213. Height="120"
  214. Closed="ToolTip_Closed"
  215. Opened="ToolTip_Opened"
  216. Style="{StaticResource ErrorRoundedTooltip}">
  217. <customcontrol:CustomImageControl
  218. Width="320"
  219. Height="120"
  220. HorizontalAlignment="Stretch"
  221. VerticalAlignment="Stretch" />
  222. </ToolTip>
  223. </Grid.ToolTip>
  224. <Grid.ColumnDefinitions>
  225. <ColumnDefinition />
  226. <ColumnDefinition Width="auto" />
  227. </Grid.ColumnDefinitions>
  228. <TextBlock
  229. x:Name="Content"
  230. VerticalAlignment="Center"
  231. Text="{Binding Outline.Title}"
  232. TextWrapping="WrapWithOverflow"
  233. Visibility="{Binding IsReName, Mode=TwoWay}" />
  234. <TextBlock
  235. x:Name="PageIndex"
  236. Grid.Column="1"
  237. HorizontalAlignment="Right"
  238. VerticalAlignment="Center"
  239. Text="{Binding PageIndex}" />
  240. </Grid>
  241. <StackPanel
  242. HorizontalAlignment="Stretch"
  243. Orientation="Horizontal"
  244. Visibility="{Binding IsInsertNextLayer, Converter={StaticResource BoolToVisible}}">
  245. <Ellipse
  246. Width="8"
  247. Height="8"
  248. Margin="0,0,0,0"
  249. VerticalAlignment="Bottom"
  250. Fill="White"
  251. Stroke="#FF0078D7"
  252. StrokeThickness="1.5" />
  253. <Line
  254. Margin="-1,0,0,2"
  255. HorizontalAlignment="Stretch"
  256. VerticalAlignment="Bottom"
  257. Stroke="#FF0078D7"
  258. StrokeDashArray="2"
  259. StrokeThickness="1.5"
  260. X1="0"
  261. X2="{Binding ElementName=ContentPanel, Path=ActualWidth}" />
  262. </StackPanel>
  263. <Grid
  264. x:Name="RenameGrid"
  265. LostFocus="RenameGrid_LostFocus"
  266. Visibility="{Binding ElementName=Content, Path=Visibility, Mode=TwoWay, Converter={StaticResource UnVisivleConvert}}">
  267. <TextBox
  268. x:Name="ReName"
  269. HorizontalAlignment="Left"
  270. VerticalAlignment="Center"
  271. IsVisibleChanged="ReName_IsVisibleChanged"
  272. KeyDown="ReName_KeyDown"
  273. Style="{StaticResource TextBoxStyleRadius}" />
  274. </Grid>
  275. </Grid>
  276. </HierarchicalDataTemplate>
  277. </TreeView.ItemTemplate>
  278. <TreeView.ItemContainerStyle>
  279. <Style BasedOn="{StaticResource OutLineItemStyle}" TargetType="TreeViewItem">
  280. <EventSetter Event="PreviewMouseLeftButtonUp" Handler="TreeViewItem_PreviewMouseLeftButtonUp" />
  281. <EventSetter Event="PreviewMouseLeftButtonDown" Handler="TreeViewItem_PreviewMouseLeftButtonDown" />
  282. </Style>
  283. </TreeView.ItemContainerStyle>
  284. </TreeView>
  285. </Grid>
  286. </Grid>
  287. </UserControl>