HomePageSetPasswordDialogModel.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 { get; set; }
  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. ///<returns>
  30. ///生成带有指定权限的CPDFPermissionsInfo对象
  31. ///</returns>
  32. public CPDFPermissionsInfo CreatePermissionsInfo(PrintMod printMod, ChangeMod changeMod)
  33. {
  34. CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
  35. switch (printMod)
  36. {
  37. case PrintMod.None:
  38. permissionsInfo.AllowsPrinting = false;
  39. permissionsInfo.AllowsHighQualityPrinting = false;
  40. break;
  41. case PrintMod.LowDpi:
  42. permissionsInfo.AllowsPrinting = true;
  43. permissionsInfo.AllowsHighQualityPrinting = false;
  44. break;
  45. case PrintMod.HighDpi:
  46. permissionsInfo.AllowsHighQualityPrinting = true;
  47. permissionsInfo.AllowsPrinting = true;
  48. break;
  49. default:
  50. break;
  51. }
  52. switch (changeMod)
  53. {
  54. case ChangeMod.None:
  55. permissionsInfo.AllowsCopying = false;
  56. permissionsInfo.AllowsDocumentAssembly = false;
  57. permissionsInfo.AllowsCommenting = false;
  58. permissionsInfo.AllowsDocumentChanges = false;
  59. permissionsInfo.AllowsFormFieldEntry = false;
  60. break;
  61. case ChangeMod.ChangePage:
  62. permissionsInfo.AllowsCopying = false;
  63. permissionsInfo.AllowsDocumentAssembly = true;
  64. permissionsInfo.AllowsCommenting = false;
  65. permissionsInfo.AllowsDocumentChanges = false;
  66. permissionsInfo.AllowsFormFieldEntry = false;
  67. break;
  68. case ChangeMod.FormAndSignature:
  69. permissionsInfo.AllowsCopying = false;
  70. permissionsInfo.AllowsDocumentAssembly = false;
  71. permissionsInfo.AllowsCommenting = false;
  72. permissionsInfo.AllowsDocumentChanges = false;
  73. permissionsInfo.AllowsFormFieldEntry = true;
  74. break;
  75. case ChangeMod.AnnotAndFormAndSignature:
  76. permissionsInfo.AllowsCopying = false;
  77. permissionsInfo.AllowsDocumentAssembly = false;
  78. permissionsInfo.AllowsCommenting = true;
  79. permissionsInfo.AllowsDocumentChanges = false;
  80. permissionsInfo.AllowsFormFieldEntry = true;
  81. break;
  82. case ChangeMod.ExceptAbstrat:
  83. permissionsInfo.AllowsCopying = true;
  84. permissionsInfo.AllowsDocumentAssembly = true;
  85. permissionsInfo.AllowsCommenting = true;
  86. permissionsInfo.AllowsDocumentChanges = false;
  87. permissionsInfo.AllowsFormFieldEntry = true;
  88. break;
  89. }
  90. return permissionsInfo;
  91. }
  92. }
  93. }