/// <summary> /// Handles the MouseDown event when the plot point tool is selected /// </summary> /// <param name="position">Mouse position.</param> /// <param name="e">The mouse event args</param> public override void OnMouseDown(PointD2D position, MouseButtonEventArgs e) { base.OnMouseDown(position, e); var graphXY = _grac.ConvertMouseToRootLayerCoordinates(position); _grac.FindGraphObjectAtPixelPosition(position, true, out var clickedObject, out var clickedLayerNumber); if (null != clickedObject && clickedObject.HittedObject is XYColumnPlotItem) { _PlotItem = (XYColumnPlotItem)clickedObject.HittedObject; var transXY = clickedObject.Transformation.InverseTransformPoint(graphXY); _layer = (XYPlotLayer)(clickedObject.ParentLayer); XYScatterPointInformation scatterPoint = _PlotItem.GetNearestPlotPoint(_layer, transXY); _PlotItemNumber = GetPlotItemNumber(_layer, _PlotItem); if (null != scatterPoint) { _PlotIndex = scatterPoint.PlotIndex; _RowIndex = scatterPoint.RowIndex; // convert this layer coordinates first to PrintableAreaCoordinates var rootLayerCoord = clickedObject.ParentLayer.TransformCoordinatesFromHereToRoot(scatterPoint.LayerCoordinates); _positionOfCrossInRootLayerCoordinates = rootLayerCoord; // m_Cross.X -= _grac.GraphViewOffset.X; // m_Cross.Y -= _grac.GraphViewOffset.Y; var newPixelCoord = _grac.ConvertGraphToMouseCoordinates(rootLayerCoord); // TODO (Wpf) //var newCursorPosition = new Point((int)(Cursor.Position.X + newPixelCoord.X - mouseXY.X),(int)(Cursor.Position.Y + newPixelCoord.Y - mouseXY.Y)); //SetCursorPos(newCursorPosition.X, newCursorPosition.Y); DisplayData(_PlotItem, scatterPoint.RowIndex, _PlotItem.XYColumnPlotData.XColumn[scatterPoint.RowIndex], _PlotItem.XYColumnPlotData.YColumn[scatterPoint.RowIndex]); // here we shoud switch the bitmap cache mode on and link us with the AfterPaint event // of the grac _grac.RenderOverlay(); // no refresh necessary, only invalidate to show the cross } } } // end of function