OutLineControl.xaml 15 KB

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