Marker moved by Cursor not working

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

ELBOB
Posts: 6
Joined: Wed May 13, 2020 3:48 pm

Marker moved by Cursor not working

Post by ELBOB » Wed Aug 12, 2020 7:35 am

Hi All :
I have a piece of code that is not running properly despite it's a very simple task.

Would you please help me to force the marker to be on in the right place after I move the red crossaim marker?

After I move the marker, I call "SolveNearestSampleByCoord" to get the nearest sample : the values are correct. as you can see in the textboxes.
but the cursor stays in the mouse location instead of going to the desired place.

This is the simple code i'm using.

Code: Select all

  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(); ;
            
 }



arction MoveCursor.png
arction MoveCursor.png (274.68 KiB) Viewed 440 times

ELBOB
Posts: 6
Joined: Wed May 13, 2020 3:48 pm

Re: Marker moved by Cursor not working

Post by ELBOB » Thu Aug 13, 2020 1:02 pm

Hello Gentelmen :

Any feedback please on why the markers are not behaving as they should?
A way to force the marker to be in the right location?

Thanks in advance.

ELBOB
Posts: 6
Joined: Wed May 13, 2020 3:48 pm

Re: Marker moved by Cursor not working

Post by ELBOB » Thu Aug 13, 2020 2:58 pm

Problem Solved.
if it can help someone else, I had to add a MouseUp handler AFTER the MovedbyMouse handler in order to force the marker into position.

Code: Select all

      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();
            }            
        }