/// <summary> /// Executes the all the actions in the pCode specified /// </summary> /// <param name="pCode">pCode containing the list of actions to perform</param> /// <returns>true on success, false otherwise</returns> public bool Execute(PCode pCode) { if (!pCode.HasCode()) { return(true); } // step through the list of action verbs foreach (ActionVerb actionVerb in pCode.ActionVerbList) { Execute(actionVerb); } return(true); }
/// <summary> /// Parses an input script into intermediate code (PCode) /// The script is essentially a semi-colon delimited set of /// functions with arguments. /// /// Each function can have 0 or more arguments, each argument /// should be delimited by a comma. There are no argument /// types. All arguments are treated as strings. /// /// An example of a script is: /// "highlightSelected(@SelectedWidget, false); select(@SelectedBox); transition(RowRotation)" /// This script has three function calls: /// "highlightSelected" with arguments "@SelectedWidget" and "false" /// "select" with argument "@SelectedBox" /// "transition" with argument "RowRotation" /// </summary> /// <param name="inputString">Input script</param> /// <param name="pCode">Returns interpreted form</param> /// <returns>true if parsed successfully, false otherwise</returns> public bool Parse(String inputString, ref PCode pCode) { bool retVal = true; if (String.IsNullOrEmpty(inputString)) { return(retVal); } pCode.Script = inputString.Trim(); if (String.IsNullOrEmpty(pCode.Script)) { return(retVal); } // semi-colon is the function separator var tokens = pCode.Script.Split(';'); // now parse each function foreach (var token in tokens) { var trimmedToken = token.Trim(); if (trimmedToken.Length > 0) { var actionVerb = new ActionVerb(); // function may have comma delimited arguments. // extract them bool ret = parseActionVerb(trimmedToken, ref actionVerb); if (ret) { pCode.ActionVerbList.Add(actionVerb); } else { break; } } } if (!retVal) { pCode.ActionVerbList.Clear(); } return(retVal); }
/// <summary> /// Loads scripts from the config file (node ACAT/Scripts/Script) /// </summary> /// <param name="configFile">Name of the config file</param> /// <returns>true onf success</returns> public bool Load(String configFile) { bool retVal = true; XmlDocument doc = new XmlDocument(); if (File.Exists(configFile)) { doc.Load(configFile); XmlNodeList scriptNodes = doc.SelectNodes("/ACAT/Scripts/Script"); // enumerate all the script nodes, extract attributes foreach (XmlNode node in scriptNodes) { var name = XmlUtils.GetXMLAttrString(node, "name"); if (!String.IsNullOrEmpty(name)) { if (!ContainsKey(name)) { var code = XmlUtils.GetXMLAttrString(node, "code"); // now, let's parse the script and add the pcode to the // hashtable var pCode = new PCode(); bool ret = _parser.Parse(code, ref pCode); if (ret) { Add(name, pCode); } } } } } else { retVal = false; } return(retVal); }
/// <summary> /// Parses an input script into intermediate code (PCode) /// The script is essentially a semi-colon delimited set of /// functions with arguments. /// /// Each function can have 0 or more arguments, each argument /// should be delimited by a comma. There are no argument /// types. All arguments are treated as strings. /// /// An example of a script is: /// "highlightSelected(@SelectedWidget, false); select(@SelectedBox); transition(RowRotation)" /// This script has three function calls: /// "highlightSelected" with arguments "@SelectedWidget" and "false" /// "select" with argument "@SelectedBox" /// "transition" with argument "RowRotation" /// </summary> /// <param name="inputString">Input script</param> /// <param name="pCode">Returns interpreted form</param> /// <returns>true if parsed successfully, false otherwise</returns> public bool Parse(String inputString, ref PCode pCode) { bool retVal = true; if (String.IsNullOrEmpty(inputString)) { return retVal; } pCode.Script = inputString.Trim(); if (String.IsNullOrEmpty(pCode.Script)) { return retVal; } // semi-colon is the function separator var tokens = pCode.Script.Split(';'); // now parse each function foreach (var token in tokens) { var trimmedToken = token.Trim(); if (trimmedToken.Length > 0) { var actionVerb = new ActionVerb(); // function may have comma delimited arguments. // extract them retVal = parseActionVerb(trimmedToken, ref actionVerb); if (retVal) { pCode.ActionVerbList.Add(actionVerb); } else { break; } } } if (!retVal) { pCode.ActionVerbList.Clear(); } return retVal; }
/// <summary> /// Initialzies an instance of the class /// </summary> public Animation() { _parser = new Parser(); Screen = String.Empty; Iterations = "1"; OnEnterExecutionNotDone = false; AnimationWidgetList = new List<AnimationWidget>(); OnBack = new PCode(); OnEnd = new PCode(); OnSelect = new PCode(); OnEnter = new PCode(); SteppingTime = CoreGlobals.AppPreferences.SteppingTime; HesitateTime = CoreGlobals.AppPreferences.HesitateTime; CoreGlobals.AppPreferences.EvtPreferencesChanged += AppPreferences_EvtPreferencesChanged; }
/// <summary> /// Loads scripts from the config file (node ACAT/Scripts/Script) /// </summary> /// <param name="configFile">Name of the config file</param> /// <returns>true onf success</returns> public bool Load(String configFile) { bool retVal = true; XmlDocument doc = new XmlDocument(); if (File.Exists(configFile)) { doc.Load(configFile); XmlNodeList scriptNodes = doc.SelectNodes("/ACAT/Scripts/Script"); // enumerate all the script nodes, extract attributes foreach (XmlNode node in scriptNodes) { var name = XmlUtils.GetXMLAttrString(node, "name"); if (!String.IsNullOrEmpty(name)) { if (!ContainsKey(name)) { var code = XmlUtils.GetXMLAttrString(node, "code"); // now, let's parse the script and add the pcode to the // hashtable var pCode = new PCode(); bool ret = _parser.Parse(code, ref pCode); if (ret) { Add(name, pCode); } } } } } else { retVal = false; } return retVal; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public WidgetAttribute() { FontName = CoreGlobals.AppPreferences.FontName; FontSize = CoreGlobals.AppPreferences.FontSize; FontBold = true; Name = String.Empty; Label = String.Empty; Value = String.Empty; Modifiers = null; MouseClickActuate = true; OnMouseClick = new PCode(); }
/// <summary> /// Initializes the animation widget object /// </summary> public AnimationWidget() { _parser = new Parser(); OnSelect = new PCode(); OnBack = new PCode(); OnHighlightOn = new PCode(); OnHighlightOff = new PCode(); OnMouseClick = new PCode(); HesitateTime = CoreGlobals.AppPreferences.HesitateTime; CoreGlobals.AppPreferences.EvtPreferencesChanged += AppPreferences_EvtPreferencesChanged; }
/// <summary> /// Initializes the object /// </summary> /// <param name="animationWidget">animation widget</param> /// <param name="onMouseClick">the code for handling the click</param> public AnimationMouseClickEventArgs(AnimationWidget animationWidget, PCode onMouseClick) { AnimationWidget = animationWidget; OnMouseClick = onMouseClick; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public SwitchElement() { OnTrigger = null; SwitchName = String.Empty; _parser = new Parser(); }
/// <summary> /// Load attribute from the XML node /// </summary> /// <param name="xmlNode">Xml node</param> /// <returns>true on success</returns> public bool Load(XmlNode xmlNode) { SwitchName = XmlUtils.GetXMLAttrString(xmlNode, "name"); var script = XmlUtils.GetXMLAttrString(xmlNode, "onTrigger"); // a switch action of default() means this is used as a selector. if (!String.IsNullOrEmpty(script)) { OnTrigger = new PCode(); if (String.Compare(script, "default()", true) != 0) { Log.Debug("Name: " + SwitchName + " onTrigger: " + script); _parser.Parse(script, ref OnTrigger); } else { Log.Debug("Name: " + SwitchName + " onTrigger: default()"); } } else { Log.Debug("Name: " + SwitchName + " script is empty. setting onTrigger to NULL"); OnTrigger = null; } return true; }
/// <summary> /// Executes the all the actions in the pCode specified /// </summary> /// <param name="pCode">pCode containing the list of actions to perform</param> /// <returns>true on success, false otherwise</returns> public bool Execute(PCode pCode) { if (!pCode.HasCode()) { return true; } // step through the list of action verbs foreach (ActionVerb actionVerb in pCode.ActionVerbList) { Execute(actionVerb); } return true; }