/// <summary> /// Runs an action and stores it in the undo stack. /// </summary> /// <typeparam name="T"></typeparam> public void RunUndoableAction <T>() where T : UndoableAction, new() { T action = new T(); action.manager = this; if (action.Init()) { clearRedoStack(); _undoStack.Push(action); action.Do(); } }
// Moves one directory up and update file browser // When there is no parent, show the drives of the computer public void DirectoryUp() { _backwardStack.Push(_currentPath); if (!IsTopLevelReached()) { _currentPath = Directory.GetParent(_currentPath).FullName; UpdateFileBrowser(); } else { UpdateFileBrowser(true); } }
// Load last saved level from redo tack and rebuild level void Redo() { // See if there is anything on the redo stack if (redoStack.Count > 0) { // If so, push it to the redo stack undoStack.Push(level); } // Get the last level entry int[,,] redoLevel = redoStack.Pop(); if (redoLevel != null) { // Set level and rebuild the level level = redoLevel; RebuildLevel(); } }
// Goes forward to the previously selected directory (inverse of DirectoryBackward) public void DirectoryForward() { // See if there is anything on the redo stack if (_forwardStack.Count > 0) { // If so, push it to the backward stack _backwardStack.Push(_currentPath); } // Get the last level entry string forwardPath = _forwardStack.Pop(); if (forwardPath != null) { // Set path and update the file browser _currentPath = forwardPath; UpdateFileBrowser(); } }
public static void Main() { SimpleStack <string> a = new SimpleStack <string>(); a.Push("Monday"); a.Push("Tuesday"); a.Push("Wednesday"); a.Push("Thursday"); a.Push("Friday"); FiniteStack <string> b = new FiniteStack <string>(12); b.Push("June"); b.Push("May"); b.Push("April"); b.Push("March"); SimpleStack <Interval> c = new SimpleStack <Interval>(); c.Push(new Interval(5, 31)); c.Push(new Interval(4, 52)); c.Push(new Interval(7, 23)); c.Push(new Interval(3, 44)); c.Push(new Interval(6, 15)); SimpleStack <object> d = new SimpleStack <object>(); d.Push("Sunday"); d.Push(new Interval(2, 30)); d.Push(12.3); a.Copy(b); c.Copy(d); PrintStack(a); PrintStack(b); PrintStack(c); PrintStack(d); }
public static void Main() { SimpleStack <string> a = new SimpleStack <string>(); a.Push("Monday"); a.Push("Tuesday"); a.Push("Wednesday"); a.Push("Thursday"); a.Push("Friday"); FiniteStack <string> b = new FiniteStack <string>(10); b.Push("June"); b.Push("May"); b.Push("April"); b.Push("March"); SimpleStack <Interval> c = new SimpleStack <Interval>(); c.Push(new Interval(5, 41)); c.Push(new Interval(7, 32)); c.Push(new Interval(6, 53)); c.Push(new Interval(3, 24)); c.Push(new Interval(4, 15)); SimpleStack <object> d = new SimpleStack <object>(); d.Push("Saturday"); d.Push(45.6); c.Copy(d); //contravariance(Interval -> object) for IStackWriter PrintStack(a); //covariance(object -> string) for IStackReader PrintStack(b); PrintStack(c); PrintStack(d); }
// ----- PRIVATE METHODS ----- // Load last saved level from undo stack and rebuild level private void Undo() { // See if there is anything on the undo stack if (_undoStack.Count > 0) { // If so, push it to the redo stack _redoStack.Push(_levelEditor.GetLevel()); } // Get the last level entry int[,,] undoLevel = _undoStack.Pop(); if (undoLevel != null) { // Set the level to the previous state _levelEditor.SetLevel(undoLevel); } }
public void AddHistoryEntry(int channel, int count = 1) { SongData.ColumnEntry[] entries = new SongData.ColumnEntry[count]; for (int i = 0; i < count; i++) { if (data.lookupTable[data.currentPattern][channel + i] < 0) { continue; } entries[i] = data.songData[data.lookupTable[data.currentPattern][channel + i]]; } HistoryEvent evt = new HistoryEvent(data.currentPattern, entries, view.position); m_History.Push(evt); }
// Returns to the previously selected directory (inverse of DirectoryForward) public void DirectoryBackward() { // See if there is anything on the backward stack if (_backwardStack.Count > 0) { // If so, push it to the forward stack _forwardStack.Push(currentPath); } // Get the last path entry string backPath = _backwardStack.Pop(); if (backPath != null) { // Set path and update the file browser currentPath = backPath; UpdateFileBrowser(); } }
// Push a level to the undo stack thereby saving it's state public void PushLevel(int[,,] level) { _undoStack.Push(level.Clone() as int[, , ]); }