示例#1
0
        /// <summary>
        /// Undoes the last step.
        /// </summary>
        /// <param name="buffer">Buffer to use</param>
        /// <remarks>Used internally, don't use!</remarks>
        internal UndoStep Undo(ref BufferManager buffer)
        {
            if (UndoStack.Count > 0)
            {
                UndoStep step = (UndoStep)UndoStack.Peek();
                RedoStack.Push(step);
                UndoStack.Pop();
                switch (step.Action)
                {
                case UndoAction.Insert:
                    buffer.SetBytes(step.Start, step.GetBytes(), false);
                    break;

                case UndoAction.Remove:
                    buffer.RemoveBytes(step.Start, step.GetBytes().Length);
                    break;

                case UndoAction.Overwrite:
                    buffer.SetBytes(step.Start, step.GetOldBytes(), true);
                    break;
                }
                EventHandler <UndoEventArgs> temp = ActionUndone;
                if (temp != null)
                {
                    temp(this, new UndoEventArgs(step, true));
                }

                return(step);
            }
            return(null);
        }
示例#2
0
		/// <summary>
		/// Adds a step to the stack.
		/// </summary>
		/// <param name="step">The step to add.</param>
		internal void AddUndoStep(UndoStep step)
		{
			UndoStack.Push(step);
			RedoStack.Clear();
			
			EventHandler<UndoEventArgs> temp = ActionUndone;
			if (temp != null)
				temp(this, new UndoEventArgs(step, false));
		}
示例#3
0
        /// <summary>
        /// Adds a step to the stack.
        /// </summary>
        /// <param name="step">The step to add.</param>
        internal void AddUndoStep(UndoStep step)
        {
            UndoStack.Push(step);
            RedoStack.Clear();

            EventHandler <UndoEventArgs> temp = ActionUndone;

            if (temp != null)
            {
                temp(this, new UndoEventArgs(step, false));
            }
        }
 public UndoEventArgs(UndoStep step, bool redo)
 {
     undostep = step;
     isRedo   = redo;
 }
示例#5
0
		public UndoEventArgs(UndoStep step, bool redo)
		{
			undostep = step;
			isRedo = redo;
		}