private Control CreateControlFor(SpriteDataField v) { // Console.WriteLine(v.display + " " + v.name); if (v.display == "checkbox") { CheckBox c = new CheckBox(); c.Checked = v.getValue(s.Data) == 1; c.Text = v.name; c.CheckedChanged += new EventHandler(saveData); return(c); } else if (v.display == "list") { ComboBox c = new ComboBox(); c.DropDownStyle = ComboBoxStyle.DropDownList; c.Items.AddRange(v.strings); try { c.SelectedIndex = Array.IndexOf(v.values, v.getValue(s.Data)); } catch (ArgumentOutOfRangeException) { } //just in case //c.SelectedIndexChanged += new EventHandler(saveData); c.SelectionChangeCommitted += new EventHandler(saveData); //c.DropDownClosed += new EventHandler(saveData); return(c); } else if (v.display == "label") { Label c = new Label(); c.Text = v.name; return(c); } else if (v.display == "binary") { BinaryEdit c = new BinaryEdit(); c.CheckBoxCount = v.getBitCount(); c.value = v.getValue(s.Data); c.ValueChanged += new EventHandler(saveData); return(c); } else { NumericUpDown c = new NumericUpDown(); c.Minimum = v.getMin(); c.Maximum = v.getMax(); c.Value = v.getValue(s.Data); c.ValueChanged += new EventHandler(saveData); return(c); } }
public void updateValue(SpriteDataField v) { Control c = controls[v]; int value = v.getValue(s.Data); if (c is CheckBox) { (c as CheckBox).Checked = value == 1; } if (c is ComboBox) { (c as ComboBox).SelectedIndex = Array.IndexOf(v.values, value); } if (c is BinaryEdit) { (c as BinaryEdit).value = value; } if (c is NumericUpDown) { (c as NumericUpDown).Value = value; } }
public void updateValue(SpriteDataField v) { Control c = controls[v]; int value = v.getValue(s.Data); if (c is CheckBox) (c as CheckBox).Checked = value == 1; if (c is ComboBox) (c as ComboBox).SelectedIndex = Array.IndexOf(v.values, value); if (c is BinaryEdit) (c as BinaryEdit).value = value; if (c is NumericUpDown) (c as NumericUpDown).Value = value; }
private Control CreateControlFor(SpriteDataField v) { // Console.WriteLine(v.display + " " + v.name); if (v.display == "checkbox") { CheckBox c = new CheckBox(); c.Checked = v.getValue(s.Data) == 1; c.Text = v.name; c.CheckedChanged += new EventHandler(saveData); return c; } else if (v.display == "list") { ComboBox c = new ComboBox(); c.DropDownStyle = ComboBoxStyle.DropDownList; c.Items.AddRange(v.strings); try { c.SelectedIndex = Array.IndexOf(v.values, v.getValue(s.Data)); } catch (ArgumentOutOfRangeException) { } //just in case //c.SelectedIndexChanged += new EventHandler(saveData); c.SelectionChangeCommitted += new EventHandler(saveData); //c.DropDownClosed += new EventHandler(saveData); return c; } else if (v.display == "label") { Label c = new Label(); c.Text = v.name; return c; } else if (v.display == "binary") { BinaryEdit c = new BinaryEdit(); c.CheckBoxCount = v.getBitCount(); c.value = v.getValue(s.Data); c.ValueChanged += new EventHandler(saveData); return c; } else { NumericUpDown c = new NumericUpDown(); c.Minimum = v.getMin(); c.Maximum = v.getMax(); c.Value = v.getValue(s.Data); c.ValueChanged += new EventHandler(saveData); return c; } }