SearchContent.xaml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <UserControl x:Class="PDF_Office.Views.BOTA.SearchContent"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:PDF_Office.Views.BOTA"
  7. xmlns:prism="http://prismlibrary.com/"
  8. prism:ViewModelLocator.AutoWireViewModel="True"
  9. xmlns:bota="clr-namespace:PDF_Office.ViewModels.BOTA"
  10. d:DataContext="{d:DesignInstance Type=bota:SearchContentViewModel}"
  11. xmlns:helper="clr-namespace:PDF_Office.Helper"
  12. xmlns:convert="clr-namespace:PDF_Office.DataConvert"
  13. xmlns:customControl="clr-namespace:PDF_Office.CustomControl"
  14. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  15. mc:Ignorable="d"
  16. d:DesignHeight="450" d:DesignWidth="800">
  17. <UserControl.Resources>
  18. <convert:WidthConvert x:Key="WidthConvert"/>
  19. <convert:BoolToVisible x:Key="BoolToVisible"/>
  20. <convert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert"/>
  21. <convert:ListCountToVisible x:Key="ListCountToVisible" />
  22. <convert:UnVisivleConvert x:Key="UnVisivleConvert" />
  23. <Style x:Key="ListViewItemGraySelectStyle" TargetType="{x:Type ListViewItem}">
  24. <Setter Property="Visibility" Value="{Binding TextProperty.ItemVisibility}" />
  25. <Setter Property="UIElement.SnapsToDevicePixels"
  26. Value="True" />
  27. <Setter Property="Control.Padding"
  28. Value="4,1" />
  29. <Setter Property="Control.HorizontalContentAlignment">
  30. <Setter.Value>
  31. <Binding Path="HorizontalContentAlignment"
  32. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  33. </Setter.Value>
  34. </Setter>
  35. <Setter Property="Control.VerticalContentAlignment">
  36. <Setter.Value>
  37. <Binding Path="VerticalContentAlignment"
  38. RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ItemsControl, AncestorLevel=1}" />
  39. </Setter.Value>
  40. </Setter>
  41. <Setter Property="Panel.Background"
  42. Value="#00FFFFFF" />
  43. <Setter Property="Border.BorderBrush"
  44. Value="#00FFFFFF" />
  45. <Setter Property="Border.BorderThickness"
  46. Value="1" />
  47. <Setter Property="FrameworkElement.FocusVisualStyle">
  48. <Setter.Value>
  49. <Style TargetType="{x:Type IFrameworkInputElement}">
  50. <Setter Property="Control.Template">
  51. <Setter.Value>
  52. <ControlTemplate>
  53. <Rectangle Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
  54. StrokeThickness="1"
  55. StrokeDashArray="1 2"
  56. Margin="2"
  57. SnapsToDevicePixels="True" />
  58. </ControlTemplate>
  59. </Setter.Value>
  60. </Setter>
  61. </Style>
  62. </Setter.Value>
  63. </Setter>
  64. <Setter Property="Control.Template">
  65. <Setter.Value>
  66. <ControlTemplate TargetType="{x:Type ListViewItem}">
  67. <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
  68. Padding="{TemplateBinding Control.Padding}"
  69. BorderBrush="{TemplateBinding Border.BorderBrush}"
  70. Background="{TemplateBinding Panel.Background}"
  71. Name="Bd"
  72. SnapsToDevicePixels="True">
  73. <Border.ContextMenu>
  74. <ContextMenu>
  75. <MenuItem Header="加入新圆形" Tag="Round" Click="Create_Click"/>
  76. <MenuItem Header="加入新四边形" Tag="Rectangle" Click="Create_Click"/>
  77. <MenuItem Header="加入新高亮" Tag="Highlight" Click="Create_Click"/>
  78. <MenuItem Header="加入新下划线" Tag="Underline" Click="Create_Click"/>
  79. <MenuItem Header="加入新删除线" Tag="Strikethrough" Click="Create_Click"/>
  80. </ContextMenu>
  81. </Border.ContextMenu>
  82. <ContentPresenter Content="{TemplateBinding ContentControl.Content}"
  83. ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
  84. ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
  85. HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
  86. VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
  87. SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
  88. </Border>
  89. <ControlTemplate.Triggers>
  90. <MultiTrigger>
  91. <MultiTrigger.Conditions>
  92. <Condition Property="UIElement.IsMouseOver" Value="True" />
  93. </MultiTrigger.Conditions>
  94. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A000000" />
  95. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A000000" />
  96. </MultiTrigger>
  97. <MultiTrigger>
  98. <MultiTrigger.Conditions>
  99. <Condition Property="Selector.IsSelectionActive" Value="False" />
  100. <Condition Property="Selector.IsSelected" Value="True" />
  101. </MultiTrigger.Conditions>
  102. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  103. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  104. </MultiTrigger>
  105. <MultiTrigger>
  106. <MultiTrigger.Conditions>
  107. <Condition Property="Selector.IsSelectionActive" Value="True" />
  108. <Condition Property="Selector.IsSelected" Value="True" />
  109. </MultiTrigger.Conditions>
  110. <Setter Property="Panel.Background" TargetName="Bd" Value="#1A477EDE" />
  111. <Setter Property="Border.BorderBrush" TargetName="Bd" Value="#1A477EDE" />
  112. </MultiTrigger>
  113. <Trigger Property="UIElement.IsEnabled" Value="False">
  114. <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  115. </Trigger>
  116. </ControlTemplate.Triggers>
  117. </ControlTemplate>
  118. </Setter.Value>
  119. </Setter>
  120. </Style>
  121. <PathGeometry x:Key="Ic_MoreButtonPath" Figures="M5.83333 12.5C8.13452 12.5 10 10.6345 10 8.33333C10 6.03215 8.13452 4.16667 5.83333 4.16667C3.53215 4.16667 1.66667 6.03215 1.66667 8.33333C1.66667 10.6345 3.53215 12.5 5.83333 12.5ZM5.83333 14.1667C6.8191 14.1667 7.74775 13.9222 8.56195 13.4905L12.4581 17.3866L13.6366 16.2081L9.92222 12.4937C10.9989 11.4354 11.6667 9.96235 11.6667 8.33333C11.6667 5.11167 9.05499 2.5 5.83333 2.5C2.61167 2.5 0 5.11167 0 8.33333C0 11.555 2.61167 14.1667 5.83333 14.1667ZM13.5059 7.65166L16.1576 10.3033L18.8092 7.65166L19.9877 8.83017L16.7468 12.0711C16.4214 12.3965 15.8938 12.3965 15.5683 12.0711L12.3274 8.83017L13.5059 7.65166Z"/>
  122. </UserControl.Resources>
  123. <Grid Background="#F3F3F3" Width="212">
  124. <Grid.RowDefinitions>
  125. <RowDefinition Height="auto"/>
  126. <RowDefinition Height="auto"/>
  127. <RowDefinition/>
  128. </Grid.RowDefinitions>
  129. <Grid>
  130. <Grid.ColumnDefinitions>
  131. <ColumnDefinition Width="16"/>
  132. <ColumnDefinition Width="*"/>
  133. <ColumnDefinition Width="16"/>
  134. </Grid.ColumnDefinitions>
  135. <Grid.RowDefinitions>
  136. <RowDefinition Height="13"/>
  137. <RowDefinition Height="auto"/>
  138. <RowDefinition Height="8"/>
  139. <RowDefinition Height="auto"/>
  140. <RowDefinition Height="18"/>
  141. </Grid.RowDefinitions>
  142. <Grid Grid.Column="1" Grid.Row="1">
  143. <TextBlock Text="查找" HorizontalAlignment="Left" VerticalAlignment="Center"/>
  144. <Button Content="完成" Height="24" Width="45" HorizontalAlignment="Right" VerticalAlignment="Center" Style="{StaticResource Btn.cta}" Visibility="{Binding Completed}" Command="{Binding CleanCommand}"/>
  145. </Grid>
  146. <customControl:TextBoxEx x:Name="SearchText" Initialized="TextBoxEx_Initialized" Grid.Column="1" Grid.Row="3" Height="32" Padding="14,0,0,0" Width="180" HorizontalAlignment="Left" KeyDown="TextBox_KeyDown" >
  147. <customControl:TextBoxEx.ContextMenu>
  148. <ContextMenu Name="ContextSearchText" Width="180" ItemsSource="{Binding MyProperty}">
  149. <ContextMenu.ItemContainerStyle>
  150. <Style TargetType="MenuItem">
  151. <EventSetter Event="Click" Handler="MenuItem_Click"/>
  152. </Style>
  153. </ContextMenu.ItemContainerStyle>
  154. </ContextMenu>
  155. </customControl:TextBoxEx.ContextMenu>
  156. </customControl:TextBoxEx>
  157. <customControl:PathButton HorizontalAlignment="Left" Grid.Column="1" Grid.Row="3"
  158. Click="PathButton_Click"
  159. Margin="8,0,0,0"
  160. Width="20"
  161. Height="20"
  162. Icon="{StaticResource Ic_MoreButtonPath}"
  163. IconFill="#616469"
  164. IconHeight="20"
  165. IconMouseOver="{StaticResource Ic_MoreButtonPath}"
  166. IconMouseOverFill="#616469"
  167. IconPress="{StaticResource Ic_MoreButtonPath}"
  168. IconPressFill="#616469"
  169. IconWidth="20"
  170. CornerRadius="4"
  171. MouseOverBackground="{StaticResource color.item-state.hov.bg}"
  172. MouseDownBackground="{StaticResource color.item-state.sel.bg.lv3}"
  173. MouseDownBorderBrush="{StaticResource color.item-state.sel.border.lv3}"
  174. />
  175. </Grid>
  176. <Grid Grid.Row="1" Margin="10,0,10,0" Visibility="{Binding ElementName=NoSearch,Path=Visibility, Converter={StaticResource UnVisivleConvert}}">
  177. <TextBlock Margin="0,0,0,10" Text="All Result" VerticalAlignment="Center" HorizontalAlignment="Left"/>
  178. <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
  179. <TextBlock Margin="0,0,0,10" Text="Results:" VerticalAlignment="Center" HorizontalAlignment="Right"/>
  180. <TextBlock x:Name="TbCount" Margin="0,0,0,10" Text="{Binding SearchCount}" VerticalAlignment="Center" HorizontalAlignment="Right"/>
  181. </StackPanel>
  182. </Grid>
  183. <Grid Grid.Row="2">
  184. <ListView Name="SearchResultList" VirtualizingPanel.IsVirtualizingWhenGrouping="True"
  185. ItemsSource="{Binding SearchItemList}"
  186. BorderThickness="0" ItemContainerStyle="{StaticResource ListViewItemGraySelectStyle}"
  187. ScrollViewer.HorizontalScrollBarVisibility="Hidden">
  188. <ListView.GroupStyle>
  189. <GroupStyle >
  190. <GroupStyle.HeaderTemplate>
  191. <DataTemplate >
  192. <Grid Background="#E2E3E6" Height="24" >
  193. <TextBlock Padding="0,4,12,4" VerticalAlignment="Stretch" TextAlignment="Center" HorizontalAlignment="Left" FontWeight="SemiBold" FontSize="12" Text="{Binding Items.Count}"
  194. FontFamily="Segoe UI" Foreground="#666666 "/>
  195. <customControl:CustomIconToggleBtn x:Name="BtnExptend" Height="24"
  196. HorizontalAlignment="Right" Click="BtnExptend_Click"
  197. Style="{StaticResource ToggleBtnViewModeStyle}">
  198. <TextBlock Text="展开" VerticalAlignment="Center"/>
  199. </customControl:CustomIconToggleBtn>
  200. </Grid>
  201. </DataTemplate>
  202. </GroupStyle.HeaderTemplate>
  203. <GroupStyle.Panel >
  204. <ItemsPanelTemplate>
  205. <VirtualizingStackPanel Visibility="Visible"/>
  206. </ItemsPanelTemplate>
  207. </GroupStyle.Panel>
  208. </GroupStyle>
  209. </ListView.GroupStyle>
  210. <ListView.ItemsPanel>
  211. <ItemsPanelTemplate>
  212. <VirtualizingStackPanel Background="White" Margin="-5,0,0,0"></VirtualizingStackPanel>
  213. </ItemsPanelTemplate>
  214. </ListView.ItemsPanel>
  215. <ListView.ItemTemplate>
  216. <ItemContainerTemplate>
  217. <StackPanel>
  218. <RichTextBox Background="Transparent" Foreground="#000000" FontFamily="Segoe UI" FontSize="14" IsReadOnly="True" BorderThickness="0"
  219. Padding="12,6,10,6" VerticalContentAlignment="Center" VerticalAlignment="Center"
  220. helper:RichTextBoxHelper.DocumentBind="{Binding TextProperty}" Cursor="Arrow"
  221. Width="{Binding ElementName=SearchResultList,Path=ActualWidth,Converter={StaticResource WidthConvert}}"
  222. IsHitTestVisible="False">
  223. </RichTextBox>
  224. </StackPanel>
  225. </ItemContainerTemplate>
  226. </ListView.ItemTemplate>
  227. <i:Interaction.Triggers>
  228. <i:EventTrigger EventName="SelectionChanged">
  229. <i:InvokeCommandAction Command="{Binding SearchChangedCommand}" CommandParameter="{Binding ElementName=SearchResultList,Path=SelectedItem}"/>
  230. </i:EventTrigger>
  231. </i:Interaction.Triggers>
  232. </ListView>
  233. </Grid>
  234. <Grid x:Name="NoSearch" Grid.Row="0" Grid.RowSpan="3" Visibility="{Binding SearchItemList.Count, Converter={StaticResource ListCountToVisible}}">
  235. <StackPanel VerticalAlignment="Center" >
  236. <Image Source="pack://application:,,,/PDF Office;component/Resources/BOTA/no search.png" />
  237. <TextBlock
  238. Height="22"
  239. HorizontalAlignment="Center"
  240. FontFamily="Segoe UI"
  241. FontSize="14"
  242. Text="No search results" />
  243. <TextBlock
  244. Width="168"
  245. HorizontalAlignment="Center"
  246. FontFamily="Segoe UI"
  247. FontSize="12"
  248. Foreground="#94989C"
  249. TextAlignment="Center"
  250. Text="Search requests can be entered above."
  251. TextWrapping="Wrap" />
  252. </StackPanel>
  253. </Grid>
  254. </Grid>
  255. </UserControl>