LightningChart cursor movement marker does not work properly

Problem: The marker for cursor movement does not work

Although this is a very simple task, I have a piece of code that does not work properly.

After moving the red crossaim marker, can you please help me to force the marker to the correct position?

After moving the marker, I call "SolveNearestSampleByCoord" to get the most recent sample: the value is correct. As you can see in the text box.
But the cursor stays at the mouse location instead of moving to the desired location.

This is the simple code I am using.
private void Cl1_MovedByMouse(object sender, MouseEventArgs e)
{
SeriesEventMarker marker = (SeriesEventMarker)sender;
selectedCursor = marker.Tag.ToString();
cursorSelected = true;

        double dXValue, dYValue;
        int iNearestIndex;
        int a = 0;
        m_chart.BeginUpdate();
        if (m_chart.ViewXY.SampleDataSeries[0].SolveNearestSampleByCoord(e.X, e.Y, out dXValue, out dYValue, out iNearestIndex)) ;
        {
            marker.VerticalPosition = SeriesEventMarkerVerticalPosition.AtYValue;
            marker.HorizontalPosition = SeriesEventMarkerHorizontalPosition.AtXValue;               
            marker.Symbol.Shape = Shape.CrossAim;
            marker.XValue = dXValue;
            marker.YValue = dYValue;
            XXX = dXValue;
            YYY = dYValue;

            txtX.Text = XXX.ToString(); // Just to make sure it is the right values
            txtY.Text = YYY.ToString();
        }
        m_chart.EndUpdate(); ;

}

LightningChart cursor movement marker does not work properly
Reply: If the marker for cursor movement is invalid
, a MouseUp handler must be added after the MovedbyMouse handler to force the marker to be placed in place.
private void Cl1_MouseUp(object sender, MouseEventArgs e)
{
SeriesEventMarker marker = (SeriesEventMarker)sender;
selectedCursor = marker.Tag.ToString();
cursorSelected = true;
{
m_chart.BeginUpdate();
marker.VerticalPosition = SeriesEventMarkerVerticalPosition.AtYValue;
marker. HorizontalPosition = SeriesEventMarkerHorizontalPosition.AtXValue;
marker.XValue = XXX;
marker.YValue = YYY;
m_chart.EndUpdate();;
m_chart.Refresh();
}
}
If you have any questions about this, please contact customer service for more information.

If you want to buy a genuine license for LightningChart, or for more product information, please click [Consult Online Customer Service]

Guess you like

Origin blog.51cto.com/15078157/2621471