Exemple #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);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Called whenever a model element is beeing deleted.
        /// </summary>
        /// <param name="e"></param>
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            base.ElementDeleting(e);

            DomainModelElement modelElement = e.ModelElement as DomainModelElement;

            if (modelElement == null)
            {
                return;
            }


            List <Guid> shapes = GraphicalDependencyShapeStore.GetFromStore(modelElement.Id);

            if (shapes != null)
            {
                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;
            }
        }
 /// <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);
 }
Exemple #4
0
 /// <summary>
 /// Add to shape mapping override.
 /// </summary>
 /// <param name="shapeElement"></param>
 public override void AddToShapeMapping(ShapeElement shapeElement)
 {
     if (shapeElement == this.MainElementShape)
     {
         GraphicalDependencyShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id);
     }
     //else
     //    base.AddToShapeMapping(shapeElement);
 }
Exemple #5
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);
 }
 /// <summary>
 /// Add to shape mapping override.
 /// </summary>
 /// <param name="shapeElement"></param>
 public override void AddToShapeMapping(ShapeElement shapeElement)
 {
     GraphicalDependencyShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id);
     //base.AddToShapeMapping(shapeElement, true);
 }