Group: Forum Members
Last Active: 5 Years Ago
Posts: 49,
Visits: 179
|
Hi Team , I am adding shapes from one DrawingDocument to another after cloning . public static NDrawingDocument CopyDigram(NDrawingDocument nProjectDiagram, NDrawingDocument nSystemTemplateDiagram, Dictionary<string, string> oldNewComponentIds) { for (int i = 0; i < nSystemTemplateDiagram.ActiveLayer.ChildrenCount(null); i++) { Hashtable mapUids = new Hashtable(); INNode node = nSystemTemplateDiagram.ActiveLayer.GetChildAt(i); if (node is NCompositeShape) { NShape soruceDiagramShape = (NShape)node; NShape shape = soruceDiagramShape.CloneWithNewUniqueId(mapUids) as NShape; shape.UniqueId = Guid.Parse(oldNewComponentIds[soruceDiagramShape.UniqueId.ToString()]); //Replace guid from nProjectDiagram.ActiveLayer.AddChild(shape);
} else if (node is NRoutableConnector) { NRoutableConnector sourceDiagramConnector = (NRoutableConnector)node; NRoutableConnector connector = templateDiagramConnector.CloneWithNewUniqueId(mapUids) as NRoutableConnector; connector.UniqueId = Guid.Parse(oldNewComponentIds[templateDiagramConnector.UniqueId.ToString()]); //connector.RerouteAutomatically = RerouteAutomatically.Always; //connector.Location = templateDiagramConnector.Location; nProjectDiagram.ActiveLayer.AddChild(connector); }
//Iterate all connectors from source diagram and find corroessponding shape and port to connect in new diagram connector.StartPlug.Connect(sourceShapePort); connector.EndPlug.Connect(targetShapePart); connector.Reroute();// Not working } }
public static NDrawingDocument CopyDigram(NDrawingDocument nProjectDiagram, NDrawingDocument nSystemTemplateDiagram, Dictionary<string, string> oldNewComponentIds)
{
for (int i = 0; i < nSystemTemplateDiagram.ActiveLayer.ChildrenCount(null); i++)
{
Hashtable mapUids = new Hashtable();
INNode node = nSystemTemplateDiagram.ActiveLayer.GetChildAt(i);
if (node is NCompositeShape)
{
NShape soruceDiagramShape = (NShape)node;
NShape shape = soruceDiagramShape.CloneWithNewUniqueId(mapUids) as NShape;
shape.UniqueId = Guid.Parse(oldNewComponentIds[soruceDiagramShape.UniqueId.ToString()]); //Replace guid from
nProjectDiagram.ActiveLayer.AddChild(shape);
}
else if (node is NRoutableConnector)
{
NRoutableConnector sourceDiagramConnector = (NRoutableConnector)node;
NRoutableConnector connector = templateDiagramConnector.CloneWithNewUniqueId(mapUids) as NRoutableConnector;
connector.UniqueId = Guid.Parse(oldNewComponentIds[templateDiagramConnector.UniqueId.ToString()]);
//connector.RerouteAutomatically = RerouteAutomatically.Always;
//connector.Location = templateDiagramConnector.Location;
nProjectDiagram.ActiveLayer.AddChild(connector);
}
//Iterate all connectors from source diagram and find corroessponding shape and port to connect in new diagram
connector.StartPlug.Connect(sourceShapePort);
connector.EndPlug.Connect(targetShapePart);
connector.Reroute();// Not working
}
}
Source Diagram : 73% of original size (was 689x19) - Click to enlarge  Routing is not correct in copying diagram 73% of original size (was 689x19) - Click to enlarge  Please suggest that how can we correct routing of these dynamically added shapes in the drawing &# 100 ; ocument . Note: All events are detached from these diagrams .
|