public override void OnMouseDown(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, ChartAnchor dataPoint) { switch (DrawingState) { case DrawingState.Building: if (StartAnchor.IsEditing) { dataPoint.CopyDataValues(StartAnchor); dataPoint.CopyDataValues(EndAnchor); StartAnchor.IsEditing = false; } else if (EndAnchor.IsEditing) { dataPoint.CopyDataValues(EndAnchor); EndAnchor.IsEditing = false; DrawingState = DrawingState.Normal; IsSelected = false; } break; case DrawingState.Normal: Point p = dataPoint.GetPoint(chartControl, chartPanel, chartScale); Cursor c = GetCursor(chartControl, chartPanel, chartScale, p); if (c == Cursors.SizeWE) { int editingAnchor = GetClosestBarAnchor(chartControl, p, false); int i = anchorBars.IndexOf(editingAnchor); if (editingAnchor != int.MinValue && i > -1) { StartAnchor.UpdateXFromPoint(new Point(anchorBars[i == 0 ? i : i - 1], chartPanel.Y + chartPanel.H), chartControl, chartScale); EndAnchor.UpdateXFromPoint(new Point(anchorBars[i == 0 ? i + 1 : i], chartPanel.Y + chartPanel.H), chartControl, chartScale); EndAnchor.IsEditing = true; DrawingState = DrawingState.Editing; } } else if (c == Cursors.SizeAll) { int editingAnchor = GetClosestBarAnchor(chartControl, p, true); int i = anchorBars.IndexOf(editingAnchor); if (editingAnchor != int.MinValue && i > -1) { StartAnchor.UpdateXFromPoint(new Point(anchorBars[i - 1], chartPanel.Y + chartPanel.H), chartControl, chartScale); EndAnchor.UpdateXFromPoint(new Point(anchorBars[i], chartPanel.Y + chartPanel.H), chartControl, chartScale); // We have to update the InitialMouseDownAnchor here because we moved our Start/End anchors InitialMouseDownAnchor = dataPoint.Clone() as ChartAnchor; DrawingState = DrawingState.Moving; } } else { IsSelected = false; } break; } }