Beispiel #1
0
 public void SaveUndoActionStack(DocumentUndoAction undoAction)
 {
     /*
      * var ser = new DataContractSerializer(typeof(DocumentUndoAction));
      * using (XmlWriter xw = XmlWriter.Create(Console.Out))
      * {
      *  ser.WriteObject(xw, undoAction);
      * }*/
 }
Beispiel #2
0
        public void PushUndoAction(DocumentUndoAction action)
        {
            // if the action is empty (does not modifies the docuement, skip adding it to the stack
            if (action.IsEmptyAction())
            {
                return;
            }

            SaveUndoActionStack(action);

            if (__UndoActions.Count == 0 || !CanMerge)
            {
                if (__UndoGroup != null)
                {
                    __UndoGroup.Add(action);
                }
                else
                {
                    __UndoActions.Push(action);
                }
            }
            else
            {
                DocumentUndoAction lastAction = __UndoActions.Peek();
                if (lastAction.CanMerge(action))
                {
                    lastAction.Merge(action);
                }
                else
                {
                    if (__UndoGroup != null)
                    {
                        __UndoGroup.Add(action);
                    }
                    else
                    {
                        __UndoActions.Push(action);
                    }
                }
            }

            CanMerge = true;
            __RedoActions.Clear();
            DoUndoCountChanged();
        }
Beispiel #3
0
        public void Undo(OutlinerDocument document, TreeListView treeListView)
        {
            while (__UndoActions.Count > 0)
            {
                DocumentUndoAction action = __UndoActions.Pop();
                action.Undo(document, treeListView);

                __RedoActions.Push(action);
                DoUndoCountChanged();

                if (!action.UndoNext)
                {
                    break;
                }
            }

            GC.Collect();
        }