JB
James Brock
October 8, 2004 05:04 AM UTC
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
PS
Pranav Shah
October 8, 2004 11:27 AM UTC
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
JB
James Brock
October 8, 2004 11:49 AM UTC
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
PS
Pranav Shah
October 8, 2004 12:34 PM UTC
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...
AD
Administrator
Syncfusion Team
October 8, 2004 05:00 PM UTC
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
AN
Andrew
August 22, 2005 03:40 PM UTC
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
AD
Administrator
Syncfusion Team
August 22, 2005 05:03 PM UTC
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