CPDFAbstractInfoControl.xaml.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using ComPDFKit.PDFDocument;
  2. using Compdfkit_Tools.Helper;
  3. using ComPDFKitViewer;
  4. using System.Windows.Controls;
  5. namespace Compdfkit_Tools.PDFControl
  6. {
  7. public partial class CPDFAbstractInfoControl : UserControl
  8. {
  9. public PDFViewControl ViewControl;
  10. public void InitWithPDFViewer(PDFViewControl viewControl)
  11. {
  12. this.ViewControl = viewControl;
  13. if(viewControl!=null && viewControl.PDFViewTool != null)
  14. {
  15. CPDFViewer pdfViewer=viewControl.PDFViewTool.GetCPDFViewer();
  16. CPDFDocument pdfDoc=pdfViewer?.GetDocument();
  17. if(pdfDoc!=null)
  18. {
  19. InitializeAbstractInfo(pdfDoc);
  20. }
  21. }
  22. }
  23. public CPDFAbstractInfoControl()
  24. {
  25. InitializeComponent();
  26. }
  27. private void InitializeAbstractInfo(CPDFDocument cpdfDocument)
  28. {
  29. FileNameTextBlock.Text = cpdfDocument.FileName;
  30. FileSizeTextBlock.Text = CommonHelper.GetFileSize(cpdfDocument.FilePath);
  31. TitleTextBlock.Text = cpdfDocument.GetInfo().Title;
  32. AuthorTextBlock.Text = cpdfDocument.GetInfo().Author;
  33. SubjectTextBlock.Text = cpdfDocument.GetInfo().Subject;
  34. KeywordTextBlock.Text = cpdfDocument.GetInfo().Keywords;
  35. }
  36. }
  37. }