Articles in this section
Category / Section

CustomOverview functionality using MouseMove.

2 mins read

CustomOverview functionality using MouseMove

Syncfusion WinForms Diagram supports for the creation of own custom overview control from the predefined OverviewControl.

 

The following code snippet is used to add an overview control in diagram

[C#]

 

CustomOverView overview1 = new CustomOverView();
//Positioning the overview control using DockStyle 
overview1.Dock = DockStyle.Right;
overview1.Diagram = diagram2;
this.Controls.Add(overview1);

 

[VB]

Dim overview1 As New CustomOverView()
‘Positioning the overview control using DockStyle 
overview1.Dock = DockStyle.Right
overview1.Diagram = diagram2
Me.Controls.Add(overview1) 

 

The below code shows customizing the overview control.

[C#]

class CustomOverView : OverviewControl
    {
        bool action = false;
        public CustomOverView()
            : base()
        {
        }
    }
 

 

[VB]

Friend Class CustomOverView
 Inherits OverviewControl
  Private action As Boolean = False
  Public Sub New()
   MyBase.New()
  End Sub
End Class

 

The overview control only displays the diagram’s impact when mouse up event is fired. This can be customized by displaying the impact when the mouse is moved.

The below code snippet shows how to customize the overview control.

[C#]

protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs meargs)
        {
            base.OnMouseMove(meargs);
            if (action)
            {
                if ((this.dgmModel != null) && (this.dgmView != null))
                {
               // Creates an impact of diagram control while moving
                    if (this.ptDragStart != Point.Empty)
                    {
                        bViewportInitiated = true;
                       
                        if (this.dragMarker != RectMarkers.Viewport)
                        {
                            this.vpRenderer.SizingRect = RectangleF.Empty;
                            if ((this.rcInDragArea.Width > 5) && (this.rcInDragArea.Height > 5))
                                this.ViewportBounds = this.rcInDragArea;
                        }
                    }
                }
                if (dgmView != null)
                {
                    // Set the view origin based on the viewport's pan location.
                    PointF origin = new PointF(
                        (this.ViewportBounds.X - this.rcDisplayArea.X) / this.scaleFactor,
                        (this.ViewportBounds.Y - this.rcDisplayArea.Y) / this.scaleFactor);
 
                    this.View.Origin = new PointF(origin.X, origin.Y);
                }
                Diagram.Invalidate();
                this.dgmModel.EndUpdate();
            }
        }

 

[VB]

Protected Overrides Sub OnMouseMove(ByVal meargs As System.Windows.Forms.MouseEventArgs)
   MyBase.OnMouseMove(meargs)
If action Then
If (Me.dgmModel IsNot Nothing) AndAlso (Me.dgmView IsNot Nothing) Then
If Me.ptDragStart <> Point.Empty Then
bViewportInitiated = True
 
If Me.dragMarker <> RectMarkers.Viewport Then
Me.vpRenderer.SizingRect = RectangleF.Empty
If (Me.rcInDragArea.Width > 5) AndAlso (Me.rcInDragArea.Height > 5) Then
Me.ViewportBounds = Me.rcInDragArea
End If
End If
End If
End If
If dgmView IsNot Nothing Then
‘Set the view origin based on the viewport's pan location.
Dim origin As New PointF((Me.ViewportBounds.X - Me.rcDisplayArea.X) / Me.scaleFactor, (Me.ViewportBounds.Y - Me.rcDisplayArea.Y) / Me.scaleFactor)
 
Me.View.Origin = New PointF(origin.X, origin.Y)
End If
Diagram.Invalidate()
Me.dgmModel.EndUpdate()
End If
End Sub
 

 

Conclusion

I hope you enjoyed learning about how to customOverview functionality using MouseMove.

You can refer to our WinForms Diagram feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms Diagram documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied