CPDFSecurityInfoControl.xaml.cs 1.9 KB

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