11-18-2017 03:13 AM
when running the C# spectrum program,on the plot ,the CURSOR is moved automatically left when the spectrum-graph waves.When the spectrum-graph doesn't wave,the cursor stop at the right fixed position .this is the question:how can I fix the cursor at the position when the spectrum-graph waves.
In the old version measurement studio,the CWgraph has a option:snap to plot with fixed x,but at the current measurement studio,only the item:snap to plot,how can i fix the cursor at a position on the plot.
Solved! Go to Solution.
11-18-2017 03:28 AM
I have done something in the aftermove events,for example set position or set the index,but these measures have no effects.the spectrum-graph waves,the cursor move left slowly,then,stop at the most left position.
what is the problem?I look for it for several days,but the behave is still exist.thanks best regards.
11-21-2017 04:27 PM
Based on your description of move events, it sounds like you are using the Windows Forms controls?
Assuming you are using the XYCursor
, you can subscribe to the BeforeMove
event to prevent the cursor from changing position. For example, this handler saves the initial position of the cursor and ensure it is always maintained:
double targetPosition = double.NaN; private void BeforeCursorMove( object sender, BeforeMoveXYCursorEventArgs e ) { if( double.IsNaN( targetPosition ) ) targetPosition = e.XPosition; if( e.XPosition != targetPosition ) e.Cancel = true; }
I was also able to use the MoveCursor
method to restore a saved index value in the AfterMove
event:
int targetIndex = -1; private void AfterCursorMove( object sender, AfterMoveXYCursorEventArgs e ) { int currentIndex = e.Cursor.GetCurrentIndex( ); if( targetIndex < 0 ) targetIndex = currentIndex; if( currentIndex != targetIndex ) e.Cursor.MoveCursor( targetIndex ); }
If this does not match your scenario, it would be helpful to include a small code example demonstrating the issue.
11-24-2017 10:57 AM
thanks for your kind response.I choose the CWGraph activex control to implement the function,because the control have more options.I have done these completely ,It works well now.