/// <summary>
        /// Makes sure child and link shapes are visible
        /// </summary>
        public virtual void FixupShapeVisibility()
        {
            ReadOnlyCollection <NodeShapeReferencesNestedChildren> linksN = NodeShapeReferencesNestedChildren.GetLinksToNestedChildren(this.ShapeElement);

            foreach (NodeShapeReferencesNestedChildren link in linksN)
            {
                OnNestedChildShapeElementAdded(link);
            }

            ReadOnlyCollection <NodeShapeReferencesRelativeChildren> linksR = NodeShapeReferencesRelativeChildren.GetLinksToRelativeChildren(this.ShapeElement);

            foreach (NodeShapeReferencesRelativeChildren link in linksR)
            {
                OnRelativeChildShapeElementAdded(link);
            }

            foreach (BaseDiagramItemElementViewModel vm in this.NestedChildren)
            {
                vm.FixupShapeVisibility();
            }

            foreach (BaseDiagramItemElementViewModel vm in this.RelativeChildren)
            {
                vm.FixupShapeVisibility();
            }
        }
        /// <summary>
        /// Called whenever a relationship of type NodeShapeReferencesRelativeChildren is added and
        /// the element hosted by this model is the source.
        /// </summary>
        /// <param name="con"></param>
        protected virtual void OnRelativeChildShapeElementAdded(NodeShapeReferencesRelativeChildren con)
        {
            if (IsDisplayingNodeShape(con.ChildShape))
            {
                return;
            }

            DiagramItemElementViewModel vm = this.ViewModelStore.Factory.CreateDiagramItemViewModel(con.ChildShape.GetDomainClassId(), this.Diagram, con.ChildShape);

            this.AddRelativeChild(vm);
        }
        /// <summary>
        /// Called whenever a relationship of type NodeShapeReferencesRelativeChildren is removed and
        /// the element hosted by this model is the source.
        /// </summary>
        /// <param name="args"></param>
        protected virtual void OnRelativeChildShapeElementRemoved(ElementDeletedEventArgs args)
        {
            NodeShapeReferencesRelativeChildren con = args.ModelElement as NodeShapeReferencesRelativeChildren;
            NodeShape nodeShape = con.ChildShape;

            if (nodeShape != null)
            {
                for (int i = this.relativeChildItems.Count - 1; i >= 0; i--)
                {
                    if (this.relativeChildItems[i].ShapeElement.Id == nodeShape.Id)
                    {
                        BaseDiagramItemElementViewModel vm = this.relativeChildItems[i];
                        this.RemoveRelativeChild(vm);
                        vm.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            NodeShapeReferencesRelativeChildren con = e.ModelElement as NodeShapeReferencesRelativeChildren;

            if (con != null)
            {
                NodeShape childShape  = con.ChildShape;
                NodeShape parentShape = con.ParentShape;

                if (childShape != null && parentShape != null)
                {
                    if (childShape.MovementBehaviour == ShapeMovementBehaviour.PositionOnEdgeOfParent)
                    {
                        childShape.CorrectLocation();
                    }
                }
                else
                {
                    con.Delete();
                }
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="con"></param>
 protected override void OnRelativeChildShapeElementAdded(NodeShapeReferencesRelativeChildren con)
 {
     throw new NotSupportedException();
 }