private static void ProcessNodeShape(NodeShape shapeElement, LinkedElementCollection <NodeShapeInfo> infos) { // try to find NodeShapeInfo for shape element NodeShapeInfo info = null; foreach (NodeShapeInfo i in infos) { if (i.ElementId == shapeElement.Element.Id) { info = i; break; } } if (info == null) { shapeElement.UpdateAbsoluteLocation(); return; } shapeElement.Size = info.Size; shapeElement.SetLocation(info.RelativeLocation); // children foreach (NodeShape shape in shapeElement.Children) { ProcessNodeShape(shape, info.ChildrenInfos); } }
/// <summary> /// Finalize. This method is called on each copied element once all the elements and links are processed. /// </summary> /// <param name="protoElement">Proto element representation of the element that is to be added.</param> /// <param name="groupMerger"> /// Group merger class used to track id mapping, merge errors/warnings and /// postprocess merging by rebuilding reference relationships. /// </param> public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger) { if (protoElement.CustomArguments is DiagramModelMergeOptions) { DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions; Guid elementID = options.ElementId; ModelProtoElement elementP = groupMerger.GetElementById(elementID); if (elementP != null) { (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger); } NodeShape shape = this.Store.ElementDirectory.FindElement( groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape; // restore layout Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel)); LayoutInfo info; using (Transaction t = store.TransactionManager.BeginTransaction()) { info = options.GetLayoutInfo(store); t.Commit(); } LayoutHelper.ApplyLayout(this, this.Diagram, info); store.Dispose(); if (!shape.IsRelativeChildShape) { shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X, RelativePastePoint.Y + options.RelativeLocation.Y)); } } }
private static void ProcessNodeShape(NodeShape shapeElement, LinkedElementCollection<NodeShapeInfo> infos) { // try to find NodeShapeInfo for shape element NodeShapeInfo info = null; foreach (NodeShapeInfo i in infos) { if (i.ElementId == shapeElement.Element.Id) { info = i; break; } } if (info == null) { shapeElement.UpdateAbsoluteLocation(); return; } shapeElement.Size = info.Size; shapeElement.SetLocation(info.RelativeLocation); // children foreach (NodeShape shape in shapeElement.Children) { ProcessNodeShape(shape, info.ChildrenInfos); } }