/* public list_varCommand(string szContent, ref GenContext Context, string[] Output) * : base(Context){} */ public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); int iPos = -1; string szPar = GenContext.GetFirstParam(szContent, ref iPos, ','); if (szPar != "") { throw new Exception("Language::Commands:list_var() does not take parameters"); } int i; string szStatus = "", szType = "", szLine = ""; for (i = 0; i < Context.m_Variables.Count; i++) { ContextVar cv = (ContextVar)Context.m_Variables[i]; if (cv.m_iType == ContextVar.CTVAR_FLOAT) { szType = "FLOAT"; } else if (cv.m_iType == ContextVar.CTVAR_TEXT) { szType = "TEXT"; } if (cv.m_bProtected) { szStatus = "protected"; } szLine = cv.m_sName + "\t" + szType + "\t" + cv.m_sValue + "\t" + szStatus; Output.Add(szLine); } }
public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); int iPos = -1; string szPar1 = GenContext.GetFirstParam(szContent, ref iPos, ','); string szPar2 = GenContext.GetNextParam(szContent, ref iPos, ','); if (GenContext.GetNextParam(szContent, ref iPos, ',') != "") { throw new Exception("Language.Commands::SetCommand:Invalid argument list."); } if (Context.isExistVariable(szPar1)) { throw new Exception("Language.Commands::SetCommand:The variable " + szPar1 + " already exists"); } int iVarType = Context.GetVarType(szPar2); if (iVarType == ContextVar.CTVAR_INVALID) { throw new Exception("Language.Commands::SetCommand:" + szPar2 + " is not a valid variable type"); } // Check the variablename if (!ContextVar.isValidVarName(szPar1)) { throw new Exception("Language.Commands::SetCommand:" + szPar1 + " is not a valid variable name"); } Context.AddVariable(szPar1, "", iVarType, false); }
public override void ExecuteCmd(string szContent, ref GenContext Context, ref ArrayList Output, ref Object Tag) { base.ExecuteCmd(szContent, ref Context, ref Output, ref Tag); int iPos = -1; string szPar1 = GenContext.GetFirstParam(szContent, ref iPos, ','); string szPar2 = GenContext.GetNextParam(szContent, ref iPos, ','); if (GenContext.GetNextParam(szContent, ref iPos, ',') != "") { throw new Exception("Language.Commands::letCommand:Invalid argument list."); } ContextVar cv = Context.GetVariable(szPar1); if (cv == null) { throw new Exception("Language.Commands::letCommand:Variable " + szPar1 + " does not exist"); } if (cv.m_iType == ContextVar.CTVAR_FLOAT) { cv.m_sValue = Context.EvalFloat(szPar2).ToString(); } else if (cv.m_iType == ContextVar.CTVAR_TEXT) { cv.m_sValue = Context.EvalText(szPar2); } }
public ContextVar <T> Get <T>(string key, T defaultValue) { object val; if (!_values.TryGetValue(key, out val)) { val = (_values[key] = new ContextVar <T>(defaultValue)); } return((ContextVar <T>)val); }
/// <summary> /// Recursive update extended contexts /// </summary> /// <param name="p_Name"></param> /// <param name="p_Var"></param> /// <param name="p_ParentNode"></param> public static void ContextVarToTreeNode(string p_Name, ContextVar p_Var, object p_ParentNode, List<String> p_AutoExpand) { if (p_Var.IsArray == true) { int l_MaxLenght = 0; foreach (var l_Pair in p_Var.Nodes) { if (l_Pair.Key.Length > l_MaxLenght) l_MaxLenght = l_Pair.Key.Length; } string l_SpaceBuffer = ""; for (int l_I = 0; l_I < l_MaxLenght; l_I++) l_SpaceBuffer += " "; foreach (var l_Pair in p_Var.Nodes) { if (l_Pair.Value.IsArray == false) { if (p_ParentNode.GetType() == typeof(TreeView)) ((TreeView)p_ParentNode).Nodes.Add(l_Pair.Key + l_SpaceBuffer.Substring(l_Pair.Key.Length) + " => [" + l_Pair.Value.Value + "]"); else ((TreeNode)p_ParentNode).Nodes.Add(l_Pair.Key + l_SpaceBuffer.Substring(l_Pair.Key.Length) + " => [" + l_Pair.Value.Value + "]"); } else { TreeNode l_Node = new TreeNode(l_Pair.Key); ContextVarToTreeNode(l_Pair.Key, l_Pair.Value, l_Node, p_AutoExpand); if (p_AutoExpand.Contains(l_Pair.Key)) l_Node.Expand(); if (p_ParentNode.GetType() == typeof(TreeView)) ((TreeView)p_ParentNode).Nodes.Add(l_Node); else ((TreeNode)p_ParentNode).Nodes.Add(l_Node); } } } else if (p_Name != "root") { ((TreeNode)p_ParentNode).Nodes.Add(p_Name + " [" + p_Var.Value + "]"); } }
void DrawTimeLineEntry(ITimelineEntry entry, DateTime startTime, DateTime currentTime, float scale, int index) { ControlContext.Context context = _controlContext.Get(entry); ContextVar <bool> foldOut = context.Get <bool>("foldOut", false); float left = (float)(entry.Start - startTime).TotalSeconds * scale; float right = (float)(CalculateEndTime(entry, currentTime) - startTime).TotalSeconds * scale; float width = Mathf.Max(right - left, 1); using (new GUILayout.HorizontalScope(index > 0 ? GUIStyle.none : _style.Row, GUILayout.ExpandWidth(true))) { GUILayout.Space(left); using (new GUILayout.VerticalScope()) { using (new GUILayout.HorizontalScope(index == 0 ? _style.GetEntry(entry.State) : _style.GetChildEntry(entry.State), GUILayout.Width(width))) { if (entry.Children.Any()) { foldOut.Value = GUILayout.Toggle(foldOut.Value, GUIContent.none, _style.EntryToggle); } else { GUILayout.Space(16); } if (GUILayout.Button(entry.Name, _style.EntryText, GUILayout.MaxWidth(width - 10))) { _selectedEntry = entry; } } if (foldOut.Value) { foreach (var child in entry.Children) { DrawTimeLineEntry(child, entry.Start, currentTime, scale, ++index); } } } } }