SetPasswordDialogModel.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using ComPDFKit.PDFDocument;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Runtime.CompilerServices;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PDF_Office.Model.Dialog.ToolsDialogs.SaftyDialogs
  10. {
  11. public class SetPasswordDialogModel
  12. {
  13. public enum EnumNeedPassword
  14. {
  15. StatusNeedOpenPassword = 1 << 0,
  16. StatusNeedPermissionsPassword = 1 << 1
  17. }
  18. public enum EnumPermissionsMod
  19. {
  20. StatusUnknown = 0,
  21. StatusRestrictPrinting = 1 << 0,
  22. StatusRestrictCopying = 1 << 1
  23. }
  24. public static CPDFPermissionsInfo CreateDefaultPermissionsInfo()
  25. {
  26. CPDFPermissionsInfo permissionsInfo = new CPDFPermissionsInfo();
  27. permissionsInfo.AllowsDocumentAssembly = true;
  28. permissionsInfo.AllowsDocumentChanges = true;
  29. permissionsInfo.AllowsPrinting = true;
  30. permissionsInfo.AllowsCopying = true;
  31. permissionsInfo.AllowsCommenting = true;
  32. permissionsInfo.AllowsFormFieldEntry = true;
  33. permissionsInfo.AllowsHighQualityPrinting = true;
  34. permissionsInfo.AllowsFormFieldEntry = true;
  35. return permissionsInfo;
  36. }
  37. public static CPDFPermissionsInfo CreatePermissionsInfo(EnumPermissionsMod enumPermissionsMod)
  38. {
  39. CPDFPermissionsInfo permissionsInfo = CreateDefaultPermissionsInfo();
  40. if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictPrinting) > 0)
  41. {
  42. permissionsInfo.AllowsPrinting = false;
  43. permissionsInfo.AllowsHighQualityPrinting = false;
  44. }
  45. if ((enumPermissionsMod & EnumPermissionsMod.StatusRestrictCopying) > 0)
  46. {
  47. permissionsInfo.AllowsCopying = false;
  48. }
  49. return permissionsInfo;
  50. }
  51. ///<returns>
  52. ///生成带有指定权限的CPDFPermissionsInfo对象
  53. ///</returns>
  54. }
  55. public class SecurityInfo
  56. {
  57. public bool IsPasswordChanged = false;
  58. public bool IsPasswordRemoved = false;
  59. public bool NeedOpenPassword = false;
  60. public bool NeedPermissionsPassword = false;
  61. public string OpenPassword = null;
  62. public string PermissionsPassword = null;
  63. public CPDFPermissionsInfo CPDFPermissionsInfo = SetPasswordDialogModel.CreateDefaultPermissionsInfo();
  64. }
  65. }