GetClosestAnchor()

View as Markdown

Definition

Returns the closest chart anchor within a specified maximum distance from the mouse cursor.

Method Return Value

This method returns an existing ChartAnchor.

Syntax

GetClosestAnchor(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, double maxDist, Point point)

Method Parameters

ParameterDescription
chartControlA ChartControl representing the x-axis
chartPanelA ChartPanel representing the panel for the chart
chartScaleA ChartScale representing the y-axis
maxDistA double value representing the cursor’s sensitivity used to detect the nearest anchor
pointA Point in device pixels representing the current mouse cursor position

Examples

1public override Cursor GetCursor(ChartControl chartControl, ChartPanel chartPanel, ChartScale chartScale, Point point)
2{
3 // get the closest anchor to where the user has clicked
4 ChartAnchor closest = GetClosestAnchor(chartControl, chartPanel, chartScale, 10, point);
5
6 if (closest != null)
7 {
8 // set cursor to indicate that it can be moved
9 return Cursors.SizeNWSE;
10 }
11 // otherwise set cursor back to arrow
12 else return Cursors.Arrow;