DefaultEditProperty.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using ComPDFKit.PDFPage.Edit;
  2. using ComPDFKit.PDFPage;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows.Media;
  9. using ComPDFKitViewer.AnnotEvent;
  10. namespace PDFSettings
  11. {
  12. public class DefaultEditProperty
  13. {
  14. public bool IsItalic { get; set; }
  15. public bool ClipImage { get; set; }
  16. public bool HorizontalMirror { get; set; }
  17. public bool VerticalMirror { get; set; }
  18. public List<string> SystemFontNameList { get; }
  19. public int Transparency { get; set; }
  20. public bool IsBold { get; set; }
  21. public string ReplaceImagePath { get; set; }
  22. public string FontName { get; set; }
  23. public TextAlignType TextAlign { get; set; }
  24. public Color FontColor { get; set; }
  25. public bool AutoBlock { get; set; }
  26. public double FontSize { get; set; }
  27. public CPDFEditType EditType { get; set; }
  28. public int Rotate { get; set; } = 0;
  29. public string SaveKey;
  30. public DefaultEditProperty()
  31. {
  32. EditType = CPDFEditType.None;
  33. }
  34. }
  35. public class DefaultEditProperties : List<DefaultEditProperty>
  36. {
  37. public DefaultEditProperty GetEditProperty(CPDFEditType editType)
  38. {
  39. return this.AsEnumerable().Where(x => x.EditType == editType).FirstOrDefault();
  40. }
  41. public DefaultEditProperty GetEditProperty(CPDFEditType editType, string saveKey)
  42. {
  43. return this.AsEnumerable().Where(x => x.EditType == editType && x.SaveKey == saveKey).FirstOrDefault();
  44. }
  45. public void SetEditProperty(DefaultEditProperty editType)
  46. {
  47. DefaultEditProperty[] deleteArray = new DefaultEditProperty[0];
  48. if (editType.SaveKey != null && editType.SaveKey != string.Empty)
  49. {
  50. deleteArray = this.AsEnumerable().Where(x => x.EditType == editType.EditType && x.SaveKey == editType.SaveKey).ToArray();
  51. }
  52. else
  53. {
  54. deleteArray = this.AsEnumerable().Where(x => x.EditType == editType.EditType).ToArray();
  55. }
  56. foreach (DefaultEditProperty deleteProperty in deleteArray)
  57. {
  58. this.Remove(deleteProperty);
  59. }
  60. this.Add(editType);
  61. }
  62. }
  63. }