DocItemListViewControl.xaml.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Navigation;
  16. using System.Windows.Shapes;
  17. using ComPDFKit.PDFDocument;
  18. using ComPDFKitViewer.PdfViewer;
  19. using PDF_Master.Helper;
  20. using PDFSettings;
  21. namespace PDF_Master.Views.HomePanel.RecentFiles
  22. {
  23. /// <summary>
  24. /// DocItemListViewControl.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class DocItemListViewControl : UserControl
  27. {
  28. public event EventHandler<RoutedEventArgs> DeleteItemHandler;
  29. public event EventHandler<RoutedEventArgs> OpenFileItemHandler;
  30. public DocItemListViewControl()
  31. {
  32. InitializeComponent();
  33. SetLangText();
  34. }
  35. private void SetLangText()
  36. {
  37. MenuOpenFile.Header = App.HomePageLoader.GetString("Home_OpenFiles");
  38. MenuDelete.Header = App.HomePageLoader.GetString("HomeList_MenuRemove");
  39. }
  40. #region UI
  41. public bool IsHoverState
  42. {
  43. get { return (bool)GetValue(IsHoverStateProperty); }
  44. set { SetValue(IsHoverStateProperty, value); }
  45. }
  46. public static readonly DependencyProperty IsHoverStateProperty =
  47. DependencyProperty.Register("IsHoverState", typeof(bool), typeof(DocItemListViewControl), new PropertyMetadata(false));
  48. private void UserControl_MouseEnter(object sender, MouseEventArgs e)
  49. {
  50. // IsHoverState = true;
  51. }
  52. private void UserControl_MouseLeave(object sender, MouseEventArgs e)
  53. {
  54. // IsHoverState = false;
  55. }
  56. private void UserControl_MouseMove(object sender, MouseEventArgs e)
  57. {
  58. // IsHoverState = true;
  59. }
  60. private void MoreButton_Initialized(object sender, EventArgs e)
  61. {
  62. MoreButton.ContextMenu = null;
  63. }
  64. private void MoreButton_Click(object sender, RoutedEventArgs e)
  65. {
  66. MenuMore.PlacementTarget = MoreButton;
  67. MenuMore.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
  68. MenuMore.IsOpen = true;
  69. }
  70. #endregion
  71. #region 事件
  72. #endregion
  73. private void DeleteButton_Click(object sender, RoutedEventArgs e)
  74. {
  75. DeleteItemHandler.Invoke(sender, e);
  76. }
  77. private void MenuMore_Loaded(object sender, RoutedEventArgs e)
  78. {
  79. }
  80. private void Grid_Loaded(object sender, RoutedEventArgs e)
  81. {
  82. var grid = sender as Grid;
  83. if (grid != null)
  84. {
  85. var data = grid.DataContext as OpenFileInfo;
  86. if (data == null) return;
  87. //显示新文档符号
  88. if (data.IsGuidPDF&& App.IsGuidPDFUpdated)
  89. {
  90. RecNewMark.Visibility = Visibility.Visible;
  91. }
  92. if (File.Exists(data.ThumbImgPath))
  93. {
  94. CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
  95. }
  96. else if (data.ThumbImgPath.Equals("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png"))
  97. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
  98. else//最近文档 但是删除了缩略图的情况
  99. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_png_Large.png");
  100. }
  101. }
  102. private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
  103. {
  104. OpenFileItemHandler?.Invoke(sender, e);
  105. }
  106. private void MenuDelete_Click(object sender, RoutedEventArgs e)
  107. {
  108. DeleteItemHandler?.Invoke(sender, e);
  109. }
  110. }
  111. }