protected void traversalAndExcute(bool breakAtFirstUnableToExcute) { List <IExcutable> removeList = null; for (int i = 0; i < _excutableList.Count; i++) { IExcutable excutable = (IExcutable)_excutableList[i]; if (!excutable.shouldCancel()) { if (excutable.canExcute()) { excutable.excute(); if (removeList == null) { removeList = new List <IExcutable>(); } removeList.Add(excutable); } else { if (breakAtFirstUnableToExcute) { break; } } } else { if (removeList == null) { removeList = new List <IExcutable>(); } removeList.Add(excutable); } } //remove all canceled or excuted excutables if (removeList != null) { for (int i = 0; i < removeList.Count; i++) { IExcutable discardedExcutable = removeList[i]; _excutableList.Remove(discardedExcutable); } } }
/// <summary> /// 创建插件公共事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Plugin_Click(object sender, EventArgs e) { ToolStripItem item = sender as ToolStripItem; if (null != item) { if (null != item.Tag) { IExcutable plugin = item.Tag as IExcutable; if (null != plugin) { CodeContent.RichText = plugin.Excute(CodeContent.RichText); } } } }
public void removeExcutable(IExcutable excutable) { lock (_excutableList) { _excutableList.Remove(excutable); } }
public void addExcutable(IExcutable excutable) { lock (_excutableList) { _excutableList.Add(excutable); } }
/// <summary> /// 先清空Redo栈,将Command对象压入栈 /// </summary> /// <param name="command">Command对象</param> public void AddCommand(IExcutable command) { redoMementos.Clear(); undoMementos.Push(command); }
public MultipleCommand AddCommand(IExcutable command) { m_Commands.Add(command); return this; }
public void removeExcutable(IExcutable excutable) { _runLoop.removeExcutable(excutable); }
public void addExcutable(IExcutable excutable) { _runLoop.addExcutable(excutable); }