DefaultAnnotProperty.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 string NoteIcon;
  30. public C_LINE_TYPE HeadLineType;
  31. public C_LINE_TYPE TailLineType;
  32. public List<double> DashArray;
  33. public DefaultAnnotProperty()
  34. {
  35. AnnotToolType = AnnotArgsType.AnnotNone;
  36. }
  37. }
  38. public class DefaultAnnotProperties : List<DefaultAnnotProperty>
  39. {
  40. public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType)
  41. {
  42. return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType).FirstOrDefault();
  43. }
  44. public DefaultAnnotProperty GetAnnotProperty(AnnotArgsType annotToolType,string saveKey)
  45. {
  46. return this.AsEnumerable().Where(x => x.AnnotToolType == annotToolType && x.SaveKey==saveKey).FirstOrDefault();
  47. }
  48. public void SetAnnotProperty(DefaultAnnotProperty annotProperty)
  49. {
  50. DefaultAnnotProperty[] deleteArray = new DefaultAnnotProperty[0];
  51. if (annotProperty.SaveKey != null && annotProperty.SaveKey != string.Empty)
  52. {
  53. deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType && x.SaveKey == annotProperty.SaveKey).ToArray();
  54. }
  55. else
  56. {
  57. deleteArray = this.AsEnumerable().Where(x => x.AnnotToolType == annotProperty.AnnotToolType).ToArray();
  58. }
  59. foreach (DefaultAnnotProperty deleteProperty in deleteArray)
  60. {
  61. this.Remove(deleteProperty);
  62. }
  63. this.Add(annotProperty);
  64. }
  65. }
  66. }