Category / Section
Multiple Diagrams Scrolling together
1 min read
Mirroring of scrolling operation in Multiple Diagrams
The mirroring of scrolling operation can be achieved by using Diagram’s event sink’s OriginChanged event. Need to create separate OriginChanged event for both the diagrams/views and assign the new origin by means of vice versa (i.e.) Need to assign the 2nd diagram’s new origin in the 1st diagram’s OriginChanged event and assign the 1st diagram’s new origin in the 2nd diagram’s OriginChanged event.
The below attached code snippet for scrolling the multiple diagrams together:
[C#]
//initializing the Origin changed event for both diagrams diagram1.EventSink.OriginChanged +=new ViewOriginEventHandler(Diagram1EventSink_OriginChanged); diagram2.EventSink.OriginChanged += new ViewOriginEventHandler(Diagram2EventSink_OriginChanged); private void Diagram1EventSink_OriginChanged(ViewOriginEventArgs evtArgs) { //Assiging the new origin value of Diagram1 to the Diagram2 while scrolling the Diagram1 diagram2.View.Origin = evtArgs.NewOrigin; diagram2.Refresh(); } private void Diagram2EventSink_OriginChanged(ViewOriginEventArgs evtArgs) { //Assiging the new origin value of Diagram2 to the Diagram1 while scrolling the Diagram2 diagram1.View.Origin = evtArgs.NewOrigin; diagram1.Refresh(); }
[VB]
'initializing the Origin changed event for both diagrams Private diagram1.EventSink.OriginChanged += New ViewOriginEventHandler(AddressOf Diagram1EventSink_OriginChanged) Private diagram2.EventSink.OriginChanged += New ViewOriginEventHandler(AddressOf Diagram2EventSink_OriginChanged) Private Sub Diagram1EventSink_OriginChanged(ByVal evtArgs As ViewOriginEventArgs) 'Assiging the new origin value of Diagram1 to the Diagram2 while scrolling the Diagram1 diagram2.View.Origin = evtArgs.NewOrigin diagram2.Refresh() End Sub Private Sub Diagram2EventSink_OriginChanged(ByVal evtArgs As ViewOriginEventArgs) 'Assiging the new origin value of Diagram2 to the Diagram1 while scrolling the Diagram2 diagram1.View.Origin = evtArgs.NewOrigin diagram1.Refresh() End Sub
Sample Link: