DrawingToolContainer.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using MuchInfo.Chart.WPF.Primitives.Interfaces;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace MuchInfo.Chart.WPF.Primitives.Drawing
  5. {
  6. public class DrawingToolContainer
  7. {
  8. #region Fields
  9. private List<DrawingToolSpec> _list;
  10. private ScaleLayer _scaleLayer;
  11. #endregion Fields
  12. #region Constructors
  13. public DrawingToolContainer(ScaleLayer owner)
  14. {
  15. this._list = new List<DrawingToolSpec>();
  16. this._scaleLayer = owner;
  17. }
  18. #endregion Constructors
  19. #region Delegates
  20. public delegate void ReloadDrawingsEventHandler();
  21. #endregion Delegates
  22. #region Methods
  23. #region Public Methods
  24. public DrawingToolSpec AddDrawing(string symbol, IDrawingTool aDrawing)
  25. {
  26. var drawingToolSpec = new DrawingToolSpec(symbol, aDrawing) { DrawingToolContainer = this };
  27. this._list.Add(drawingToolSpec);
  28. return drawingToolSpec;
  29. }
  30. public void AddDrawing(DrawingToolSpec aSpec)
  31. {
  32. aSpec.DrawingToolContainer = this;
  33. this._list.Add(aSpec);
  34. }
  35. public List<DrawingToolSpec> AllDrawings()
  36. {
  37. return this._list;
  38. }
  39. public void Clear()
  40. {
  41. this._list.Clear();
  42. }
  43. public List<IDrawingTool> DrawingForSymbol(string symbol)
  44. {
  45. var list = new List<IDrawingTool>();
  46. if (string.IsNullOrWhiteSpace(symbol) || this._list == null) return list;
  47. list.AddRange(from current in _list
  48. let flag = current.AppliesToSymbol(symbol)
  49. where flag
  50. select current.GetTool());
  51. return list;
  52. }
  53. public ScaleLayer ScaleLayer()
  54. {
  55. return this._scaleLayer;
  56. }
  57. #endregion Public Methods
  58. #region Internal Methods
  59. internal void DrawingToolContainer_3724(DrawingToolSpec aSpec)
  60. {
  61. this._list.Remove(aSpec);
  62. bool flag = this._scaleLayer != null;
  63. if (flag)
  64. {
  65. this._scaleLayer.RefreshChart(true);
  66. }
  67. }
  68. #endregion Internal Methods
  69. #endregion Methods
  70. }
  71. }