DefaultAnnotProperty.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using ComPDFKitViewer.AnnotEvent;
  2. using System;
  3. using System.Collections;
  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 System.Windows;
  10. using ComPDFKit.PDFAnnotation;
  11. namespace PDFSettings
  12. {
  13. public class DefaultAnnotProperty
  14. {
  15. public AnnotArgsType AnnotToolType;
  16. public Color ForgoundColor;
  17. public Color BackgroundColor;
  18. public Color BorderColor;
  19. public double Opacity;
  20. public double Thickness;
  21. public double FontSize;
  22. public FontStyle FontStyle;
  23. public FontWeight FontWeight;
  24. public TextAlignment TextAlign;
  25. public string FontFamily = string.Empty;
  26. public string NoteText = string.Empty;
  27. public string SaveKey;
  28. public string NoteIcon;
  29. public C_LINE_TYPE HeadLineType;
  30. public C_LINE_TYPE TailLineType;
  31. public List<double> DashArray;
  32. public DefaultAnnotProperty()
  33. {
  34. AnnotToolType = AnnotArgsType.AnnotNone;
  35. }
  36. }
  37. public class DefaultAnnotProperties : List<DefaultAnnotProperty>
  38. {
  39. public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType)
  40. {
  41. return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType).FirstOrDefault();
  42. }
  43. public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType,string saveKey)
  44. {
  45. return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType && x.SaveKey==saveKey).FirstOrDefault();
  46. }
  47. public void SetAnnotProperty(DefaultAnnotProperty annotProperty)
  48. {
  49. DefaultAnnotProperty[] deleteArray = new DefaultAnnotProperty[0];
  50. if (annotProperty.SaveKey != null && annotProperty.SaveKey != string.Empty)
  51. {
  52. deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType && x.SaveKey == annotProperty.SaveKey).ToArray();
  53. }
  54. else
  55. {
  56. deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType).ToArray();
  57. }
  58. foreach (DefaultAnnotProperty deleteProperty in deleteArray)
  59. {
  60. this.Remove(deleteProperty);
  61. }
  62. this.Add(annotProperty);
  63. }
  64. }
  65. }