Synchronize position of cursors

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

Junseob
Posts: 2
Joined: Fri Aug 04, 2017 2:37 am

Synchronize position of cursors

Post by Junseob » Fri Aug 04, 2017 4:48 am

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.

User avatar
ArctionNikolai
Posts: 38
Joined: Fri Feb 05, 2016 11:37 am
Location: Finland

Re: Synchronize position of cursors

Post by ArctionNikolai » Fri Aug 04, 2017 3:34 pm

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
Nikolai Arsenov
Software developer
Arction Ltd
Microkatu 1, 70210 Kuopio, Finland

lokesh
Posts: 45
Joined: Tue Feb 14, 2017 8:48 am

Re: Synchronize position of cursors

Post by lokesh » Mon Aug 07, 2017 3:17 pm

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