CPDFSecurityInfoControl.xaml.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer.PdfViewer;
  3. using System;
  4. using System.Collections.Generic;
  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. namespace compdfkit_tools.PDFControl
  18. {
  19. /// <summary>
  20. /// PDFSecurityInfoControl.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class CPDFSecurityInfoControl : UserControl
  23. {
  24. private string T_Allowed = "Allowed";
  25. private string T_NotAllowed = "Not Allowed";
  26. public CPDFViewer pdfViewer;
  27. public void InitWithPDFViewer(CPDFViewer pdfViewer)
  28. {
  29. this.pdfViewer = pdfViewer;
  30. InitializeSecurityInfo(pdfViewer.Document);
  31. }
  32. public CPDFSecurityInfoControl()
  33. {
  34. InitializeComponent();
  35. }
  36. /// <summary>
  37. /// Pass in a boolean value and return the corresponding text.
  38. /// </summary>
  39. /// <param name="isTrue"></param>
  40. /// <returns></returns>
  41. private string GetStringFromBool(bool isTrue)
  42. {
  43. if (isTrue)
  44. {
  45. return T_Allowed;
  46. }
  47. else
  48. {
  49. return T_NotAllowed;
  50. }
  51. }
  52. private void InitializeSecurityInfo(CPDFDocument pdfDocument)
  53. {
  54. CPDFPermissionsInfo Permissions = pdfDocument.GetPermissionsInfo();
  55. AllowsPrintingTextBlock.Text = GetStringFromBool(Permissions.AllowsPrinting);
  56. AllowsCopyingTextBlock.Text = GetStringFromBool(Permissions.AllowsCopying);
  57. AllowsDocumentChangesTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentChanges);
  58. AllowsDocumentAssemblyTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentAssembly);
  59. AllowsCommentingTextBlock.Text = GetStringFromBool(Permissions.AllowsCommenting);
  60. AllowsFormFieldEntryTextBlock.Text = GetStringFromBool(Permissions.AllowsFormFieldEntry);
  61. }
  62. }
  63. }