DocItemListViewControl.xaml.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_Office.Helper;
  20. using PDFSettings.Settings;
  21. namespace PDF_Office.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. }
  38. #region UI
  39. public bool IsHoverState
  40. {
  41. get { return (bool)GetValue(IsHoverStateProperty); }
  42. set { SetValue(IsHoverStateProperty, value); }
  43. }
  44. public static readonly DependencyProperty IsHoverStateProperty =
  45. DependencyProperty.Register("IsHoverState", typeof(bool), typeof(DocItemListViewControl), new PropertyMetadata(false));
  46. private void UserControl_MouseEnter(object sender, MouseEventArgs e)
  47. {
  48. // IsHoverState = true;
  49. }
  50. private void UserControl_MouseLeave(object sender, MouseEventArgs e)
  51. {
  52. // IsHoverState = false;
  53. }
  54. private void UserControl_MouseMove(object sender, MouseEventArgs e)
  55. {
  56. // IsHoverState = true;
  57. }
  58. private void MoreButton_Initialized(object sender, EventArgs e)
  59. {
  60. MoreButton.ContextMenu = null;
  61. }
  62. private void MoreButton_Click(object sender, RoutedEventArgs e)
  63. {
  64. MenuMore.PlacementTarget = MoreButton;
  65. MenuMore.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
  66. MenuMore.IsOpen = true;
  67. }
  68. #endregion
  69. #region 事件
  70. #endregion
  71. private void DeleteButton_Click(object sender, RoutedEventArgs e)
  72. {
  73. DeleteItemHandler.Invoke(sender, e);
  74. }
  75. private void MenuMore_Loaded(object sender, RoutedEventArgs e)
  76. {
  77. }
  78. private void Grid_Loaded(object sender, RoutedEventArgs e)
  79. {
  80. var grid = sender as Grid;
  81. if (grid != null)
  82. {
  83. var data = grid.DataContext as OpenFileInfo;
  84. if (data == null) return;
  85. //显示新文档符号
  86. if (data.IsGuidPDF&& App.IsGuidPDFUpdated)
  87. {
  88. RecNewMark.Visibility = Visibility.Visible;
  89. }
  90. if (File.Exists(data.ThumbImgPath))
  91. {
  92. CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
  93. }
  94. else if (data.ThumbImgPath.Equals("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png"))
  95. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
  96. else//最近文档 但是删除了缩略图的情况
  97. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_png_Large.png");
  98. }
  99. }
  100. private void MenuOpenFile_Click(object sender, RoutedEventArgs e)
  101. {
  102. OpenFileItemHandler?.Invoke(sender, e);
  103. }
  104. private void MenuDelete_Click(object sender, RoutedEventArgs e)
  105. {
  106. DeleteItemHandler?.Invoke(sender, e);
  107. }
  108. }
  109. }