Beispiel #1
0
        /// <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 DomainModelElement)
            {
                DomainModelElement modelElement = args.ModelElement as DomainModelElement;

                List <Guid> shapes = GraphicalDependencyShapeStore.GetFromStore(modelElement.Id);
                if (shapes != null)
                {
                    if (shapes.Count > 0)
                    {
                        modelElement.Store.UndoManager.UndoState = UndoState.DisabledNoFlush;
                        using (Transaction t = modelElement.Store.TransactionManager.BeginTransaction("", true))
                        {
                            for (int i = shapes.Count - 1; i >= 0; i--)
                            {
                                ShapeElement shape = modelElement.Store.ElementDirectory.FindElement(shapes[i]) as ShapeElement;
                                if (shape != null)
                                {
                                    shape.Delete();
                                }
                            }
                            t.Commit();
                        }
                        modelElement.Store.UndoManager.UndoState = UndoState.Enabled;
                        GraphicalDependencyShapeStore.RemoveFromStore(modelElement.Id);
                    }
                }
            }
        }
 /// <summary>
 /// Remove from shape mapping override.
 /// </summary>
 /// <param name="shapeElement"></param>
 public override void RemoveFromShapeMapping(ShapeElement shapeElement)
 {
     if (shapeElement.Element != null)
     {
         GraphicalDependencyShapeStore.RemoveFromStore(shapeElement.Element.Id, shapeElement.Id);
     }
     //base.RemoveFromShapeMapping(shapeElement, true);
 }
Beispiel #3
0
 /// <summary>
 /// Remove from shape mapping override.
 /// </summary>
 /// <param name="shapeElement"></param>
 public override void RemoveFromShapeMapping(ShapeElement shapeElement)
 {
     if (shapeElement == this.MainElementShape)
     {
         if (shapeElement.Element != null)
         {
             GraphicalDependencyShapeStore.RemoveFromStore(shapeElement.Element.Id, shapeElement.Id);
         }
     }
     //else
     //    base.RemoveFromShapeMapping(shapeElement);
 }