Search
DiagramBase.DrawAdjustmentHandles Event
See Also
 





Raised when item's adjustment handles must be custom drawn.

Namespace: MindFusion.Diagramming.Wpf
Assembly: MindFusion.Diagramming.Wpf

 Syntax

C#  Copy Code

public event EventHandler<DrawItemEventArgs> DrawAdjustmentHandles

Visual Basic  Copy Code

Public Event DrawAdjustmentHandles As EventHandler(Of DrawItemEventArgs)

 Event Data

DrawAdjustmentHandles event handlers receive an argument of type DrawItemEventArgs.

 Remarks

DrawAdjustmentHandles is raised for selected items whose HandlesStyle is set to Custom.

 Example

The following example illustrates how to draw a red frame around a node as a visualization of its adjustment handles.

C#  Copy Code

private void diagram_DrawAdjustmentHandles(object sender, DrawItemEventArgs e)
{
    Pen pen = new Pen(Brushes.Red, 0.3);

    if (e.Item is ShapeNode)
    {
        ShapeNode shapeNode = e.Item as ShapeNode;
        Rect r = shapeNode.Bounds;
        r.X = 0;
        r.Y = 0;
        e.Graphics.DrawRectangle(null, pen, new Rect(r.X, r.Y, r.Width, r.Height));
    }

    if (e.Item is DiagramLink)
    {
        DiagramLink link = e.Item as DiagramLink;
        PathGeometry pg = new PathGeometry();
        PathFigure pf = new PathFigure();
        pf.StartPoint = link.ControlPoints[0];

        for (int i = 1; i < link.ControlPoints.Count; i++)
            pf.Segments.Add(new LineSegment(link.ControlPoints[i], true));

        pg.Figures.Add(pf);

        e.Graphics.DrawGeometry(null, pen, pg);
    }
}

Visual Basic  Copy Code

Sub diagram_DrawAdjustmentHandles(ByVal sender As Object, ByVal e As MindFusion.Diagramming.Wpf.DrawItemEventArgs) Handles diagram.DrawAdjustmentHandles

    Dim pen As Pen = New Pen(Brushes.Red, 0.3)

    If TypeOf e.Item Is ShapeNode Then

        Dim shapeNode As ShapeNode = CType(e.Item, ShapeNode)
        Dim r As Rect = shapeNode.Bounds
        e.Graphics.DrawRectangle(Nothing, pen, New Rect(0, 0, r.Width, r.Height))

    End If

    If TypeOf e.Item Is DiagramLink Then

        Dim link As DiagramLink = CType(e.Item, DiagramLink)
        Dim pg As PathGeometry = New PathGeometry()
        Dim pf As PathFigure = New PathFigure()
        pf.StartPoint = link.ControlPoints(0)

        For i As Integer = 1 To link.ControlPoints.Count - 1 Step 1
            pf.Segments.Add(New LineSegment(link.ControlPoints(i), True))
        Next

        pg.Figures.Add(pf)

        e.Graphics.DrawGeometry(Nothing, pen, pg)

    End If

End Sub

 See Also