Beispiel #1
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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Removes a ShapeElement from the shape mapping dictionary.
        /// </summary>
        /// <param name="shapeElement">Shape element to remove from the shape mapping dictionary.</param>
        public virtual void RemoveFromShapeMapping(ShapeElement shapeElement)
        {
            if (shapeElement == null)
            {
                throw new ArgumentNullException("shapeElement");
            }

            if (shapeElement.Element == null)
            {
                throw new ArgumentNullException("shapeElement.Element");
            }

            if (shapeMapping.ContainsKey(shapeElement.Element.Id))
            {
                if (shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id))
                {
                    shapeMapping[shapeElement.Element.Id].Remove(shapeElement.Id);
                    if (shapeMapping[shapeElement.Element.Id].Count == 0)
                    {
                        shapeMapping.Remove(shapeElement.Element.Id);
                    }
                }
            }
            DiagramsShapeStore.RemoveFromStore(shapeElement.Element.Id, shapeElement.Id);
        }
        /// <summary>
        /// Clean up.
        /// </summary>
        protected override void OnDispose()
        {
            this.shapeElement = null;
            this.sufaceDiagram = null;

            base.OnDispose();
        }
Beispiel #4
0
        /// <summary>
        /// Adds a ShapeElement to the shape mapping dictionary.
        /// </summary>
        /// <param name="shapeElement">Shape element to add to the shape mapping dictionary.</param>
        public virtual void AddToShapeMapping(ShapeElement shapeElement, bool bOnlyAddToStore)
        {
            if (shapeElement == null)
            {
                throw new ArgumentNullException("shapeElement");
            }

            if (shapeElement.Element == null)
            {
                throw new ArgumentNullException("shapeElement.Element");
            }

            if (!bOnlyAddToStore)
            {
                if (!shapeMapping.ContainsKey(shapeElement.Element.Id))
                {
                    shapeMapping.Add(shapeElement.Element.Id, new List <Guid>());
                }

                if (!shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id))
                {
                    shapeMapping[shapeElement.Element.Id].Add(shapeElement.Id);
                }
            }

            DiagramsShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id);
        }
Beispiel #5
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>
        /// Constuctor.
        /// </summary>
        /// <param name="viewModelStore">The store this view model belongs to.</param>
        /// <param name="diagram">The Diagram this item belongs to.</param>
        /// <param name="shapeElement">Shape element to be associated with this vm.</param>
        protected BaseDiagramItemViewModel(ViewModelStore viewModelStore, DiagramSurfaceViewModel diagram, ShapeElement shapeElement)
            : base(viewModelStore, shapeElement.Element, true, false)
        {
            this.sufaceDiagram = diagram;
            this.shapeElement = shapeElement;

            this.Initialize();
        }
 /// <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 #8
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);
 }
Beispiel #9
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);
 }
            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 #11
0
        /// <summary>
        /// Searches for the shapes of a specific type hosting a specific element and deletes them.
        /// </summary>
        /// <param name="store">Store.</param>
        /// <param name="shapeDomainClassType">Type of the shape.</param>
        /// <param name="elementId">Model element Id.</param>
        /// <remarks>Needs to be called within a modeling transaction context.</remarks>
        public static void DeleteShapes(Store store, Guid shapeDomainClassType, Guid elementId)
        {
            ReadOnlyCollection <ModelElement> shapes = store.ElementDirectory.FindElements(shapeDomainClassType);

            for (int i = shapes.Count - 1; i >= 0; i--)
            {
                ShapeElement shapeElement = shapes[i] as ShapeElement;
                if (shapeElement != null)
                {
                    if (shapeElement.Element != null)
                    {
                        if (shapeElement.Element.Id == elementId)
                        {
                            shapeElement.Delete();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Adds a ShapeElement to the shape mapping dictionary.
        /// </summary>
        /// <param name="shapeElement">Shape element to add to the shape mapping dictionary.</param>
        public virtual void AddToShapeMapping(ShapeElement shapeElement, bool bOnlyAddToStore)
        {
            if (shapeElement == null)
                throw new ArgumentNullException("shapeElement");

            if (shapeElement.Element == null)
                throw new ArgumentNullException("shapeElement.Element");

            if (!bOnlyAddToStore)
            {
                if (!shapeMapping.ContainsKey(shapeElement.Element.Id))
                    shapeMapping.Add(shapeElement.Element.Id, new List<Guid>());

                if (!shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id))
                    shapeMapping[shapeElement.Element.Id].Add(shapeElement.Id);
            }

            DiagramsShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id);
        }
Beispiel #13
0
        /// <summary>
        /// Searches for the shape of a specific type hosting a specific element and deletes it.
        /// </summary>
        /// <param name="store">Store.</param>
        /// <param name="shapeDomainClassType">Type of the shape.</param>
        /// <param name="elementId">Model element Id.</param>
        /// <remarks>Needs to be called within a modeling transaction context.</remarks>
        public static void DeleteShape(Store store, Guid shapeDomainClassType, Guid elementId)
        {
            ReadOnlyCollection <ModelElement> shapes = store.ElementDirectory.FindElements(shapeDomainClassType);

            foreach (ModelElement m in shapes)
            {
                if (m is ShapeElement)
                {
                    ShapeElement shapeElement = m as ShapeElement;
                    if (shapeElement.Element != null)
                    {
                        if (shapeElement.Element.Id == elementId)
                        {
                            shapeElement.Delete();
                            return;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Removes a ShapeElement from the shape mapping dictionary.
        /// </summary>
        /// <param name="shapeElement">Shape element to remove from the shape mapping dictionary.</param>
        public virtual void RemoveFromShapeMapping(ShapeElement shapeElement, bool bOnlyRemoveFromStore)
        {
            if (shapeElement == null)
                throw new ArgumentNullException("shapeElement");

            if (shapeElement.Element == null)
                throw new ArgumentNullException("shapeElement.Element");

            if (!bOnlyRemoveFromStore)
            {
                if (shapeMapping.ContainsKey(shapeElement.Element.Id))
                    if (shapeMapping[shapeElement.Element.Id].Contains(shapeElement.Id))
                    {
                        shapeMapping[shapeElement.Element.Id].Remove(shapeElement.Id);
                        if (shapeMapping[shapeElement.Element.Id].Count == 0)
                            shapeMapping.Remove(shapeElement.Element.Id);
                    }
            }

            DiagramsShapeStore.RemoveFromStore(shapeElement.Element.Id, shapeElement.Id);
        }
 /// <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)
 {
     if (shapeElement == this.MainElementShape)
     {
         GraphicalDependencyShapeStore.AddToStore(shapeElement.Element.Id, shapeElement.Id);
     }
     //else
     //    base.AddToShapeMapping(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);
 }
        /// <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);            
        }
 /// <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);
 }
 /// <summary>
 /// Adds a ShapeElement to the shape mapping dictionary.
 /// </summary>
 /// <param name="shapeElement">Shape element to add to the shape mapping dictionary.</param>
 public virtual void AddToShapeMapping(ShapeElement shapeElement)
 {
     this.AddToShapeMapping(shapeElement, false);
 }
 /// <summary>
 /// Removes a ShapeElement from the shape mapping dictionary.
 /// </summary>
 /// <param name="shapeElement">Shape element to remove from the shape mapping dictionary.</param>
 public virtual void RemoveFromShapeMapping(ShapeElement shapeElement)
 {
     this.RemoveFromShapeMapping(shapeElement, false);
 }
Beispiel #22
0
 /// <summary>
 /// Removes a ShapeElement from the shape mapping dictionary.
 /// </summary>
 /// <param name="shapeElement">Shape element to remove from the shape mapping dictionary.</param>
 public virtual void RemoveFromShapeMapping(ShapeElement shapeElement)
 {
     this.RemoveFromShapeMapping(shapeElement, false);
 }
Beispiel #23
0
 /// <summary>
 /// Adds a ShapeElement to the shape mapping dictionary.
 /// </summary>
 /// <param name="shapeElement">Shape element to add to the shape mapping dictionary.</param>
 public virtual void AddToShapeMapping(ShapeElement shapeElement)
 {
     this.AddToShapeMapping(shapeElement, false);
 }