CPDFSecurityInfoControl.xaml.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer.PdfViewer;
  3. using System.Windows.Controls;
  4. namespace Compdfkit_Tools.PDFControl
  5. {
  6. public partial class CPDFSecurityInfoControl : UserControl
  7. {
  8. private string T_Allowed = "Allowed";
  9. private string T_NotAllowed = "Not Allowed";
  10. public CPDFViewer pdfViewer;
  11. public void InitWithPDFViewer(CPDFViewer pdfViewer)
  12. {
  13. this.pdfViewer = pdfViewer;
  14. InitializeSecurityInfo(pdfViewer.Document);
  15. }
  16. public CPDFSecurityInfoControl()
  17. {
  18. InitializeComponent();
  19. }
  20. /// <summary>
  21. /// Pass in a boolean value and return the corresponding text.
  22. /// </summary>
  23. /// <param name="isTrue"></param>
  24. /// <returns></returns>
  25. private string GetStringFromBool(bool isTrue)
  26. {
  27. if (isTrue)
  28. {
  29. return T_Allowed;
  30. }
  31. else
  32. {
  33. return T_NotAllowed;
  34. }
  35. }
  36. private void InitializeSecurityInfo(CPDFDocument pdfDocument)
  37. {
  38. CPDFPermissionsInfo Permissions = pdfDocument.GetPermissionsInfo();
  39. AllowsPrintingTextBlock.Text = GetStringFromBool(Permissions.AllowsPrinting);
  40. AllowsCopyingTextBlock.Text = GetStringFromBool(Permissions.AllowsCopying);
  41. AllowsDocumentChangesTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentChanges);
  42. AllowsDocumentAssemblyTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentAssembly);
  43. AllowsCommentingTextBlock.Text = GetStringFromBool(Permissions.AllowsCommenting);
  44. AllowsFormFieldEntryTextBlock.Text = GetStringFromBool(Permissions.AllowsFormFieldEntry);
  45. }
  46. }
  47. }