| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using MuchInfo.Chart.Data;
- using MuchInfo.Chart.WPF.Helpers;
- using MuchInfo.Chart.WPF.Primitives.Interfaces;
- using System;
- using System.Collections.Generic;
- namespace MuchInfo.Chart.WPF.Primitives.Drawing
- {
- public class SharedDrawingToolContainer
- {
- public delegate void ReloadDrawingsEventHandler();
- private ScaleLayer _scaleLayer;
- public event SharedDrawingToolContainer.ReloadDrawingsEventHandler ReloadDrawings;
- protected virtual void OnReloadDrawings()
- {
- ReloadDrawingsEventHandler handler = ReloadDrawings;
- if (handler != null) handler();
- }
- public SharedDrawingToolContainer(ScaleLayer owner)
- {
- this._scaleLayer = owner;
- }
- public SharedDrawingToolSpec AddNewDrawing(string symbol, IDrawingTool aDrawing, TimeSpan timeFrame, Guid scaleGUID, bool IsPriceScale)
- {
- return new SharedDrawingToolSpec(this, symbol, aDrawing, timeFrame, scaleGUID, IsPriceScale);
- }
- internal void SharedDrawingToolContainer_3819(SharedDrawingToolSpec aSpec)
- {
- bool flag = this._scaleLayer != null;
- if (flag)
- {
- this._scaleLayer.RefreshChart(true);
- }
- }
- private IDrawingTool GetDrawingTool(DrawingToolInfo info, Guid scaleGuid, bool isPriceScale)
- {
- if (info == null) return null;
- if (isPriceScale)
- {
- if (info.ScaleGUID.HasValue && info.ScaleGUID.Value != scaleGuid) return null;
- var toolSpec = new SharedDrawingToolSpec(this, info);
- return toolSpec.GetTool();
- }
- else
- {
- var currentGuid = info.OriginalScaleGUID();
- if (currentGuid != scaleGuid) return null;
- var toolSpec = new SharedDrawingToolSpec(this, info);
- return toolSpec.GetTool();
- }
- }
- public List<IDrawingTool> DrawingForSymbol(string symbol, Guid scaleGuid, bool isPriceScale, Chart chart)
- {
- var list = new List<IDrawingTool>();
- if (string.IsNullOrWhiteSpace(symbol)) return list;
- var drawingTools = SharedDrawingManager.GetDrawingsForSymbol(symbol);
- if (drawingTools != null)
- {
- foreach (var current in drawingTools)
- {
- var tool = GetDrawingTool(current, scaleGuid, isPriceScale);
- if (tool == null) continue;
- list.Add(tool);
- }
- }
- var drawingInfos = SharedDrawingManager.GetDrawingsOnAllSymbols();
- if (drawingInfos != null)
- {
- foreach (var current in drawingInfos)
- {
- var tool = GetDrawingTool(current, scaleGuid, isPriceScale);
- if (tool == null) continue;
- list.Add(tool);
- }
- }
- return list;
- }
- public ScaleLayer ScaleLayer()
- {
- return this._scaleLayer;
- }
- }
- }
|