コード例 #1
0
        public void ProcessRedo()
        {
            if (_Redo.Count > 0)
            {
                var item = _Redo.Last();
                _Redo.Remove(item);

                var undoItem = _UndoHistory.Last();
                _Undo.Add(undoItem);
                _UndoHistory.Remove(undoItem);

                foreach (var historyTile in item.Reverse())
                {
                    _world.Tiles[historyTile.Location.X, historyTile.Location.Y] = historyTile.Tile;
                    _renderer.UpdateWorldImage(new PointInt32(historyTile.Location.X, historyTile.Location.Y));
                }
            }
        }
コード例 #2
0
        public void ProcessUndo()
        {
            if (_Undo.Count > 0)
            {
                var item = _Undo.Last();
                _Undo.Remove(item);

                var redo = new Queue <HistoryTile>();
                foreach (var historyTile in item.Reverse())
                {
                    redo.Enqueue(new HistoryTile(historyTile.Location, (Tile)_world.Tiles[historyTile.Location.X, historyTile.Location.Y].Clone()));
                    _world.Tiles[historyTile.Location.X, historyTile.Location.Y] = historyTile.Tile;
                    _renderer.UpdateWorldImage(new PointInt32(historyTile.Location.X, historyTile.Location.Y));
                }

                _UndoHistory.Add(item);
                _Redo.Add(redo.ToArray());
            }
        }