RecentFilesContent.xaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <UserControl
  2. x:Class="PDF_Office.Views.HomePanel.RecentFiles.RecentFilesContent"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:DataConvert="clr-namespace:PDF_Office.DataConvert"
  6. xmlns:customControl="clr-namespace:PDF_Office.CustomControl"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
  9. xmlns:local="clr-namespace:PDF_Office.Views.HomePanel.RecentFiles"
  10. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  11. xmlns:prism="http://prismlibrary.com/"
  12. d:DesignHeight="450"
  13. d:DesignWidth="800"
  14. prism:ViewModelLocator.AutoWireViewModel="True"
  15. Loaded="UserControl_Loaded"
  16. mc:Ignorable="d">
  17. <UserControl.Resources>
  18. <ResourceDictionary>
  19. <ResourceDictionary.MergedDictionaries>
  20. <ResourceDictionary Source="../../../Styles/ListViewStyle.xaml" />
  21. <ResourceDictionary Source="../../../Styles/CustomBtnStyle.xaml" />
  22. <ResourceDictionary Source="../../../Styles/RadioButtonStyle.xaml" />
  23. <ResourceDictionary Source="../../../Styles/ButtonStyle.xaml" />
  24. </ResourceDictionary.MergedDictionaries>
  25. <DataConvert:BoolToVisible x:Key="BoolToVisible" />
  26. <DataConvert:InvertBoolToVisibleConvert x:Key="InvertBoolToVisibleConvert" />
  27. <DataConvert:InvertBoolConvert x:Key="InvertBoolConvert" />
  28. <DataTemplate x:Key="listviewItem">
  29. <local:DocItemListViewControl
  30. HorizontalAlignment="Stretch"
  31. DeleteItemHandler="DocItemListViewControl_DeleteItemHandler"
  32. OpenFileItemHandler="DocItemListViewControl_OpenFileItemHandler" />
  33. </DataTemplate>
  34. <DataTemplate x:Key="gridviewItem">
  35. <local:DocItemControl HorizontalAlignment="Stretch" />
  36. </DataTemplate>
  37. <ItemsPanelTemplate x:Key="listPanel">
  38. <StackPanel Orientation="Vertical" />
  39. </ItemsPanelTemplate>
  40. <ItemsPanelTemplate x:Key="gridPanel">
  41. <WrapPanel />
  42. </ItemsPanelTemplate>
  43. <ContextMenu
  44. x:Key="FlyoutMenu"
  45. FontSize="14"
  46. Opened="ContextMenu_Opened">
  47. <ContextMenu.ItemContainerStyle>
  48. <Style TargetType="MenuItem">
  49. <Setter Property="Padding" Value="0,7,0,7" />
  50. <Setter Property="VerticalContentAlignment" Value="Center" />
  51. </Style>
  52. </ContextMenu.ItemContainerStyle>
  53. <MenuItem
  54. Name="FilePathMenuItem"
  55. Click="FilePathMenuItem_Click"
  56. Header="打开文件路径"
  57. IsEnabled="True">
  58. <MenuItem.Icon>
  59. <Path Data="M5.24031 1.5H0.5V14.5H15.5V4H7.24031L5.24031 1.5ZM1.5 13.5V2.5H4.75969L6.75969 5H14.5V13.5H1.5ZM4 7.5H12V6.5H4V7.5Z" Fill="Black">
  60. <Path.RenderTransform>
  61. <TranslateTransform X="3.0000" Y="0" />
  62. </Path.RenderTransform>
  63. </Path>
  64. </MenuItem.Icon>
  65. </MenuItem>
  66. <MenuItem
  67. Name="DeleteMenuItem"
  68. Click="DeleteMenuItem_Click"
  69. Header="从最近列表删除"
  70. IsEnabled="True">
  71. <MenuItem.Icon>
  72. <Path Data="M9 0H3V2H0V3H1V14H11V3H12V2H9V0ZM2 13V3H3H4H8H9H10V13H2ZM8 2V1H4V2H8ZM4 12V4H3V12H4ZM6.5 4V12H5.5V4H6.5ZM9 12V4H8V12H9Z" Fill="Black">
  73. <Path.RenderTransform>
  74. <TranslateTransform X="5.0000" Y="0" />
  75. </Path.RenderTransform>
  76. </Path>
  77. </MenuItem.Icon>
  78. </MenuItem>
  79. </ContextMenu>
  80. <Style
  81. x:Key="SubFilesListViewItemStyle"
  82. BasedOn="{StaticResource FilesListViewItemStyle}"
  83. TargetType="{x:Type ListViewItem}">
  84. <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}" />
  85. <Setter Property="HorizontalContentAlignment" Value="Center" />
  86. <Setter Property="Margin" Value="0,0,0,0" />
  87. <EventSetter Event="PreviewMouseRightButtonDown" Handler="ListViewItem_PreviewMouseRightButtonDown" />
  88. <EventSetter Event="PreviewMouseDoubleClick" Handler="RecentFilesList_PreviewMouseDoubleClick" />
  89. </Style>
  90. <Style
  91. x:Key="HomeGridViewItemStyle"
  92. BasedOn="{StaticResource FilesGridItemStyle}"
  93. TargetType="{x:Type ListViewItem}">
  94. <Setter Property="ContextMenu" Value="{StaticResource FlyoutMenu}" />
  95. <Setter Property="HorizontalContentAlignment" Value="Center" />
  96. <EventSetter Event="PreviewMouseRightButtonDown" Handler="ListViewItem_PreviewMouseRightButtonDown" />
  97. <EventSetter Event="PreviewMouseDoubleClick" Handler="RecentFilesList_PreviewMouseDoubleClick" />
  98. </Style>
  99. </ResourceDictionary>
  100. </UserControl.Resources>
  101. <Grid>
  102. <Grid>
  103. <Grid.RowDefinitions>
  104. <RowDefinition Height="Auto" />
  105. <RowDefinition Height="Auto" />
  106. <RowDefinition />
  107. </Grid.RowDefinitions>
  108. <Grid x:Name="GridRecentFilesTile" Margin="32,38,0,13">
  109. <TextBlock
  110. x:Name="TxbRecentlyTile"
  111. Margin="0,0,0,0"
  112. Padding="0,6,0,0"
  113. HorizontalAlignment="Left"
  114. FontSize="20"
  115. FontWeight="Semibold"
  116. Text="Recent" />
  117. <StackPanel
  118. x:Name="PnlRightBtns"
  119. Grid.Column="0"
  120. Grid.ColumnSpan="2"
  121. Margin="0,0,0,0"
  122. HorizontalAlignment="Right"
  123. Orientation="Horizontal">
  124. <Border
  125. Height="30"
  126. Padding="1,0,1,0"
  127. Background="#EEF2F3"
  128. CornerRadius="4">
  129. <StackPanel Orientation="Horizontal">
  130. <RadioButton
  131. x:Name="BtnListMode"
  132. Width="40"
  133. Height="28"
  134. HorizontalContentAlignment="Center"
  135. VerticalContentAlignment="Center"
  136. Foreground="#333333"
  137. GroupName="Mode"
  138. IsChecked="{Binding IsListMode, Mode=OneTime}"
  139. Style="{StaticResource ListModeRadioBtnStyle}"
  140. Tag="ListMode">
  141. <Grid Margin="-5,0,0,0" HorizontalAlignment="Center">
  142. <Path
  143. Data="M3 5L17 5"
  144. Stroke="{Binding ElementName=BtnListMode, Path=Foreground}"
  145. StrokeStartLineCap="Round"
  146. StrokeThickness="1.5" />
  147. <Path
  148. Data="M3 10H17"
  149. Stroke="{Binding ElementName=BtnListMode, Path=Foreground}"
  150. StrokeStartLineCap="Round"
  151. StrokeThickness="1.5" />
  152. <Path
  153. Data="M3 15H17"
  154. Stroke="{Binding ElementName=BtnListMode, Path=Foreground}"
  155. StrokeStartLineCap="Round"
  156. StrokeThickness="1.5" />
  157. </Grid>
  158. <i:Interaction.Triggers>
  159. <i:EventTrigger EventName="Checked">
  160. <i:InvokeCommandAction Command="{Binding ListModeCheckedCommand}" CommandParameter="{Binding ElementName=BtnListMode, Path=Tag}" />
  161. </i:EventTrigger>
  162. </i:Interaction.Triggers>
  163. </RadioButton>
  164. <RadioButton
  165. x:Name="BtnGridMode"
  166. Width="40"
  167. Height="28"
  168. HorizontalContentAlignment="Center"
  169. VerticalContentAlignment="Center"
  170. Foreground="#6B869C"
  171. GroupName="Mode"
  172. IsChecked="{Binding IsListMode, Converter={StaticResource InvertBoolConvert}, Mode=OneTime}"
  173. Style="{StaticResource ListModeRadioBtnStyle}"
  174. Tag="GridMode">
  175. <Grid Margin="-5,0,0,0" HorizontalAlignment="Center">
  176. <Grid.RowDefinitions>
  177. <RowDefinition />
  178. <RowDefinition />
  179. </Grid.RowDefinitions>
  180. <Grid.ColumnDefinitions>
  181. <ColumnDefinition />
  182. <ColumnDefinition />
  183. </Grid.ColumnDefinitions>
  184. <Rectangle
  185. Grid.Row="0"
  186. Grid.Column="0"
  187. Width="5"
  188. Height="5"
  189. Margin="1"
  190. Stroke="{Binding ElementName=BtnGridMode, Path=Foreground}"
  191. StrokeDashCap="Round"
  192. StrokeThickness="1.5" />
  193. <Rectangle
  194. Grid.Row="0"
  195. Grid.Column="1"
  196. Width="5"
  197. Height="5"
  198. Margin="1"
  199. Stroke="{Binding ElementName=BtnGridMode, Path=Foreground}"
  200. StrokeDashCap="Round"
  201. StrokeThickness="1.5" />
  202. <Rectangle
  203. Grid.Row="1"
  204. Grid.Column="0"
  205. Width="5"
  206. Height="5"
  207. Margin="1"
  208. Stroke="{Binding ElementName=BtnGridMode, Path=Foreground}"
  209. StrokeDashCap="Round"
  210. StrokeThickness="1.5" />
  211. <Rectangle
  212. Grid.Row="1"
  213. Grid.Column="1"
  214. Width="5"
  215. Height="5"
  216. Margin="1"
  217. Stroke="{Binding ElementName=BtnGridMode, Path=Foreground}"
  218. StrokeDashCap="Round"
  219. StrokeThickness="1.5" />
  220. </Grid>
  221. <i:Interaction.Triggers>
  222. <i:EventTrigger EventName="Checked">
  223. <i:InvokeCommandAction Command="{Binding ListModeCheckedCommand}" CommandParameter="{Binding ElementName=BtnGridMode, Path=Tag}" />
  224. </i:EventTrigger>
  225. </i:Interaction.Triggers>
  226. </RadioButton>
  227. </StackPanel>
  228. </Border>
  229. <Separator
  230. Width="1"
  231. Height="16"
  232. Margin="1,0,1,0"
  233. BorderBrush="#1A000000"
  234. BorderThickness="1" />
  235. <Button
  236. x:Name="BtnDelete"
  237. Width="28"
  238. Height="28"
  239. MaxHeight="40"
  240. Margin="0"
  241. Padding="0,0,0,0"
  242. Background="Transparent"
  243. BorderThickness="0"
  244. Command="{Binding RemoveFilesFromContainerCommand}"
  245. CommandParameter="{Binding ElementName=RecentFilesList, Path=SelectedItems}"
  246. Foreground="#6B6F7D"
  247. IsEnabled="{Binding IsEmpty, Converter={StaticResource InvertBoolConvert}, Mode=OneWay}"
  248. Style="{StaticResource OnlyContentBtn}">
  249. <Grid Width="20" Height="20">
  250. <Path
  251. Data="M8 2H12"
  252. Stroke="{Binding ElementName=BtnDelete, Path=Foreground}"
  253. StrokeDashCap="Round"
  254. StrokeThickness="2" />
  255. <Path
  256. Data="M5 5V17H15V5"
  257. Stroke="{Binding ElementName=BtnDelete, Path=Foreground}"
  258. StrokeDashCap="Round"
  259. StrokeThickness="2" />
  260. <Path
  261. Data="M17 5H3"
  262. Stroke="{Binding ElementName=BtnDelete, Path=Foreground}"
  263. StrokeDashCap="Round"
  264. StrokeThickness="2" />
  265. <Path
  266. Data="M10 9V13"
  267. Stroke="{Binding ElementName=BtnDelete, Path=Foreground}"
  268. StrokeDashCap="Round"
  269. StrokeThickness="2" />
  270. </Grid>
  271. </Button>
  272. </StackPanel>
  273. </Grid>
  274. <Grid Grid.Row="2" Visibility="{Binding IsEmpty, Converter={StaticResource InvertBoolToVisibleConvert}}">
  275. <Grid.ColumnDefinitions>
  276. <ColumnDefinition Width="799*" />
  277. <ColumnDefinition Width="*" />
  278. </Grid.ColumnDefinitions>
  279. <Border Visibility="{Binding IsListMode, Converter={StaticResource BoolToVisible}}">
  280. <ListView
  281. x:Name="RecentFilesList"
  282. Grid.ColumnSpan="2"
  283. MinWidth="380"
  284. MinHeight="216"
  285. Margin="32,0,0,0"
  286. Padding="0,0,0,0"
  287. Background="Transparent"
  288. BorderThickness="0"
  289. ItemContainerStyle="{StaticResource SubFilesListViewItemStyle}"
  290. ItemTemplate="{StaticResource listviewItem}"
  291. ItemsPanel="{StaticResource listPanel}"
  292. ItemsSource="{Binding RecentFilesGroup}"
  293. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  294. ScrollViewer.VerticalScrollBarVisibility="Auto"
  295. SelectionMode="Extended"
  296. Style="{StaticResource FilesListViewStyle}"
  297. VirtualizingPanel.CacheLength="1"
  298. VirtualizingPanel.CacheLengthUnit="Page"
  299. VirtualizingPanel.IsVirtualizing="True"
  300. VirtualizingPanel.ScrollUnit="Pixel" />
  301. </Border>
  302. <ListView
  303. x:Name="GridRecentFilesList"
  304. Grid.ColumnSpan="2"
  305. MinWidth="380"
  306. MinHeight="216"
  307. Margin="32,0,0,0"
  308. Padding="0,0,0,0"
  309. Background="Transparent"
  310. BorderThickness="0"
  311. ItemContainerStyle="{StaticResource HomeGridViewItemStyle}"
  312. ItemTemplate="{StaticResource gridviewItem}"
  313. ItemsPanel="{StaticResource gridPanel}"
  314. ItemsSource="{Binding RecentFilesGroup}"
  315. ScrollViewer.HorizontalScrollBarVisibility="Disabled"
  316. ScrollViewer.VerticalScrollBarVisibility="Auto"
  317. SelectionMode="Extended"
  318. Style="{StaticResource FilesGridViewStyle}"
  319. VirtualizingPanel.CacheLength="1"
  320. VirtualizingPanel.CacheLengthUnit="Page"
  321. VirtualizingPanel.IsVirtualizing="True"
  322. VirtualizingPanel.ScrollUnit="Pixel"
  323. Visibility="{Binding IsListMode, Converter={StaticResource InvertBoolToVisibleConvert}}" />
  324. </Grid>
  325. <StackPanel
  326. x:Name="BlankContentPanel"
  327. Grid.Row="1"
  328. Grid.RowSpan="2"
  329. HorizontalAlignment="Center"
  330. VerticalAlignment="Center"
  331. Visibility="{Binding IsEmpty, Converter={StaticResource BoolToVisible}}">
  332. <Button
  333. x:Name="BtnAddFiles"
  334. Width="128"
  335. Height="128"
  336. MaxHeight="128"
  337. Background="Transparent"
  338. BorderThickness="0"
  339. Command="{Binding OpenFilesCommand}"
  340. Foreground="#6B6F7D"
  341. Style="{StaticResource OnlyContentBtn}">
  342. <Grid Width="128" Height="128">
  343. <Image
  344. Width="128"
  345. Height="128"
  346. VerticalAlignment="Center"
  347. Source="../../../Resources/HomeIcon/add.png"
  348. Stretch="Uniform" />
  349. </Grid>
  350. </Button>
  351. <TextBlock
  352. x:Name="NoFilesText"
  353. HorizontalAlignment="Center"
  354. FontFamily="Segoe UI"
  355. FontSize="16"
  356. Foreground="#FF333333"
  357. LineHeight="22"
  358. Text="No documents"
  359. TextAlignment="Center" />
  360. <StackPanel Margin="0,12,0,0" Orientation="Horizontal">
  361. <TextBlock
  362. x:Name="clickFileText"
  363. VerticalAlignment="Center"
  364. FontSize="14"
  365. Foreground="#FF999999"
  366. Text="Drop documents here or click the '" />
  367. </StackPanel>
  368. </StackPanel>
  369. </Grid>
  370. </Grid>
  371. </UserControl>