private MemoryStream GetRedoStream() { if (this.canRedo) { MemoryStream resStream = null; int index = history.IndexOf(currentElement); if (index == history.Count - 1) { currentElement = history.Last <HistoryElement>(); } else { if (index == -1) { currentElement = history.First <HistoryElement>(); } else { currentElement = history.ElementAt <HistoryElement>(index + 1); } } resStream = currentElement.Stream; return(resStream); } return(null); }
private bool MakeSnapshot() { MemoryStream currState = new MemoryStream(); currState.Seek(0, SeekOrigin.Begin); bool result = this.parent.SaveToHistory(currState); currState.Seek(0, SeekOrigin.Begin); //currState.Close(); if (!result) { return(false); } HistoryElement item = new HistoryElement(currState, false); int index = -1; index = history.IndexOf(currentElement); if (index == history.Count - 1) { history.Add(item); currentElement = item; return(true); } history.RemoveRange(index + 1, (history.Count - index - 1)); history.Add(item); currentElement = item; return(true); }
private MemoryStream GetUndoStream() { if (this.canUndo) { MemoryStream resStream = null; int index = history.IndexOf(currentElement); if (index <= 0) { resStream = currentElement.Stream; } if (index > 0) { currentElement = history.ElementAt <HistoryElement>(index - 1); resStream = currentElement.Stream; } return(resStream); } return(null); }