public virtual void AddRootShapesForElement(DomainModelElement modelElement)//, bool bIgnoreVisualizationBehavior) { DiagramDomainDataDirectory data = modelElement.Store.DomainDataAdvDirectory.ResolveExtensionDirectory <DiagramDomainDataDirectory>(); IDomainModelServices topMost = modelElement.GetDomainModelServices().TopMostService; List <Guid> shapeIds = data.GetRootShapeTypesForElement(modelElement.GetDomainClassId()); if (shapeIds != null) { foreach (Guid shapeId in shapeIds) { ShapeClassInfo shapeInfo = data.ShapeClassInfos[shapeId]; ReadOnlyCollection <ModelElement> diagrams = modelElement.Store.ElementDirectory.FindElements(shapeInfo.DiagramClassType); if (diagrams.Count == 0) { continue; } foreach (Diagram d in diagrams) { if (d.IsVisible && d.CanHostShape(shapeId)) { if (!DiagramHelper.IsElementDisplayedOn(d, shapeId, modelElement.Id)) { NodeShape shape = topMost.ShapeProvider.CreateShapeForElement(shapeId, modelElement) as NodeShape; d.Children.Add(shape); DiagramsShapeStore.AddToStore(shape.Element.Id, shape.Id); shape.FixUpMissingLinkShapes(); } } } } } }
/// <summary> /// Removes a ShapeElement from the shape mapping dictionary. /// </summary> /// <param name="shapeElement">Shape element to remove from the shape mapping dictionary.</param> public virtual void RemoveFromShapeMapping(ShapeElement shapeElement) { if (shapeElement == null) { throw new ArgumentNullException("shapeElement"); } if (shapeElement.Element == null) { throw new ArgumentNullException("shapeElement.Element"); } if (shapeMapping.ContainsKey(shapeElement.Element.Id)) { if (shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id)) { shapeMapping[shapeElement.Element.Id].Remove(shapeElement.Id); if (shapeMapping[shapeElement.Element.Id].Count == 0) { shapeMapping.Remove(shapeElement.Element.Id); } } } DiagramsShapeStore.RemoveFromStore(shapeElement.Element.Id, shapeElement.Id); }
/// <summary> /// Adds a ShapeElement to the shape mapping dictionary. /// </summary> /// <param name="shapeElement">Shape element to add to the shape mapping dictionary.</param> public virtual void AddToShapeMapping(ShapeElement shapeElement, bool bOnlyAddToStore) { if (shapeElement == null) { throw new ArgumentNullException("shapeElement"); } if (shapeElement.Element == null) { throw new ArgumentNullException("shapeElement.Element"); } if (!bOnlyAddToStore) { if (!shapeMapping.ContainsKey(shapeElement.Element.Id)) { shapeMapping.Add(shapeElement.Element.Id, new List <Guid>()); } if (!shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id)) { shapeMapping[shapeElement.Element.Id].Add(shapeElement.Id); } } DiagramsShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id); }
public void DeleteShapesForElement(Store store, Guid modelElementId) { List <Guid> shapes = DiagramsShapeStore.GetFromStore(modelElementId); if (shapes != null) { for (int i = shapes.Count - 1; i >= 0; i--) { ShapeElement shape = store.ElementDirectory.FindElement(shapes[i]) as ShapeElement; if (shape != null) { shape.Delete(); } } } }
/// <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); }
public void DeleteShapesForElement(DomainModelElement modelElement) { if (modelElement != null) { List <Guid> shapes = DiagramsShapeStore.GetFromStore(modelElement.Id); if (shapes != null) { for (int i = shapes.Count - 1; i >= 0; i--) { NodeShape shape = modelElement.Store.ElementDirectory.FindElement(shapes[i]) as NodeShape; if (shape != null) { shape.Delete(); } } } } }
public void DeleteShapesForElement(Store store, Guid modelElementId, Guid shapeTypeId) { List <Guid> shapes = DiagramsShapeStore.GetFromStore(modelElementId); if (shapes != null) { for (int i = shapes.Count - 1; i >= 0; i--) { LinkShape shape = store.ElementDirectory.FindElement(shapes[i]) as LinkShape; if (shape != null) { if (shape.GetDomainClass().Id == shapeTypeId) { shape.Delete(); } } } } }
public virtual void AddRSShapesForElement(DomainModelElement sourceElement, DomainModelElement targetElement, ModelElement con, Guid shapeType) { List <Guid> shapeIdsSource = DiagramsShapeStore.GetFromStore(sourceElement.Id); List <Guid> shapeIdsTarget = DiagramsShapeStore.GetFromStore(targetElement.Id); if (shapeIdsSource == null || shapeIdsTarget == null) { return; } if (shapeIdsSource.Count == 0 || shapeIdsTarget.Count == 0) { return; } IDomainModelServices topMost = sourceElement.GetDomainModelServices().TopMostService; foreach (Guid sourceShapeId in shapeIdsSource) { NodeShape sourceShape = con.Store.ElementDirectory.FindElement(sourceShapeId) as NodeShape; if (sourceShape == null) { continue; } foreach (Guid targetShapeId in shapeIdsTarget) { NodeShape targetShape = con.Store.ElementDirectory.FindElement(targetShapeId) as NodeShape; if (targetShape != null) { if (sourceShape.Diagram == targetShape.Diagram) { if (!DiagramHelper.IsLinkDisplayedOn(sourceShape.Diagram, shapeType, con.Id, sourceShape.Id, targetShape.Id)) { LinkShape shape = topMost.ShapeProvider.CreateShapeForElementLink(shapeType, con, sourceShape, targetShape) as LinkShape; sourceShape.Diagram.LinkShapes.Add(shape); shape.Layout(FixedGeometryPoints.None); } } } } } }