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

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