DocItemListViewControl.xaml.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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> PrintItemHandler;
  30. public event EventHandler<RoutedEventArgs> FileInfoItemHandler;
  31. public event EventHandler<RoutedEventArgs> ShareItemHandler;
  32. public event EventHandler<RoutedEventArgs> FilePathItemHandler;
  33. public DocItemListViewControl()
  34. {
  35. InitializeComponent();
  36. SetLangText();
  37. }
  38. private void SetLangText()
  39. {
  40. }
  41. #region UI
  42. public bool IsHoverState
  43. {
  44. get { return (bool)GetValue(IsHoverStateProperty); }
  45. set { SetValue(IsHoverStateProperty, value); }
  46. }
  47. public static readonly DependencyProperty IsHoverStateProperty =
  48. DependencyProperty.Register("IsHoverState", typeof(bool), typeof(DocItemListViewControl), new PropertyMetadata(false));
  49. private void UserControl_MouseEnter(object sender, MouseEventArgs e)
  50. {
  51. IsHoverState = true;
  52. }
  53. private void UserControl_MouseLeave(object sender, MouseEventArgs e)
  54. {
  55. IsHoverState = false;
  56. }
  57. private void UserControl_MouseMove(object sender, MouseEventArgs e)
  58. {
  59. IsHoverState = true;
  60. }
  61. private void MoreButton_Initialized(object sender, EventArgs e)
  62. {
  63. MoreButton.ContextMenu = null;
  64. }
  65. private void MoreButton_Click(object sender, RoutedEventArgs e)
  66. {
  67. MenuMore.PlacementTarget = MoreButton;
  68. MenuMore.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
  69. MenuMore.IsOpen = true;
  70. }
  71. #endregion
  72. #region 事件
  73. private void MenuPrint_Click(object sender, RoutedEventArgs e)
  74. {
  75. PrintItemHandler.Invoke(sender, e);
  76. }
  77. private void MenuShare_Click(object sender, RoutedEventArgs e)
  78. {
  79. ShareItemHandler.Invoke(sender, e);
  80. }
  81. private void MenuFileInfo_Click(object sender, RoutedEventArgs e)
  82. {
  83. FileInfoItemHandler.Invoke(sender, e);
  84. }
  85. #endregion
  86. private void DeleteButton_Click(object sender, RoutedEventArgs e)
  87. {
  88. DeleteItemHandler.Invoke(sender, e);
  89. }
  90. private void MenuFilePath_Click(object sender, RoutedEventArgs e)
  91. {
  92. FilePathItemHandler.Invoke(sender, e);
  93. }
  94. private void MenuMore_Loaded(object sender, RoutedEventArgs e)
  95. {
  96. }
  97. private void Grid_Loaded(object sender, RoutedEventArgs e)
  98. {
  99. var grid = sender as Grid;
  100. if (grid != null)
  101. {
  102. var data = grid.DataContext as OpenFileInfo;
  103. if (data == null) return;
  104. if (File.Exists(data.ThumbImgPath))
  105. {
  106. CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
  107. }
  108. else if (data.ThumbImgPath.Equals("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png"))
  109. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
  110. else//最近文档 但是删除了缩略图的情况
  111. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_png_Large.png");
  112. }
  113. }
  114. }
  115. }