DocItemControl.xaml.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.IO;
  16. using PDFSettings;
  17. using PDF_Master.Helper;
  18. using ComPDFKit.PDFDocument;
  19. namespace PDF_Master.Views.HomePanel.RecentFiles
  20. {
  21. /// <summary>
  22. /// DocItemControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class DocItemControl : UserControl
  25. {
  26. public DocItemControl()
  27. {
  28. InitializeComponent();
  29. }
  30. private void Grid_Loaded(object sender, RoutedEventArgs e)
  31. {
  32. var grid = sender as Grid;
  33. if (grid != null)
  34. {
  35. var data = grid.DataContext as OpenFileInfo;
  36. if (data == null) return;
  37. if (data.IsGuidPDF && App.IsGuidPDFUpdated)
  38. {
  39. RecNewMark.Visibility = Visibility.Visible;
  40. }
  41. if (!string.IsNullOrEmpty(data.ThumbImgPath))
  42. CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
  43. else
  44. {
  45. CPDFDocument tempdoc = CPDFDocument.InitWithFilePath(data.FilePath);
  46. if (tempdoc != null && (bool)(tempdoc.IsLocked))
  47. {
  48. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
  49. }
  50. else
  51. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources//FilesType/ic_propertybar_file_png_Large.png");
  52. tempdoc?.Release();
  53. }
  54. }
  55. }
  56. private void Grid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
  57. {
  58. var grid = sender as Grid;
  59. if (grid != null&&CoverImage.Source==null)
  60. {
  61. var data = grid.DataContext as OpenFileInfo;
  62. if (data == null) return;
  63. if (data.IsGuidPDF && App.IsGuidPDFUpdated)
  64. {
  65. RecNewMark.Visibility = Visibility.Visible;
  66. }
  67. if (!string.IsNullOrEmpty(data.ThumbImgPath))
  68. CoverImage.Source = ToolMethod.GetFileThumbImg(data.ThumbImgPath);
  69. else
  70. {
  71. CPDFDocument tempdoc = CPDFDocument.InitWithFilePath(data.FilePath);
  72. if (tempdoc != null && (bool)(tempdoc.IsLocked))
  73. {
  74. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources/FilesType/ic_propertybar_file_pdf_lock.png");
  75. }
  76. else
  77. CoverImage.Source = ToolMethod.GetFileThumbImg("pack://application:,,,/Resources//FilesType/ic_propertybar_file_png_Large.png");
  78. tempdoc?.Release();
  79. }
  80. }
  81. }
  82. }
  83. }