public override bool OnDoubleClick() { base.OnDoubleClick(); DialogResult result = DialogResult.None; if (SupportedTypes.Length == 1 && SupportedTypes[0].IsEnum) { var form = new SelectionForm(); form.Text = Name ?? "Select item from list"; form.Items = SupportedTypes[0].GetEnumNames(); int index = Array.IndexOf(SupportedTypes[0].GetEnumNames(), ValueState.Text); if (index == -1) { index = 0; } form.SelectedIndex = index; result = form.ShowDialog(); if (result == DialogResult.OK) { ValueState = new ValueItemState(form.Items[form.SelectedIndex], SupportedTypes[0]); } } else { var form = new ValueBoxForm(); form.Text = Name ?? "Value editor"; form.SetSupportedTypes(SupportedTypes); form.InputText = ValueState.Text; form.InputType = ValueState.Type; form.EnableTypeComboBox = EnableTypeField; result = form.ShowDialog(); if (result == DialogResult.OK && ValueItemState.TryParse(form.InputText, form.InputType) != null) { ValueState = new ValueItemState(form.InputText, form.InputType); } } return(true); }
public override bool OnDoubleClick() { base.OnDoubleClick(); DialogResult result = DialogResult.None; if (SupportedTypes.Length == 1 && SupportedTypes[0].IsEnum) { var form = new SelectionForm(); form.Text = Name ?? "Select item from list"; form.Items = SupportedTypes[0].GetEnumNames(); int index = Array.IndexOf(SupportedTypes[0].GetEnumNames(), ValueState.Text); if (index == -1) index = 0; form.SelectedIndex = index; result = form.ShowDialog(); if (result == DialogResult.OK) { ValueState = new ValueItemState(form.Items[form.SelectedIndex], SupportedTypes[0]); } } else { var form = new ValueBoxForm(); form.Text = Name ?? "Value editor"; form.SetSupportedTypes(SupportedTypes); form.InputText = ValueState.Text; form.InputType = ValueState.Type; form.EnableTypeComboBox = EnableTypeField; result = form.ShowDialog(); if (result == DialogResult.OK && ValueItemState.TryParse(form.InputText, form.InputType) != null) { ValueState = new ValueItemState(form.InputText, form.InputType); } } return true; }