DrawToolsRedux/UndoManager.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;

/// Undo-Redo code is written using the article:
/// http://www.codeproject.com/cs/design/commandpatterndemo.asp
//  The Command Pattern and MVC Architecture
//  By David Veeneman.
namespace DrawTools
{
	/// <summary>
	/// Class is responsible for executing Undo - Redo operations
	/// </summary>
	internal class UndoManager
	{
		#region Class Members
		private Layers layers;

		private List<Command> historyList;
		private int nextUndo;
		#endregion  Class Members

		#region Constructor
		public UndoManager(Layers layerList)
		{
			layers = layerList;

			ClearHistory();
		}
		#endregion Constructor

		#region Properties
		/// <summary>
		/// Return true if Undo operation is available
		/// </summary>
		public bool CanUndo
		{
			get
			{
				// If the NextUndo pointer is -1, no commands to undo
				if (nextUndo < 0 ||
					nextUndo > historyList.Count - 1) // precaution
				{
					return false;
				}

				return true;
			}
		}

		/// <summary>
		/// Return true if Redo operation is available
		/// </summary>
		public bool CanRedo
		{
			get
			{
				// If the NextUndo pointer points to the last item, no commands to redo
				if (nextUndo == historyList.Count - 1)
				{
					return false;
				}
后面还有 103 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。