Ejemplo n.º 1
0
		protected virtual void OnRedone(UndoPoint e)
		{
			if (Redone != null)	Redone(e);
		}
Ejemplo n.º 2
0
		private UndoPoint AddPoint(Element element, UndoAction action, string description, bool overwrite)
		{
			if (Suspended) return null;

			UndoPoint undo = null;
			string key = null;
			string createDesc = null;

			//Create undopoint
			if (element is Shape || element is Line)
			{
				undo = new UndoPoint(element, action);
				key = element.Key;
				createDesc = element.GetType().Name;
			}
			else
			{
				return null;
			}

			//Remove any previous undos ahead of this one
			if (mUndoPointer < List.Count)
			{
				for (int i = mUndoPointer+1;  i < List.Count; i++)
				{
					List.RemoveAt(i);
				}
			}

			//Set description
			if (description == null || description == "")
			{
				if (action == UndoAction.Add)
				{
					undo.Description = "Add " + createDesc;
				}
				else if (action == UndoAction.Edit)
				{
					undo.Description = "Edit " + createDesc;
				}
				else if (action == UndoAction.Remove)
				{
					undo.Description = "Remove " + createDesc;
				}
			}
			else
			{
				undo.Description = description;
			}

			//Get current undopoint
			UndoPoint currentUndo = null;

			if (mUndoPointer > -1) currentUndo = (UndoPoint) List[mUndoPointer];

			//Check if must add or update the undopoint
			if (overwrite && mUndoPointer > -1 && action == UndoAction.Edit && currentUndo.Key == key)
			{
				List[mUndoPointer] = undo; 
			}
			else
			{
				//Add object to internal arraylist
				List.Add(undo);
				mUndoPointer = List.Count - 1;
			}

			return undo;
		}
Ejemplo n.º 3
0
		protected virtual void OnUndone(UndoPoint e)
		{
			if (Undone != null) Undone(e);
		}