HomePageSetPasswordDialogModel.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using ComPDFKit.PDFDocument;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing
  8. {
  9. public class HomePageSetPasswordDialogModel
  10. {
  11. public bool CanOpen { get; set; }
  12. public bool CanEdit { get; set; }
  13. public static string PasswordForOpen = "";
  14. public static string PasswordForEdit { get; set; }
  15. public enum PrintMod
  16. {
  17. None,
  18. LowDpi,
  19. HighDpi
  20. }
  21. public enum ChangeMod
  22. {
  23. None,
  24. ChangePage,
  25. FormAndSignature,
  26. AnnotAndFormAndSignature,
  27. ExceptAbstrat
  28. }
  29. public enum EnumNeedPassword
  30. {
  31. StatusNeedOpenPassword = 1 << 0,
  32. StatusNeedPermissionsPassword = 1 << 1
  33. }
  34. public enum EnumPermissionsMod
  35. {
  36. StatusUnknown = 0,
  37. StatusRestrictPrinting = 1 << 0,
  38. StatusRestrictCopying = 1 << 1
  39. }
  40. public static CPDFPermissionsInfo CreatePermissionsInfo(EnumPermissionsMod enumPermissionsMod)
  41. {
  42. CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
  43. permissionsInfo.AllowsDocumentAssembly = true;
  44. permissionsInfo.AllowsDocumentChanges = true;
  45. permissionsInfo.AllowsPrinting = true;
  46. permissionsInfo.AllowsCopying = true;
  47. permissionsInfo.AllowsCommenting = true;
  48. permissionsInfo.AllowsFormFieldEntry = true;
  49. permissionsInfo.AllowsHighQualityPrinting = true;
  50. permissionsInfo.AllowsFormFieldEntry = true;
  51. if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictPrinting) > 0)
  52. {
  53. permissionsInfo.AllowsPrinting = false;
  54. permissionsInfo.AllowsHighQualityPrinting = false;
  55. }
  56. if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictCopying) > 0)
  57. {
  58. permissionsInfo.AllowsCopying = false;
  59. }
  60. return permissionsInfo;
  61. }
  62. ///<returns>
  63. ///生成带有指定权限的CPDFPermissionsInfo对象
  64. ///</returns>
  65. public CPDFPermissionsInfo CreatePermissionsInfo(PrintMod printMod, ChangeMod changeMod)
  66. {
  67. CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
  68. switch (printMod)
  69. {
  70. case PrintMod.None:
  71. permissionsInfo.AllowsPrinting = false;
  72. permissionsInfo.AllowsHighQualityPrinting = false;
  73. break;
  74. case PrintMod.LowDpi:
  75. permissionsInfo.AllowsPrinting = true;
  76. permissionsInfo.AllowsHighQualityPrinting = false;
  77. break;
  78. case PrintMod.HighDpi:
  79. permissionsInfo.AllowsHighQualityPrinting = true;
  80. permissionsInfo.AllowsPrinting = true;
  81. break;
  82. default:
  83. break;
  84. }
  85. switch (changeMod)
  86. {
  87. case ChangeMod.None:
  88. permissionsInfo.AllowsCopying = false;
  89. permissionsInfo.AllowsDocumentAssembly = false;
  90. permissionsInfo.AllowsCommenting = false;
  91. permissionsInfo.AllowsDocumentChanges = false;
  92. permissionsInfo.AllowsFormFieldEntry = false;
  93. break;
  94. case ChangeMod.ChangePage:
  95. permissionsInfo.AllowsCopying = false;
  96. permissionsInfo.AllowsDocumentAssembly = true;
  97. permissionsInfo.AllowsCommenting = false;
  98. permissionsInfo.AllowsDocumentChanges = false;
  99. permissionsInfo.AllowsFormFieldEntry = false;
  100. break;
  101. case ChangeMod.FormAndSignature:
  102. permissionsInfo.AllowsCopying = false;
  103. permissionsInfo.AllowsDocumentAssembly = false;
  104. permissionsInfo.AllowsCommenting = false;
  105. permissionsInfo.AllowsDocumentChanges = false;
  106. permissionsInfo.AllowsFormFieldEntry = true;
  107. break;
  108. case ChangeMod.AnnotAndFormAndSignature:
  109. permissionsInfo.AllowsCopying = false;
  110. permissionsInfo.AllowsDocumentAssembly = false;
  111. permissionsInfo.AllowsCommenting = true;
  112. permissionsInfo.AllowsDocumentChanges = false;
  113. permissionsInfo.AllowsFormFieldEntry = true;
  114. break;
  115. case ChangeMod.ExceptAbstrat:
  116. permissionsInfo.AllowsCopying = true;
  117. permissionsInfo.AllowsDocumentAssembly = true;
  118. permissionsInfo.AllowsCommenting = true;
  119. permissionsInfo.AllowsDocumentChanges = false;
  120. permissionsInfo.AllowsFormFieldEntry = true;
  121. break;
  122. }
  123. return permissionsInfo;
  124. }
  125. }
  126. }