public NodeValueItem(string text, Type type, bool inputEnabled, bool outputEnabled) : base(inputEnabled, outputEnabled) { EnableTypeField = true; TextMaxLength = 20; if (string.IsNullOrEmpty(text)) { ValueState = new ValueItemState(type); } else { ValueState = new ValueItemState(text, type); } background = Brushes.LightCyan; }
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 AcceptNodeValueChangedEventArgs(ValueItemState oldState, ValueItemState newState, bool cancel) : base(cancel) { PreviousState = oldState; CurrentState = newState; }
public AcceptNodeValueChangedEventArgs(ValueItemState oldState, ValueItemState newState) { PreviousState = oldState; CurrentState = newState; }
public static object TryParse(ValueItemState state) { return TryParse(state.Text, state.Type); }
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 NodeValueItem(string text, Type type, bool inputEnabled, bool outputEnabled) : base(inputEnabled, outputEnabled) { EnableTypeField = true; TextMaxLength = 20; if (string.IsNullOrEmpty(text)) ValueState = new ValueItemState(type); else ValueState = new ValueItemState(text, type); background = Brushes.LightCyan; }
public static object TryParse(ValueItemState state) { return(TryParse(state.Text, state.Type)); }