Page 1 of 1

Synchronize position of cursors

Posted: Fri Aug 04, 2017 4:48 am
by Junseob
Hi,

I have made two chars on different forms.
Each char has two line series cursors (X1, X2 vertical line) for caculating average, min, max values.

My question is :
- How can I synchronize position of cursors while moving the other cursor ?
- The cursor need to be move by the other cursor.
- For example,
=> Chart1's X1 cursor move 10 to 20, Chart2's X1 cursor will following Chart1's cursor.

Re: Synchronize position of cursors

Posted: Fri Aug 04, 2017 3:34 pm
by ArctionNikolai
Junseob wrote:Hi,

I have made two chars on different forms.
Each char has two line series cursors (X1, X2 vertical line) for caculating average, min, max values.

My question is :
- How can I synchronize position of cursors while moving the other cursor ?
- The cursor need to be move by the other cursor.
- For example,
=> Chart1's X1 cursor move 10 to 20, Chart2's X1 cursor will following Chart1's cursor.
Hello,

You can subscribe to the cursor.PoisitionChanged event. In the following method, you will be able to access to PositionChagedEventArgs e, which contains e.NewValue property with a new position of a touched cursor. Then, you just need to assign a gathered value to another cursorX2.ValueAtXAxis = e.NewValue.

Best regards, Nikolai

Re: Synchronize position of cursors

Posted: Mon Aug 07, 2017 3:17 pm
by lokesh
Hi,
I actually had to do this and what I did is as follows:

1. Created an event in the 2 forms. (I actually had a base class for both; so created a virtual event in the base class and override it in the 2 child classes) My arguments were a sender object to identify the form invoking this event along with the updated position.
2. In the parent form, subscribe to the events.
3. In the event handler, I identify the sender and call the other form's position update method.

The event is invoked in the cursor.PoisitionChanged event as mentioned by Nikolai. And the position is updated as (also) mentioned by Nikolai.

Just in case you were wondering why I override the event is actually because of my design pattern and also so I could use event?.Invoke().

Hope that helps.

Regards,
Lokesh