private void editValueNodeMenuItem_Click(object sender, EventArgs e) { if (listViewCustom1.SelectedItems.Count <= 0) { return; } var node = listViewCustom1.SelectedItems[0].Tag as EditableNode; if (node == null) { return; } if (node.Get() is ByamlPathPoint) { new BymlPathPointEditor(node.Get()).ShowDialog(); //ByamlPathPoint is a reference type } else { string value = node.Get().ToString(); var dRes = InputDialog.Show("Enter value", $"Enter new value for the node, the value must be of type {node.type}", ref value); if (dRes != DialogResult.OK) { return; } if (value.Trim() == "") { return; } node.Set(ByamlTypeHelper.ConvertValue(node.type, value)); } ResetValues(); }
private void button1_Click(object sender, EventArgs e) { dynamic value; if (radioButton1.Checked) { if ((Type)comboBox1.SelectedItem == typeof(List <dynamic>)) { value = new List <dynamic>(); } else if ((Type)comboBox1.SelectedItem == typeof(Dictionary <string, dynamic>)) { value = new Dictionary <string, dynamic>(); } else { value = ByamlTypeHelper.ConvertValue((Type)comboBox1.SelectedItem, textBox1.Text); } } else { value = new Dictionary <string, dynamic>(); value.Add("X", float.Parse(textBox2.Text)); value.Add("Y", float.Parse(textBox3.Text)); value.Add("Z", float.Parse(textBox4.Text)); } result = new Tuple <string, dynamic>(textBox5.Enabled ? textBox5.Text : null, value); this.Close(); }
static dynamic ParseNode(XmlNode n) { ByamlNodeType nodeType = (ByamlNodeType)byte.Parse(n.Name.Substring(1)); switch (nodeType) { case ByamlNodeType.Array: return(ParseArrNode(n)); case ByamlNodeType.Dictionary: return(ParseDictNode(n)); default: { Type T = nodeType.GetInstanceType(); return(ByamlTypeHelper.ConvertValue(T, n.Attributes["V"].Value)); } } }