Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
 }