public override bool IsVisibleOnChart(ChartControl chartControl, ChartScale chartScale, DateTime firstTimeOnChart, DateTime lastTimeOnChart) { if (DrawingState == DrawingState.Building) { return(true); } if (Mode == RegionHighlightMode.Time) { if (Anchors.Any(a => a.Time >= firstTimeOnChart && a.Time <= lastTimeOnChart)) { return(true); } // check crossovers if (StartAnchor.Time <= firstTimeOnChart && EndAnchor.Time >= lastTimeOnChart) { return(true); } if (EndAnchor.Time <= firstTimeOnChart && StartAnchor.Time >= lastTimeOnChart) { return(true); } return(false); } else { // check if active y range highlight is on scale or cross through if (Anchors.Any(a => a.Price <= chartScale.MaxValue && a.Price >= chartScale.MinValue)) { return(true); } return((StartAnchor.Price <= chartScale.MinValue && EndAnchor.Price >= chartScale.MaxValue) || (EndAnchor.Price <= chartScale.MinValue && StartAnchor.Price >= chartScale.MaxValue)); } }
public override void OnCalculateMinMax() { // It is important to set MinValue and MaxValue to the min/max Y values your drawing tool uses if you want it to support auto scale MinValue = double.MaxValue; MaxValue = double.MinValue; if (!IsVisible) { return; } // return min/max values only if something has been actually drawn if (Anchors.Any(a => !a.IsEditing)) { foreach (ChartAnchor anchor in Anchors) { if (anchor.DisplayName == RewardAnchor.DisplayName && !DrawTarget) { continue; } MinValue = Math.Min(anchor.Price, MinValue); MaxValue = Math.Max(anchor.Price, MaxValue); } } }
public override void OnCalculateMinMax() { MinValue = double.MaxValue; MaxValue = double.MinValue; if (!IsVisible) { return; } // return min/max values only if something has been actually drawn if (Anchors.Any(a => !a.IsEditing)) { foreach (ChartAnchor anchor in Anchors) { MinValue = Math.Min(anchor.Price, MinValue); MaxValue = Math.Max(anchor.Price, MaxValue); } } }
public override bool IsVisibleOnChart(ChartControl chartControl, ChartScale chartScale, DateTime firstTimeOnChart, DateTime lastTimeOnChart) { return(DrawingState == DrawingState.Building || Anchors.Any(a => a.Time >= firstTimeOnChart && a.Time <= lastTimeOnChart)); }