We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to programmatically change the geometry of the node(s) within a Symbol?

 

The Syncfusion.Windows.Forms.Diagram.ILocalPoints interface that all Essential Diagram Shape objects implement can be used to dynamically access and change the geometry of the nodes that make up a symbol. The following code shows how to programmatically change the length of a Line node contained within a custom defined symbol.

C#

public class MySymbol : Symbol

{

public MySymbol()

{

// Custom symbol initialization

// Original line segment in the symbol spanning points (20,30) to (40,30)

this.innerLine = new Line(new PointF(20,30), new PointF(40,30));

this.AppendChild(this.innerLine);

}

// Changing the geometry of a node in the symbol

public void IncreaseLineLength()

{

// Use the ILocalPoints interface to dynamically access and change the line geometry

// The following code changes the line's end point from (40,30) to (60,30)

IServiceProvider svcprovider = this.innerLine as IServiceProvider;

ILocalPoints localpoints = (ILocalPoints)svcprovider.GetService(typeof(ILocalPoints));

Debug.Assert(svcprovider != null);

PointF[] pts = localpoints.GetPoints();

Trace.WriteLine(pts[0].ToString(), pts[1].ToString());

// Set the new end point of the line to be PointF(60,30);

localpoints.SetPoint(1, new PointF(60,30));

}

}

VB

Public Class MySymbol Inherits Symbol

Public Sub New()

' Custom Symbol initialization

' Original line segment in the custom symbol spanning points (20,30) to (40,30)

Me.innerLine = New Line(New PointF(20, 30), New PointF(40, 30))

Me.AppendChild(Me.innerLine)

End Sub

Public Sub IncreaseLineLength()

' Use the ILocalPoints interface to dynamically access and change the line geometry

' The following code changes the line's end point from (40,30) to (60,30)

Dim svcprovider As IServiceProvider = Me.innerLine

Dim localpoints As ILocalPoints = CType(svcprovider.GetService(GetType(ILocalPoints)), ILocalPoints)

Debug.Assert( Not (svcprovider Is Nothing))

Dim pts As PointF() = localpoints.GetPoints()

Trace.WriteLine(pts(0).ToString(), pts(1).ToString())

' Set the new end point of the line to be PointF(60,30)

localpoints.SetPoint(1, New PointF(60, 30))

End Sub

End Class 'MySymbol

Referring to the class reference documentation on the Syncfusion.Windows.Forms.Diagram.ILocalPoints interface will give a better idea on how to go about using it.

Article ID: Published Date: Last Revised Date: Platform: Control:
191 04/30/2011 07/10/2014 WinForms Diagram
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon