CPDFSecurityInfoControl.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using ComPDFKit.PDFDocument;
  2. using ComPDFKitViewer;
  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 PDFViewControl ViewControl;
  12. public void InitWithPDFViewer(PDFViewControl viewControl)
  13. {
  14. this.ViewControl = viewControl;
  15. if(viewControl!=null && viewControl.PDFViewTool != null )
  16. {
  17. CPDFViewer pdfViewer=viewControl.PDFViewTool.GetCPDFViewer();
  18. CPDFDocument pdfDoc=pdfViewer?.GetDocument();
  19. if(pdfDoc!=null)
  20. {
  21. InitializeSecurityInfo(pdfDoc);
  22. }
  23. }
  24. }
  25. public CPDFSecurityInfoControl()
  26. {
  27. InitializeComponent();
  28. }
  29. /// <summary>
  30. /// Pass in a boolean value and return the corresponding text.
  31. /// </summary>
  32. /// <param name="isTrue"></param>
  33. /// <returns></returns>
  34. private string GetStringFromBool(bool isTrue)
  35. {
  36. if (isTrue)
  37. {
  38. return T_Allowed;
  39. }
  40. else
  41. {
  42. return T_NotAllowed;
  43. }
  44. }
  45. private void InitializeSecurityInfo(CPDFDocument pdfDocument)
  46. {
  47. CPDFPermissionsInfo Permissions = pdfDocument.GetPermissionsInfo();
  48. AllowsPrintingTextBlock.Text = GetStringFromBool(Permissions.AllowsPrinting);
  49. AllowsCopyingTextBlock.Text = GetStringFromBool(Permissions.AllowsCopying);
  50. AllowsDocumentChangesTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentChanges);
  51. AllowsDocumentAssemblyTextBlock.Text = GetStringFromBool(Permissions.AllowsDocumentAssembly);
  52. AllowsCommentingTextBlock.Text = GetStringFromBool(Permissions.AllowsCommenting);
  53. AllowsFormFieldEntryTextBlock.Text = GetStringFromBool(Permissions.AllowsFormFieldEntry);
  54. }
  55. }
  56. }