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();
                        }
                    }
                }
            }
Beispiel #2
0
            /// <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();
                 }
             }
         }
     }
 }
Beispiel #4
0
            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);
                                }
                            }
                        }
                    }
                }
            }