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.
Unfortunately, activation email could not send to your email. Please try again.

programmatically adding ports

Thread ID:

Created:

Updated:

Platform:

Replies:

20025 Oct 7,2004 08:32 PM Aug 22,2005 01:03 PM Windows Forms 7
loading
Tags: Diagram
Aaron
Asked On October 7, 2004 08:32 PM

I have a derived symbol class, how can I add ports at specific places in this class? How can I hide these port so that they do not render even when a link tool interacts with the symbol?

James Brock
Replied On October 8, 2004 01:04 AM

Hi Aaron, I added this method to MySymbol class and called it in the constructor: private void AddThePorts() { this.Ports.Add(new AnchoredPort(this, BoxPosition.TopLeft)); this.Ports.Add(new AnchoredPort(this, BoxPosition.TopRight)); this.Ports.Add(new AnchoredPort(this, BoxPosition.TopCenter)); this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomLeft)); this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomCenter)); this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomRight)); this.Ports.Add(new AnchoredPort(this, BoxPosition.MiddleLeft)); this.Ports.Add(new AnchoredPort(this, BoxPosition.MiddleRight)); foreach (AnchoredPort port in this.Ports) { // loads the circle crosshair instead of the x port port.Load(PortVisuals.CirclePort); port.Visible = false; } } My symbol was a simple square so I added them to all corners. I believe you can use the X and Y properties to set the actual position if you do not wish to use the BoxPosition. The visible property is the important one, if this is false then it seems to ensure that they are never shown. Hope this helps. Jimski

Pranav Shah
Replied On October 8, 2004 07:27 AM

Hi, Question on the same topic. How can I make all the ports in the diagram visible as soon as the link tool is activated? Thanks in advance. Pranav... >Hi Aaron, > >I added this method to MySymbol class and called it in the constructor: > >private void AddThePorts() >{ > this.Ports.Add(new AnchoredPort(this, BoxPosition.TopLeft)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.TopRight)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.TopCenter)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomLeft)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomCenter)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.BottomRight)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.MiddleLeft)); > this.Ports.Add(new AnchoredPort(this, BoxPosition.MiddleRight)); > foreach (AnchoredPort port in this.Ports) > { > // loads the circle crosshair instead of the x port > port.Load(PortVisuals.CirclePort); > port.Visible = false; > } >} > >My symbol was a simple square so I added them to all corners. I believe you can use the X and Y properties to set the actual position if you do not wish to use the BoxPosition. > >The visible property is the important one, if this is false then it seems to ensure that they are never shown. > >Hope this helps. > >Jimski

James Brock
Replied On October 8, 2004 07:49 AM

Hi Pranav, Set the Visible property of the ports to False in the AddPorts method in my earlier example. Assuming you are using a Symbol Palette containing SymbolModels then ensure that the SymbolModel.AutoHidePorts is set to True. I believe that the Symbol itself has an AutoHidePorts property too. This should ensure that when you select a link tool etc... that the ports are displayed. Good luck. Jimski

Pranav Shah
Replied On October 8, 2004 08:34 AM

Hi Jimski, Thanks for your reply. This makes the ports visible only when I move the cursor on the port after activating link tool. I have 4 ports on my symbol. What I want is, all 4 ports to be visible as soon as I activate the link tool. Any other suggestions? Thanks, Pranav...

Administrator [Syncfusion]
Replied On October 8, 2004 01:00 PM

Hi Pranav That is how the AutoHidePorts Property is supposed to work. To do what you are seeking, you could emumerate through all instances of your custom symbol say MySymbol in the Diagram, and sets all the ports'' Visible property to true before activating the Link tool. You could then set it to false in the Model''s ConnectionsChangeComplete event which is fired after the Link is created. Note that initially the Visible property of all the ports are set to false. Here is a code snippet: IEnumerator enumnodes = this.diagram1.Model.Nodes.GetEnumerator(); //Iterate through the enumerator while (enumnodes.MoveNext()) { INode node = enumnodes.Current as INode; if (node.GetType()== typeof(MySymbol)) { MySymbol sym = (node) as MySymbol; PortCollection portenum = sym.Ports; foreach(Port port in portenum) { port.Visible = true; } } } //Activate LinkTool this.diagram1.ActivateTool("LinkTool"); Regards Arun

Andrew
Replied On August 22, 2005 11:40 AM

I have problem like this. How can I create link manualy? I have 2 Symbols, I want to connect this Symbols by simple link, how? Thanks

Administrator [Syncfusion]
Replied On August 22, 2005 01:03 PM

Hello Andrew, Please refer to the following Essential Diagram KB article for information and a code snippet on programmatically creating a link - http://www.syncfusion.com/support/kb/diagram/Default.aspx?ToDo=view&questId=24. The forthcoming 3.3.0.0 version of Essential Diagram will contain a revised version of the QuickStart\DynamicSymbol sample that shows this approach of using the LinkCmd to programmatically form a link between two symbols. Thanks, Prakash

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.

;