Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

the cursor snaping to plot moves left automatically,in the C# program using measurement studio.

Solved!
Go to solution

        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.

0 Kudos
Message 1 of 4
(2,403 Views)

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.

0 Kudos
Message 2 of 4
(2,399 Views)
Solution
Accepted by topic author marmot1969

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.

~ Paul H
0 Kudos
Message 3 of 4
(2,357 Views)

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.

0 Kudos
Message 4 of 4
(2,318 Views)