/// <summary> /// Correct children. /// </summary> public virtual bool CorrectChildren() { bool bRet = false; for (int i = this.Children.Count - 1; i >= 0; i--) { NodeShape shape = this.Children[i]; if (!this.CanHostShape(shape.GetDomainClassId())) { shape.Delete(); bRet = true; } else if (shape.CorrectChildren()) { bRet = true; } } foreach (Diagram d in this.IncludedDiagrams) { if (d.CorrectChildren()) { bRet = true; } } return(bRet); }
/// <summary> /// Correct the children elements. /// </summary> public virtual bool CorrectChildren() { bool bRet = false; for (int i = this.Children.Count - 1; i >= 0; i--) { NodeShape shape = this.Children[i]; if (!this.CanHostShape(shape.GetDomainClassId())) { shape.Delete(); bRet = true; } else { if (shape.IsRelativeChildShape && !this.RelativeChildren.Contains(shape)) { if (this.NestedChildren.Contains(shape)) { this.NestedChildren.Remove(shape); } this.RelativeChildren.Add(shape); } else if (!shape.IsRelativeChildShape && !this.NestedChildren.Contains(shape)) { if (this.RelativeChildren.Contains(shape)) { this.RelativeChildren.Remove(shape); } this.NestedChildren.Add(shape); } shape.CorrectChildren(); } } return(bRet); }
/// <summary> /// Adds shapes for a given element. /// </summary> /// <param name="parent">Model element.</param> /// <param name="child"></param> internal void AddShapesForElement(DomainModelElement parent, DomainModelElement child) { if (parent == null || child == null) { return; } DiagramDomainDataDirectory data = child.Store.DomainDataAdvDirectory.ResolveExtensionDirectory <DiagramDomainDataDirectory>(); IDomainModelServices topMost = child.GetDomainModelServices().TopMostService; // find parent shapes List <Guid> shapeIds = DiagramsShapeStore.GetFromStore(parent.Id); if (shapeIds != null) { foreach (Guid shapeId in shapeIds) { // see if each parent shape has a child shape already added to it NodeShape parentShape = child.Store.ElementDirectory.FindElement(shapeId) as NodeShape; if (parentShape == null) { continue; } foreach (Guid elementShapeId in data.GetShapeTypesForElement(child.GetDomainClassId(), parentShape.GetDomainClassId())) { if (!DiagramHelper.IsElementDisplayedOn(parentShape, elementShapeId, child.Id)) { NodeShape shape = topMost.ShapeProvider.CreateShapeForElement(elementShapeId, child) as NodeShape; if (shape.IsRelativeChildShape) { parentShape.AddRelativeChild(shape); } else { parentShape.AddNestedChild(shape); } shape.SetAtFreePositionOnParent(); } } } } //AddRootShapesForElement(child, false); AddRootShapesForElement(child); }