public void loadFromXML(XmlTextReader aXMLTextReader) { var lReader = new XMLAttributeReader(aXMLTextReader); if (aXMLTextReader.IsEmptyElement == false) { aXMLTextReader.Read(); string lStateName; CSScipt lScript; while (aXMLTextReader.Name.Equals("State", StringComparison.Ordinal) && aXMLTextReader.IsStartElement()) { lStateName = lReader.getAttribute <string>("Name"); lScript = new CSScipt(mItemBrowser); try { lScript.loadFromXML(aXMLTextReader); } catch (Exception lExc) { throw new ArgumentException("State '" + lStateName + "'. " + lExc.Message, lExc); } addState(lStateName, lScript); aXMLTextReader.Read(); aXMLTextReader.Read(); } } check(); }
private void tsButton_Add_Click(object aSender, EventArgs aEventArgs) { bool lExit = false; var lName = "State" + (mCSharpFSMClone.StateCount + 1).ToString(); do { try { lName = StringForm.getString(lName, this, "Add State"); if (lName != null) { if (mCSharpFSMClone.isStateExists(lName)) { throw new ArgumentException("State '" + lName + "' already exists. "); } CSScipt lScript = new CSScipt(mBrowser); if (lScript.setupByForm(lName, this) == DialogResult.OK) { mCSharpFSMClone.addState(lName, lScript); updateForm(); updateButtons(); } lExit = true; } } catch (Exception lExc) { MessageForm.showMessage(lExc.Message, this); } }while (lName != null && lExit == false); }
public void addState(string aName, CSScipt aScript) { if (String.IsNullOrWhiteSpace(aName)) { throw new ArgumentException("State name is empty. "); } if (mStateAction.ContainsKey(aName)) { throw new ArgumentException("State '" + aName + "' already exists. "); } aScript.ScriptException += MCSScript_ScriptException; aScript.SwitchToState += MCSScript_SwitchToState; mStateAction.Add(aName, aScript); mStates.Add(aName); if (mStates.Count == 1) { mCurrentState = aName; raiseValuesChanged(); } mItemHandles = null; }
protected virtual void Dispose(bool aDisposing) { if (!mDisposed) { if (aDisposing) { if (mCSScript != null) { mCSScript.ScriptException -= MCSScript_ScriptException; mCSScript.Dispose(); mCSScript = null; } } mDisposed = true; } }