示例#1
0
 internal override OperationResult UndoOperation()
 {
     /*
      * forbid undo in those cases where elements couldn't be ordered
      * in an ordering that would allow to put them back in the diagram
      * safely
      */
     if (CheckOrdering && !safeOrdering)
     {
         return(OperationResult.Failed);
     }
     foreach (Element element in DeletedElements)
     {
         if (IsInDiagram(element))
         {
             ErrorDescription = CommandError.CMDERR_REMOVED_ELEMENT_BEING_USED;
             return(OperationResult.Failed);
         }
     }
     foreach (Element element in _deletionOrder.Reverse())
     {
         if (DeletedElements.Contains(element))
         {
             element.PutMeBackToModel();
             Diagram.AddModelElement(element, DeletedElementsViewHelpers[element]);
         }
     }
     return(OperationResult.OK);
 }
示例#2
0
        internal override void CommandOperation()
        {
            IList <Element> _deleted;

            // try to order elements
            if (PSMTree.ReturnElementsInPSMOrder(DeletedElements, out _deleted, true))
            {
                safeOrdering   = true;
                _deletionOrder = _deleted.Reverse();
            }
            else
            {
                // this will forbid undo
                safeOrdering   = false;
                _deletionOrder = DeletedElements;
            }

            foreach (Element element in _deletionOrder)
            {
                if (DeletedElements.Contains(element))
                {
                    DeletedElementsViewHelpers[element] = Diagram.DiagramElements[element];
                    element.RemoveMeFromModel();
                    Diagram.RemoveModelElement(element);
                }
                //AssociatedElements.Add(element);
            }
        }