Thanks. The events now fire after I upgraded. I am however not getting an accurate hit result. Is the code below an accurate way to get the mouse position and resolve it to the chart element? Thx, Gil.
private void OnMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
StringBuilder strBuild = new StringBuilder();
System.Windows.Point pos = new System.Windows.Point();
pos = e.GetPosition(this);
Debug.WriteLine(String.Format("X: {0}, Y: {1}", pos.X, pos.Y));
//MouseEventTextBox.Text = mouseEvent;
//ButtonTextBox.Text = e.Button.ToString();
//ChartObjectTextBox.Text = sender.GetType().ToString();
string sInfo = GetResultDescription(this.HitTest((int)pos.X, (int)pos.Y));
Debug.WriteLine(sInfo);
//DescriptionTextBox.Text = sInfo;
}
private string GetResultDescription(NHitTestResult hitTestResult)
{
int nChartElement = (int)hitTestResult.ChartElement;
string sInfo = "";
Debug.WriteLine(hitTestResult.ChartElement.ToString());
switch (hitTestResult.ChartElement)
{
case ChartElement.Nothing:
sInfo = "Nothing";
break;
case ChartElement.ControlBackground:
sInfo = "Control background";
break;
case ChartElement.DataPoint:
sInfo = "Data point [" + hitTestResult.DataPointIndex.ToString() + "] from series [" + ((NSeriesBase)hitTestResult.Object.ParentNode).Name + "]";
break;
case ChartElement.SurfaceDataPoint:
sInfo = "Surface data point [" + hitTestResult.SurfaceDataPointX.ToString() + ", " + hitTestResult.SurfaceDataPointZ.ToString();
break;
case ChartElement.Axis:
sInfo = "Axis [" + hitTestResult.ObjectIndex + "]";
break;
case ChartElement.ChartWall:
sInfo = "Wall [" + hitTestResult.ObjectIndex + "]";
break;
case ChartElement.Legend:
sInfo = "Legend";
break;
case ChartElement.LegendDataItem:
sInfo = "Legend data item [" + hitTestResult.ObjectIndex.ToString() + "]";
break;
case ChartElement.LegendHeader:
sInfo = "Legend header";
break;
case ChartElement.LegendFooter:
sInfo = "Legend footer";
break;
case ChartElement.AxisStripe:
sInfo = "Axis stripe";
break;
case ChartElement.Label:
sInfo = "Label";
break;
case ChartElement.Watermark:
sInfo = "Watermark";
break;
case ChartElement.Annotation:
sInfo = "Annotation";
break;
case ChartElement.Chart:
sInfo = "Chart";
break;
default:
Debug.Assert(false); // new chart element?
break;
}
return sInfo;
}