private async void PropTree_BeforeExpand(object sender, TreeViewCancelEventArgs e) { if (e.Node.Tag == null || e.Node.Nodes[0].Text != "") { return; } PropDesc propDesc = (PropDesc)e.Node.Tag; if (propDesc.Value.Tag == DValueTag.HeapPtr) { await PopulateTreeNode(e.Node, (HeapPtr)propDesc.Value); } }
private void PropTree_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Tag != null) { PropDesc desc = (PropDesc)e.Node.Tag; WritableCheckBox.Enabled = !desc.Flags.HasFlag(PropFlags.Accessor); EnumerableCheckBox.Enabled = true; ConfigurableCheckBox.Enabled = true; AccessorCheckBox.Enabled = true; WritableCheckBox.Checked = desc.Flags.HasFlag(PropFlags.Writable); EnumerableCheckBox.Checked = desc.Flags.HasFlag(PropFlags.Enumerable); ConfigurableCheckBox.Checked = desc.Flags.HasFlag(PropFlags.Configurable); AccessorCheckBox.Checked = desc.Flags.HasFlag(PropFlags.Accessor); } else { WritableCheckBox.Enabled = WritableCheckBox.Checked = false; EnumerableCheckBox.Enabled = EnumerableCheckBox.Checked = false; ConfigurableCheckBox.Enabled = ConfigurableCheckBox.Checked = false; AccessorCheckBox.Enabled = AccessorCheckBox.Enabled = false; } }
static void AddPropertyDesc <T>(string name, Func <SharpTreeNode, T> getter, Action <SharpTreeNode, T> setter = null) { var desc = new PropDesc <T>(name, getter, setter); descMap.Add(name, desc); }
private static List<PropDesc> GetPropertiesFromString(string st, ref List<gfErrors> errors, int nline, string path, string projectname, string oTag) { List<PropDesc> result = new List<PropDesc>(); string[] words = st.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); //List<string> words=SplitPropertiesAndValues(st); PropDesc current = new PropDesc(null, null); byte skip = 0; foreach (string s in words) { // if (skip > 0) { skip--; continue; } if (s == "catchingact:") { skip = 2; } if (s == "caughtact:") { skip = 2; } if (s[s.Length - 1] == ':') //if tag name { if (s.Length < 2) errors.Add(new gfErrors() { Description = "Whitespace before colon", Line = nline, File = path, Project = projectname }); else { if (current.value == null && current.name != null) { result.Add(current); errors.Add(new gfErrors() { Description = "Property name found but where value?", Line = nline, File = path, Project = projectname }); } current = new PropDesc(s, null); if (s == words[words.Length - 1])//if last tag hasn't value { errors.Add(new gfErrors() { Description = "Property name found but where value?", Line = nline, File = path, Project = projectname }); result.Add(current); } } } else //if value { if (current.name == null) errors.Add(new gfErrors() { Description = "Value found but where Property name?", Line = nline, File = path, Project = projectname }); if (skip > 0) { current.value += ' ' + s; skip--; } else current.value = s; if (skip == 0) { result.Add(current); #region Check pic // if (current.name == "pic:") { // try { // int cv = Convert.ToInt32(current.value); // if (cv < firstPic || cv > lastPic) // errors.Add(new gfErrors() { Description = "Wrong value for property 'pic'", Line = nline, File = path, Project = projectname }); } // catch { } } #endregion #region Check property value if (current.name != null) if (!current.name.Contains("sound") && !current.name.Contains("file")) { if (!isStringConsistsDigits(current.value)) errors.Add(new gfErrors() { Description = "Number value expected", Line = nline, File = path, Project = projectname }); } #endregion current = new PropDesc(null, null); } } } if (errors.Count > 0) { } return result; }
public static void ChangeValuesInTagOrAdd(ref List<PropDesc> lpd, string propname, string newvalue, bool isAddIfNew = true) { for (int i = 0; i < lpd.Count; i++) { if (lpd[i].name == propname) { lpd[i] = new PropDesc(lpd[i].name, newvalue); return; } } if (isAddIfNew) lpd.Add(new PropDesc(propname, newvalue)); }