public override void OnMouseUp(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint) { //don't set anchors until we're done drawing if (DrawingState == DrawingState.Building) { return; } //set the drawing state back to normal when mouse is relased if (DrawingState == DrawingState.Editing || DrawingState == DrawingState.Moving) { DrawingState = DrawingState.Normal; } if (editingAnchor != null) { if (editingAnchor == EntryAnchor) { SetReward(); if (Ratio.ApproxCompare(0) != 0) { SetRisk(); } } editingAnchor.IsEditing = false; } editingAnchor = null; }
public override void OnMouseMove(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint) { if (IsLocked && DrawingState != DrawingState.Building || !IsVisible) { return; } if (DrawingState == DrawingState.Building) { if (EntryAnchor.IsEditing) { dataPoint.CopyDataValues(EntryAnchor); } else if (RiskAnchor.IsEditing) { dataPoint.CopyDataValues(RiskAnchor); } else if (RewardAnchor.IsEditing) { dataPoint.CopyDataValues(RewardAnchor); } } else if (DrawingState == DrawingState.Editing && editingAnchor != null) { dataPoint.CopyDataValues(editingAnchor); if (editingAnchor != EntryAnchor) { if (editingAnchor != RewardAnchor && Ratio.ApproxCompare(0) != 0) { SetReward(); } else if (Ratio.ApproxCompare(0) != 0) { SetRisk(); } } } else if (DrawingState == DrawingState.Moving) { foreach (ChartAnchor anchor in Anchors) { anchor.MoveAnchor(InitialMouseDownAnchor, dataPoint, chartControl, chartPanel, chartScale, this); } } entryPrice = AttachedTo.Instrument.MasterInstrument.RoundToTickSize(EntryAnchor.Price); stopPrice = AttachedTo.Instrument.MasterInstrument.RoundToTickSize(RiskAnchor.Price); targetPrice = AttachedTo.Instrument.MasterInstrument.RoundToTickSize(RewardAnchor.Price); }