Ejemplo n.º 1
0
		internal void saveCommand(Command cmd, FlowChart flowChart)
		{
			if (maxDepth == 0 || !flowChart.confirmRecordAction(cmd))
			{
				cmd.freeUndoResources();
				return;
			}

			if (currCmd < commands.Count - 1)
			{
				for (int i = currCmd + 1; i < commands.Count; ++i)
					commands[i].freeRedoResources();
				commands.RemoveRange(currCmd + 1, commands.Count - currCmd - 1);
			}

			commands.Add(cmd);
			currCmd++;

			if (commands.Count > maxDepth)
			{
				commands[0].freeUndoResources();
				commands.RemoveAt(0);
				currCmd--;
			}

			flowChart.fireActionRecorded(cmd);
		}
Ejemplo n.º 2
0
		public int IndexOf(Command value)
		{
			return innerList.IndexOf(value);
		}
Ejemplo n.º 3
0
		public bool Contains(Command value)
		{
			return innerList.Contains(value);
		}
Ejemplo n.º 4
0
		public bool Contains(Command cmd)
		{
			return List.Contains(cmd);
		}
Ejemplo n.º 5
0
		public void Remove(Command cmd)
		{
			List.Remove(cmd);
		}
Ejemplo n.º 6
0
		public void Add(Command cmd)
		{
			List.Add(cmd);
		}
Ejemplo n.º 7
0
		public void AddSubCmd(Command cmd)
		{
			subCommands.Add(cmd);
		}
Ejemplo n.º 8
0
		internal void executeCommand(Command cmd)
		{
			if (cmd == null) return;

			// just execute the action if no later undo is needed
			if (!undoEnabled)
			{
				cmd.setContext(defaultCmdContext);
				cmd.Execute(false);
				cmd.freeUndoResources();
				return;
			}

			// if executing the ChangeItem comand on table, clear last reference
			if (cmd == currChangeTableCmd)
				currChangeTableCmd = null;

			// if redimensioning a table, handle arrow removals
			RemoveItemCmd removeItemCmd = cmd as RemoveItemCmd;
			if (currRedimCmd != null && cmd != currRedimCmd &&
				removeItemCmd != null)
			{
				if (removeItemCmd.getItem() is Arrow)
				{
					Arrow arr = (Arrow)removeItemCmd.getItem();
					if (arr.Origin == currRedimCmd.getItem() ||
						arr.Destination == currRedimCmd.getItem())
					{
						cmd.setContext(defaultCmdContext);
						cmd.Execute(true);
						currRedimCmd.AddSubCmd(cmd);
						return;
					}
				}
			}

			// handle current composite command
			if (currCompositeCmd != null)
			{
				if (cmd == currCompositeCmd)
				{
					history.saveCommand(currCompositeCmd, document);
					currCompositeCmd = null;
					return;
				}
				else
				{
					cmd.setContext(defaultCmdContext);
					cmd.Execute(true);
					currCompositeCmd.AddSubCmd(cmd);
					return;
				}
			}

			// create a single composite command for modify or remove commands
			// that lead to modification or removal of more items
			if (currCommand == null)
			{
				currCommand = cmd;
				cmd.setContext(defaultCmdContext);
				cmd.Execute(true);
				history.saveCommand(cmd, document);
				currCommand = null;
			}
			else
			{
				cmd.setContext(defaultCmdContext);
				cmd.Execute(true);
				currCommand.AddSubCmd(cmd);
			}
		}