Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4695 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 0 additions and 209 deletions
@ -1,19 +0,0 @@
@@ -1,19 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
namespace ICSharpCode.SharpDevelop.Internal.Undo |
||||
{ |
||||
/// <summary>
|
||||
/// This Interface describes a the basic Undo/Redo operation
|
||||
/// all Undo Operations must implement this interface.
|
||||
/// </summary>
|
||||
public interface IUndoableOperation |
||||
{ |
||||
void Undo(); |
||||
void Redo(); |
||||
} |
||||
} |
@ -1,50 +0,0 @@
@@ -1,50 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Internal.Undo |
||||
{ |
||||
/// <summary>
|
||||
/// This class stacks the last x operations from the undostack and makes
|
||||
/// one undo/redo operation from it.
|
||||
/// </summary>
|
||||
internal class UndoQueue : IUndoableOperation |
||||
{ |
||||
List<IUndoableOperation> undolist = new List<IUndoableOperation>(); |
||||
|
||||
public UndoQueue(UndoStack stack, int numops) |
||||
{ |
||||
if (stack == null) { |
||||
throw new ArgumentNullException("stack"); |
||||
} |
||||
|
||||
System.Diagnostics.Debug.Assert(numops > 0 , "ICSharpCode.SharpDevelop.Internal.Undo.UndoQueue : numops should be > 0"); |
||||
|
||||
for (int i = 0; i < numops; ++i) { |
||||
if (stack._UndoStack.Count > 0) { |
||||
undolist.Add(stack._UndoStack.Pop()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void Undo() |
||||
{ |
||||
for (int i = 0; i < undolist.Count; ++i) { |
||||
undolist[i].Undo(); |
||||
} |
||||
} |
||||
|
||||
public void Redo() |
||||
{ |
||||
for (int i = undolist.Count - 1 ; i >= 0 ; --i) { |
||||
((IUndoableOperation)undolist[i]).Redo(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,126 +0,0 @@
@@ -1,126 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Internal.Undo |
||||
{ |
||||
/// <summary>
|
||||
/// This class implements an undo stack
|
||||
/// </summary>
|
||||
public class UndoStack |
||||
{ |
||||
Stack<IUndoableOperation> undostack = new Stack<IUndoableOperation>(); |
||||
Stack<IUndoableOperation> redostack = new Stack<IUndoableOperation>(); |
||||
|
||||
public event EventHandler ActionUndone; |
||||
public event EventHandler ActionRedone; |
||||
|
||||
public bool AcceptChanges = true; |
||||
|
||||
/// <summary>
|
||||
/// This property is EXCLUSIVELY for the UndoQueue class, don't USE it
|
||||
/// </summary>
|
||||
internal Stack<IUndoableOperation> _UndoStack { |
||||
get { |
||||
return undostack; |
||||
} |
||||
} |
||||
|
||||
public bool CanUndo { |
||||
get { |
||||
return undostack.Count > 0; |
||||
} |
||||
} |
||||
|
||||
public bool CanRedo { |
||||
get { |
||||
return redostack.Count > 0; |
||||
} |
||||
} |
||||
|
||||
// /// <summary>
|
||||
// /// You call this method to pool the last x operations from the undo stack
|
||||
// /// to make 1 operation from it.
|
||||
// /// </summary>
|
||||
// public void UndoLast(int x)
|
||||
// {
|
||||
// undostack.Push(new UndoQueue(this, x));
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Call this method to undo the last operation on the stack
|
||||
/// </summary>
|
||||
public void Undo() |
||||
{ |
||||
if (undostack.Count > 0) { |
||||
IUndoableOperation uedit = (IUndoableOperation)undostack.Pop(); |
||||
redostack.Push(uedit); |
||||
uedit.Undo(); |
||||
OnActionUndone(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Call this method to redo the last undone operation
|
||||
/// </summary>
|
||||
public void Redo() |
||||
{ |
||||
if (redostack.Count > 0) { |
||||
IUndoableOperation uedit = (IUndoableOperation)redostack.Pop(); |
||||
undostack.Push(uedit); |
||||
uedit.Redo(); |
||||
OnActionRedone(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Call this method to push an UndoableOperation on the undostack, the redostack
|
||||
/// will be cleared, if you use this method.
|
||||
/// </summary>
|
||||
public void Push(IUndoableOperation operation) |
||||
{ |
||||
if (operation == null) { |
||||
throw new ArgumentNullException("UndoStack.Push(UndoableOperation operation) : operation can't be null"); |
||||
} |
||||
|
||||
if (AcceptChanges) { |
||||
undostack.Push(operation); |
||||
ClearRedoStack(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Call this method, if you want to clear the redo stack
|
||||
/// </summary>
|
||||
public void ClearRedoStack() |
||||
{ |
||||
redostack.Clear(); |
||||
} |
||||
|
||||
public void ClearAll() |
||||
{ |
||||
undostack.Clear(); |
||||
redostack.Clear(); |
||||
} |
||||
|
||||
protected void OnActionUndone() |
||||
{ |
||||
if (ActionUndone != null) { |
||||
ActionUndone(null, null); |
||||
} |
||||
} |
||||
|
||||
protected void OnActionRedone() |
||||
{ |
||||
if (ActionRedone != null) { |
||||
ActionRedone(null, null); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue