Beispiel #1
0
        public void Do(Action act, bool select = false)
        {
            if (act.cancel)
            {
                return;
            }

            //First do the action. Only the *new* action
            act.SetEdControl(EdControl);
            act.Redo();

            if (select)
            {
                act.AfterAction();
            }

            EdControl.mode.Refresh();

            //Then save the done action. Merge with previous actions if needed.
            //Determine if the actions should be merged
            if (merge && UActions.Count > 0 && UActions.Peek().CanMerge(act))
            {
                UActions.Peek().Merge(act);
            }
            else
            {
                UActions.Push(act);
                ToolStripMenuItem item = new ToolStripMenuItem(act.ToString());
                item.MouseEnter += new EventHandler(updateActCount);
                item.Click      += new EventHandler(onUndoActions);
                undo.DropDownItems.Insert(0, item);
            }

            //Clear the redo buffer because we just did a new action.
            if (redo.DropDownItems.Count > 0)
            {
                redo.DropDownItems.Clear();
                RActions.Clear();
            }

            //Always after doing an action.
            EdControl.repaint();
            EdControl.GiveFocus();

            //Now set some flags.
            undo.Enabled = true;
            redo.Enabled = false;

            merge = true;
            dirty = true;
        }