RecentFilesControl.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using ComPDFKit.Controls.Helper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace ComPDFKit.Controls.PDFControl
  17. {
  18. /// <summary>
  19. /// Interaction logic for RecentFilesControl.xaml
  20. /// </summary>
  21. public partial class RecentFilesControl : UserControl
  22. {
  23. /// <summary>
  24. /// Open file event. Parameter is file path.
  25. /// </summary>
  26. public event EventHandler<OpenFileEventArgs> OpenFileEvent;
  27. public RecentFilesControl()
  28. {
  29. this.DataContext = FileHistoryHelper<PDFFileInfo>.Instance;
  30. InitializeComponent();
  31. }
  32. private void ListViewItem_DoubleClick(object sender, MouseButtonEventArgs e)
  33. {
  34. if (sender is ListViewItem listViewItem)
  35. {
  36. if (listViewItem.Content is PDFFileInfo fileInfo)
  37. {
  38. OpenFileEvent?.Invoke(this, new OpenFileEventArgs(FileOperationType.OpenFileDirectly, fileInfo.FilePath));
  39. }
  40. }
  41. }
  42. }
  43. }