DefaultAnnotProperty.cs 2.3 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.Linq;
  10. using System.Windows;
  11. using ComPDFKit.PDFAnnotation;
  12. namespace PDFSettings
  13. {
  14. public class DefaultAnnotProperty
  15. {
  16. public AnnotArgsType AnnotToolType;
  17. public Color ForgoundColor;
  18. public Color BackgroundColor;
  19. public Color BorderColor;
  20. public double Opacity;
  21. public double Thickness;
  22. public double FontSize;
  23. public FontStyle FontStyle;
  24. public FontWeight FontWeight;
  25. public TextAlignment TextAlign;
  26. public string FontFamily = string.Empty;
  27. public string NoteText = string.Empty;
  28. public string SaveKey;
  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. }