Exemple #1
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            base.ElementAdded(e);

            DiagramHasLinkShapes con = e.ModelElement as DiagramHasLinkShapes;

            if (con != null)
            {
                LinkShape linkShape = con.LinkShape;
                Diagram   diagram   = con.Diagram;

                if (linkShape != null && diagram != null)
                {
                    diagram.RemoveFromShapeMapping(linkShape);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Called whenever a child element is deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleted(ElementDeletedEventArgs e)
        {
            base.ElementDeleted(e);

            DiagramHasChildren con = e.ModelElement as DiagramHasChildren;

            if (con != null)
            {
                NodeShape nodeShape = con.ChildShape;
                Diagram   diagram   = con.Diagram;

                if (nodeShape != null && diagram != null)
                {
                    diagram.RemoveFromShapeMapping(nodeShape);
                }
            }
        }
        /// <summary>
        /// Called whenever a model element is deleted from the store.
        /// </summary>
        /// <param name="sender">ViewModelStore</param>
        /// <param name="args">Event Arguments for notification of the removal of an ModelElement.</param>
        private void OnElementDeleted(object sender, ElementDeletedEventArgs args)
        {
            if (args.ModelElement is DiagramHasChildren)
            {
                DiagramHasChildren con = args.ModelElement as DiagramHasChildren;
                if (con != null)
                {
                    NodeShape nodeShape = con.ChildShape;
                    Diagram   diagram   = con.Diagram;

                    if (nodeShape != null && diagram != null)
                    {
                        if (nodeShape.Element != null)
                        {
                            diagram.RemoveFromShapeMapping(nodeShape);
                        }
                    }
                }
            }
            else if (args.ModelElement is ShapeElementContainsChildShapes)
            {
                ShapeElementContainsChildShapes con = args.ModelElement as ShapeElementContainsChildShapes;
                if (con != null)
                {
                    NodeShape childShape  = con.ChildShape;
                    NodeShape parentShape = con.ParentShape;

                    if (childShape != null && parentShape != null)
                    {
                        if (childShape.Element != null)
                        {
                            parentShape.RemoveFromShapeMapping(childShape);
                        }
                    }
                }
            }
        }