public ButtonEditorForm(IWheelButton button, IWheelElements elements) { InitializeComponent(); this.button = button; this.elements = elements; actionComboBox.Items.Add("None"); foreach (var item in elements.Editor.ActionEditors) { actionComboBox.Items.Add(item.DisplayName); } actionComboBox.SelectedIndex = 0; if (button.Action != null) { var types = elements.Editor.ActionEditors.Select(item => item.Type).ToList(); int index = types.IndexOf(button.Action.GetType()); if (index > -1) { comboboxChangedByUser = false; actionTriggerButton.Enabled = editActionButton.Enabled = true; actionComboBox.SelectedIndex = index + 1; } } Action = button.Action; nameTextBox.Text = button.Label; imageTextBox.Text = button.ImgPath; }
private void actionComboBox_SelectedValueChanged(object sender, EventArgs e) { if (actionComboBox.SelectedIndex == lastIndex) { return; } lastIndex = actionComboBox.SelectedIndex; if (!comboboxChangedByUser) { comboboxChangedByUser = true; } else if (actionComboBox.SelectedIndex == 0) { Action = null; actionTriggerButton.Enabled = editActionButton.Enabled = false; } else { Action = elements.Editor.ActionEditors[actionComboBox.SelectedIndex - 1].CreateAction(elements); actionTriggerButton.Enabled = editActionButton.Enabled = true; if (Action is null) { actionComboBox.SelectedIndex = 0; } } }
public SimplifiedWheelAction(IWheelAction action, IWheelElements elements) { if (action is ShowSubwheelAction showSubwheelAction) { Type = WheelActionType.DisplaySubwheel; if (showSubwheelAction.SubWheel != null) { SubWheel = new SimplifiedWheel(showSubwheelAction.SubWheel, elements); } else { SubWheel = null; } } else { Type = WheelActionType.Other; SubWheel = null; } }