示例#1
0
        /// <summary>
        /// Register a new undo command. Use this method after your
        /// application has performed an operation/command that is
        /// undoable.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        public void AddUndoCommand(UndoCommand cmd)
        {
            Debug.Assert(cmd != null);
            Debug.Assert(m_undoList.Count <= m_maxUndoLevel);

            if (m_maxUndoLevel == 0)
            {
                return;
            }

            UndoInfo info = null;

            if (m_undoList.Count == m_maxUndoLevel)
            {
                // Remove the oldest entry from the undo list to make room.
                info = (UndoInfo)m_undoList[0];
                m_undoList.RemoveAt(0);
            }

            // Insert the new undoable command into the undo list.
            if (info == null)
            {
                info = new UndoInfo();
            }
            info.m_undoCommand = cmd;
            info.m_undoHandler = null;
            m_undoList.Add(info);

            // Clear the redo stack.
            ClearRedo();
        }
示例#2
0
        /// <summary>
        /// Get the text value of the next redo command. Use this method
        /// to update the Text property of your "Redo" menu item if desired.
        /// For example, the text value for a command might be "Draw Line".
        /// This allows you to change your menu item text to "&Redo Draw Line".
        /// </summary>
        /// <returns>Text value of the next redo command.</returns>
        public string GetRedoText()
        {
            UndoCommand cmd = GetNextRedoCommand();

            if (cmd == null)
            {
                return("");
            }
            return(cmd.GetText());
        }
示例#3
0
        /// <summary>
        /// Register a new undo command along with an undo handler. The
        /// undo handler is used to perform the actual undo or redo
        /// operation later when requested.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        /// <param name="undoHandler">Undo handler to perform the actual undo/redo operation.</param>
        public void AddUndoCommand(UndoCommand cmd, IUndoHandler undoHandler)
        {
            AddUndoCommand(cmd);

            if (m_undoList.Count > 0)
            {
                UndoInfo info = (UndoInfo)m_undoList[m_undoList.Count - 1];
                Debug.Assert(info != null);
                info.m_undoHandler = undoHandler;
                undoHandler.refreshHistory(m_undoList);
            }
        }
示例#4
0
        /// <summary>
        /// Retrieve all of the redo commands. Useful for debugging,
        /// to analyze the contents of the redo stack.
        /// </summary>
        /// <returns>Array of commands for redo.</returns>
        public UndoCommand[] GetRedoCommands()
        {
            if (m_redoStack.Count == 0)
            {
                return(null);
            }

            UndoCommand[] cmdList = new UndoCommand[m_redoStack.Count];
            object[]      objList = m_redoStack.ToArray();
            for (int i = 0; i < objList.Length; i++)
            {
                UndoInfo info = (UndoInfo)objList[i];
                cmdList[i] = info.m_undoCommand;
            }

            return(cmdList);
        }
 void IUndoHandler.Redo(UndoCommand cmd)
 {
     if (cmd is FillRandomPointsCommand)
     {
         FillRandomPointsCommand fillPointsCmd = (FillRandomPointsCommand)cmd;
         FillPointHistory pointCmd = null;
         MapElement mapElement = fillPointsCmd.getMapElement();
         for (int i = 0; i < fillPointsCmd.getPointsCount(); i++)
         {
             pointCmd = fillPointsCmd.getPoint(i);
             //Object oldElement = pointCmd.getTileElement_Org();
             Object newElement = pointCmd.getTileElement_New();
             int tileIndex_X = pointCmd.getTileIndex_X();
             int tileIndex_Y = pointCmd.getTileIndex_Y();
             short tileLevel = pointCmd.getTileLevel();
             fillPoint(pointCmd.getMapElement(), mapBufferW, mapBufferH, zoomLevel, tileIndex_X, tileIndex_Y, tileLevel, newElement, true, pointCmd.getStageID());
         }
         if (mapElement != null && !mapElement.Equals(currentMap))
         {
             setCurrentMap(mapElement.getID());
             updateMap_Refresh();
         }
         else
         {
             this.updateMap();
         }
     }
 }
 public UndoInfo()
 {
     m_undoCommand = null;
     m_undoHandler = null;
 }
        /// <summary>
        /// Retrieve all of the redo commands. Useful for debugging,
        /// to analyze the contents of the redo stack.
        /// </summary>
        /// <returns>Array of commands for redo.</returns>
        public UndoCommand[] GetRedoCommands()
        {
            if (m_redoStack.Count == 0)
                return null;

            UndoCommand[] cmdList = new UndoCommand[m_redoStack.Count];
            object[] objList = m_redoStack.ToArray();
            for (int i = 0; i < objList.Length; i++)
            {
                UndoInfo info = (UndoInfo)objList[i];
                cmdList[i] = info.m_undoCommand;
            }

            return cmdList;
        }
        /// <summary>
        /// Register a new undo command along with an undo handler. The
        /// undo handler is used to perform the actual undo or redo
        /// operation later when requested.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        /// <param name="undoHandler">Undo handler to perform the actual undo/redo operation.</param>
        public void AddUndoCommand(UndoCommand cmd, IUndoHandler undoHandler)
        {
            AddUndoCommand(cmd);

            if (m_undoList.Count > 0)
            {
                UndoInfo info = (UndoInfo)m_undoList[m_undoList.Count - 1];
                Debug.Assert(info != null);
                info.m_undoHandler = undoHandler;
                undoHandler.refreshHistory(m_undoList);
            }
        }
        /// <summary>
        /// Register a new undo command. Use this method after your
        /// application has performed an operation/command that is
        /// undoable.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        public void AddUndoCommand(UndoCommand cmd)
        {
            Debug.Assert(cmd != null);
            Debug.Assert(m_undoList.Count <= m_maxUndoLevel);

            if (m_maxUndoLevel == 0)
                return;

            UndoInfo info = null;
            if (m_undoList.Count == m_maxUndoLevel)
            {
                // Remove the oldest entry from the undo list to make room.
                info = (UndoInfo)m_undoList[0];
                m_undoList.RemoveAt(0);
            }

            // Insert the new undoable command into the undo list.
            if (info == null)
                info = new UndoInfo();
            info.m_undoCommand = cmd;
            info.m_undoHandler = null;
            m_undoList.Add(info);

            // Clear the redo stack.
            ClearRedo();
        }
示例#10
0
 public UndoInfo()
 {
     m_undoCommand = null;
     m_undoHandler = null;
 }