BookmarkContent.xaml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <UserControl
  2. x:Class="PDF_Office.Views.BOTA.BookmarkContent"
  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_Office.ViewModels.BOTA"
  6. xmlns:convert="clr-namespace:PDF_Office.DataConvert"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:data="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
  9. xmlns:helper="clr-namespace:PDF_Office.Helper"
  10. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  11. xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
  12. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  13. xmlns:prism="http://prismlibrary.com/"
  14. d:DataContext="{d:DesignInstance Type=bota:BookmarkContentViewModel}"
  15. d:DesignHeight="450"
  16. d:DesignWidth="300"
  17. prism:ViewModelLocator.AutoWireViewModel="True"
  18. mc:Ignorable="d">
  19. <UserControl.Resources>
  20. <ResourceDictionary>
  21. <ResourceDictionary.MergedDictionaries>
  22. <ResourceDictionary Source="pack://application:,,,/Styles/ListViewStyle.xaml" />
  23. <ResourceDictionary Source="pack://application:,,,/Styles/ButtonStyle.xaml" />
  24. </ResourceDictionary.MergedDictionaries>
  25. <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
  26. <convert:UnVisivleConvert x:Key="UnVisivleConvert" />
  27. <convert:ObjectConvert x:Key="ObjectConvert" />
  28. <DataTemplate x:Key="myDataTemplate" DataType="{x:Type data:CPDFBookmark}">
  29. <StackPanel
  30. Name="StackPanel"
  31. HorizontalAlignment="Stretch"
  32. VerticalAlignment="Stretch">
  33. <Grid Name="Grid" Margin="15,5">
  34. <Grid.ColumnDefinitions>
  35. <ColumnDefinition Width="10*" />
  36. <ColumnDefinition Width="90*" />
  37. </Grid.ColumnDefinitions>
  38. <!--<Image
  39. Grid.Column="0"
  40. Width="16"
  41. Height="16"
  42. Source="pack://application:,,,/Resources/BOTA/empty_bookmark.png" />-->
  43. <Path Grid.Column="0"
  44. Width="16"
  45. Height="16" Data="M3 3.47368C3 2.65979 3.65979 2 4.47368 2H11.5263C12.3402 2 13 2.65979 13 3.47368V14.3044C13 14.9486 12.2314 15.2826 11.7604 14.843L8.50276 11.8026C8.21966 11.5384 7.78034 11.5384 7.49724 11.8026L4.2396 14.843C3.7686 15.2826 3 14.9486 3 14.3044V3.47368Z" Fill="#94989C">
  46. <Path.RenderTransform>
  47. <TransformGroup>
  48. <TranslateTransform Y="-3" />
  49. </TransformGroup>
  50. </Path.RenderTransform>
  51. </Path>
  52. <TextBox
  53. Name="TxtTitleInput"
  54. Grid.Column="1"
  55. Padding="5"
  56. HorizontalContentAlignment="Left"
  57. Background="White"
  58. BorderThickness="1"
  59. FontSize="14"
  60. Text="{Binding Title}"
  61. TextWrapping="Wrap">
  62. <i:Interaction.Triggers>
  63. <i:EventTrigger EventName="KeyDown">
  64. <i:InvokeCommandAction Command="{Binding DataContext.KeyDownCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" PassEventArgsToCommand="True" />
  65. </i:EventTrigger>
  66. </i:Interaction.Triggers>
  67. </TextBox>
  68. <TextBlock
  69. Name="TxbTitle"
  70. Grid.Column="1"
  71. Padding="5"
  72. Background="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=Background}"
  73. FontSize="14"
  74. Text="{Binding Title}"
  75. Visibility="Visible" />
  76. </Grid>
  77. </StackPanel>
  78. </DataTemplate>
  79. <ContextMenu
  80. x:Key="ContextMenu"
  81. DataContext="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource Self}}"
  82. FontSize="14">
  83. <MenuItem Click="MenuItemRename_Click" Header="重命名" />
  84. <MenuItem
  85. Command="{Binding DataContext.EditPageIndexCommand, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"
  86. CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}, Path=PlacementTarget.DataContext}"
  87. Header="更改目标位置" />
  88. <MenuItem Click="MenuItemDeleteCommand_Click" Header="删除" />
  89. </ContextMenu>
  90. </ResourceDictionary>
  91. </UserControl.Resources>
  92. <Grid Background="#F2F2F2">
  93. <Grid.RowDefinitions>
  94. <RowDefinition Height="40" />
  95. <RowDefinition />
  96. </Grid.RowDefinitions>
  97. <Grid MinWidth="190">
  98. <TextBlock
  99. x:Name="TxtTitle"
  100. Margin="12,0,0,0"
  101. HorizontalAlignment="Left"
  102. VerticalAlignment="Center"
  103. FontSize="18"
  104. FontWeight="SemiBold"
  105. Text="Bookmarks" />
  106. <Button
  107. Name="BtnAddBookmark"
  108. Width="40"
  109. Height="40"
  110. Margin="0,0,0,0"
  111. Style="{StaticResource PageEditToolBtn}"
  112. HorizontalAlignment="Right"
  113. Command="{Binding AddBookmarkCommand}"
  114. CommandParameter="{Binding ElementName=BookMarkListView}">
  115. <Path Data="M13.5 8C13.5 11.0376 11.0376 13.5 8 13.5C4.96243 13.5 2.5 11.0376 2.5 8C2.5 4.96243 4.96243 2.5 8 2.5C11.0376 2.5 13.5 4.96243 13.5 8ZM15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM7.25005 4.80003V7.25003H4.80005V8.75003H7.25005V11.2H8.75005V8.75003H11.2V7.25003H8.75005V4.80003H7.25005Z" Fill="#616469">
  116. <Path.RenderTransform>
  117. <TransformGroup>
  118. <TranslateTransform Y="-3" />
  119. </TransformGroup>
  120. </Path.RenderTransform>
  121. </Path>
  122. </Button>
  123. </Grid>
  124. <Grid Grid.Row="1">
  125. <ListView
  126. Name="BookMarkListView"
  127. HorizontalContentAlignment="Stretch"
  128. Background="#F2F2F2"
  129. BorderThickness="0"
  130. ItemTemplate="{StaticResource myDataTemplate}"
  131. ItemsSource="{Binding Bookmarklist}"
  132. PreviewMouseDown="BookMarkListView_PreviewMouseDown"
  133. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  134. VirtualizingPanel.CacheLength="1"
  135. VirtualizingPanel.CacheLengthUnit="Page"
  136. VirtualizingPanel.IsVirtualizing="True"
  137. VirtualizingPanel.ScrollUnit="Pixel">
  138. <ListView.ItemsPanel>
  139. <ItemsPanelTemplate>
  140. <VirtualizingStackPanel Margin="-5,0,0,0" Background="Transparent" />
  141. </ItemsPanelTemplate>
  142. </ListView.ItemsPanel>
  143. <ListView.ItemContainerStyle>
  144. <Style BasedOn="{StaticResource ListViewItemGraySelectStyle}" TargetType="ListViewItem">
  145. <EventSetter Event="PreviewMouseDown" Handler="ListViewItem_MouseLeftButtonDown" />
  146. <EventSetter Event="LostFocus" Handler="ListViewItem_LostFocus" />
  147. <Setter Property="ContextMenu" Value="{StaticResource ContextMenu}" />
  148. </Style>
  149. </ListView.ItemContainerStyle>
  150. </ListView>
  151. </Grid>
  152. <StackPanel
  153. Name="EmptyPanel"
  154. Grid.RowSpan="2"
  155. Width="150"
  156. VerticalAlignment="Center"
  157. Visibility="{Binding IsEmptyPanelVisibility}">
  158. <Image
  159. Width="140"
  160. Height="140"
  161. Source="pack://application:,,,/Resources/BOTA/empty_bookmark.png" />
  162. <TextBlock
  163. Name="txtEmpty"
  164. Margin="0,12,0,0"
  165. FontFamily="Segoe UI"
  166. FontSize="16"
  167. Text="No bookmark"
  168. TextAlignment="Center" />
  169. </StackPanel>
  170. </Grid>
  171. </UserControl>