public override HotkeyAction CreateAction(IWheelElements elements) { var action = new HotkeyAction(); bool accepted = EditAction(action, elements); return(accepted ? action : null); }
public CreationT AddWheel(IWheelElements elements) { CreationT wheel = new CreationT(); bool accepted = EditWheel(wheel, elements); return(accepted ? wheel : null); }
public bool EditWheel(IWheel wheel, IWheelElements elements) { WheelEditorForm form = new WheelEditorForm(wheel, elements); if (form.ShowDialog() == DialogResult.OK) { wheel.Label = form.Label; wheel.AccentColor = form.AccentColor; wheel.BgColor = form.BgColor; if (form.IsStartup) { elements.StartupWheel = wheel; } if (wheel.Buttons != null) { foreach (IWheelButton button in form.Buttons) { if (!wheel.Buttons.Remove(button)) { elements.Buttons.Add(button); } } foreach (IWheelButton button in wheel.Buttons) { elements.Buttons.Remove(button); } } wheel.Buttons = form.Buttons; return(true); } return(false); }
public CreationT AddButton(IWheelElements elements) { CreationT newButton = new CreationT(); bool accepted = EditButton(newButton, elements); return(accepted ? newButton : null); }
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; }
public override OpenProgramAction CreateAction(IWheelElements elements) { var action = new OpenProgramAction(); bool accepted = EditAction(action, elements); return(accepted ? action : null); }
public IWheel Clone(IWheelElements elements) { var clone = (Wheel)MemberwiseClone(); clone.Buttons = Buttons.Select(button => button.Clone(elements)).ToList(); return(clone); }
public IWheelButton Clone(IWheelElements elements) { var clone = (WheelButton)MemberwiseClone(); clone.Action = Action?.Clone(elements); elements.Buttons.Add(clone); return(clone); }
public IWheelAction Clone(IWheelElements elements) { var result = new ShowSubwheelAction { SubWheel = SubWheel?.Clone(elements) }; return(result); }
public override bool EditAction(OpenWebsiteAction action, IWheelElements elements) { var form = new OpenWebsiteActionEditorForm(action); if (form.ShowDialog() == DialogResult.OK) { action.Url = form.Url; return(true); } return(false); }
public override bool EditAction(OpenSteamAppAction action, IWheelElements elements) { var form = new OpenSteamAppActionEditorForm(action); if (form.ShowDialog() == DialogResult.OK) { action.AppId = form.AppId; return(true); } return(false); }
public override bool EditAction(HotkeyAction action, IWheelElements elements) { var form = new HotkeyActionEditorForm(action); if (form.ShowDialog() == DialogResult.OK) { action.SetHotkey(form.Keys); return(true); } return(false); }
public ShowSubwheelActionEditorForm(ShowSubwheelAction action, IWheelElements elements) { InitializeComponent(); this.action = action; this.elements = elements; SubWheel = action.SubWheel; subWheelEditButton.Enabled = false; UpdateComboBox(); }
public override bool EditAction(OpenProgramAction action, IWheelElements elements) { OpenProgramActionEditorForm form = new OpenProgramActionEditorForm(action); if (form.ShowDialog() == DialogResult.OK) { action.ProgramPath = form.ProgramPath; action.Arguments = form.Arguments; return(true); } return(false); }
public void UpdateElements() { IWheelElements copy = (IWheelElements)Elements.Clone(); IWheelElements newElements = Elements.Editor.Edit(copy); if (newElements != null) { View.UpdateElements(new SimplifiedWheelElements(newElements)); elements = newElements; Model.SaveElements(elements); } }
public SimplifiedWheelButton(IWheelButton button, IWheelElements elements) { Label = button.Label; ImgPath = button.ImgPath; if (button.Action != null) { Action = new SimplifiedWheelAction(button.Action, elements); } else { Action = null; } }
public bool EditButton(IWheelButton button, IWheelElements elements) { ButtonEditorForm form = new ButtonEditorForm(button, elements); if (form.ShowDialog() == DialogResult.OK) { button.Label = form.Label; button.ImgPath = form.ImgPath; button.Action = form.Action; return(true); } return(false); }
public bool RemoveButton(IWheelButton button, IWheelElements elements) { var dialog = new ComfirmationDialog($"Are you sure you wish to delete button '{button.Label}'?", "Comfirmation"); if (dialog.ShowDialog() != DialogResult.OK) { return(false); } elements.Buttons.Remove(button); foreach (IWheel wheel in elements.Wheels) { wheel.Buttons.Remove(button); } return(true); }
public IWheelElements Edit(IWheelElements wheelElementsCopy) { ElementsEditorForm editor = new ElementsEditorForm(wheelElementsCopy); if (editor.ShowDialog() == DialogResult.OK) { var buttons = new List <IWheelButton>(); foreach (IWheel wheel in wheelElementsCopy.Wheels) { buttons.AddRange(wheel.Buttons); } wheelElementsCopy.Buttons = buttons; return(wheelElementsCopy); } return(null); }
public IWheelElements GetElements() { try { string json; lock (this) { json = File.ReadAllText(ElementsPath); } IWheelElements elements = JsonConvert.DeserializeObject <IWheelElements>(json, jsonSettings); return(elements); } catch (Exception) { return(null); } }
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; } }
public bool SaveElements(IWheelElements elements) { try { var jsonSettings = new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.All, TypeNameHandling = TypeNameHandling.Objects }; string json = JsonConvert.SerializeObject(elements, elements.GetType(), Formatting.Indented, jsonSettings); lock (this) { File.WriteAllText(ElementsPath, json); } return(true); } catch (Exception) { return(false); } }
public override bool EditAction(ShowSubwheelAction action, IWheelElements elements) { IWheel subwheel; if (action.SubWheel == null) { subwheel = elements.Editor.WheelEditor.AddWheel(elements); if (subwheel != null) { action.SubWheel = subwheel; return(true); } else { return(false); } } else { return(elements.Editor.WheelEditor.EditWheel(action.SubWheel, elements)); } }
public WheelEditorForm(IWheel wheel, IWheelElements elements) { InitializeComponent(); this.wheel = wheel; this.elements = elements; bgColorPanel.BackColor = wheel.BgColor; bgColorAlphaNumericUpDown.Value = wheel.BgColor.A / 255M * 100; accentColorPanel.BackColor = wheel.AccentColor; nameTextBox.Text = wheel.Label; startupWheelCheckbox.Checked = wheel == elements.StartupWheel; if (wheel.Buttons != null) { Buttons = new List <IWheelButton>(wheel.Buttons); } else { Buttons = new List <IWheelButton>(); } UpdateButtonList(); }
public SimplifiedWheel(IWheel wheel, IWheelElements elements) { Dictionary <IWheelButton, int> allButtons = new Dictionary <IWheelButton, int>(); for (int i = 0; i < elements.Buttons.Count; i++) { allButtons[elements.Buttons[i]] = i; } ButtonIndices = new int[wheel.Buttons.Count]; for (int i = 0; i < ButtonIndices.Length; i++) { ButtonIndices[i] = allButtons[wheel.Buttons[i]]; } AccentColor = ToArray(wheel.AccentColor); BgColor = ToArray(wheel.BgColor); Label = wheel.Label; int[] ToArray(Color color) { return(new int[] { color.R, color.G, color.B, color.A }); } }
public bool RemoveWheel(IWheel wheel, IWheelElements elements) { Form dialog = new ComfirmationDialog($"Are you sure you wish to delete wheel '{wheel.Label}'?", "Comfirm deletion"); if (dialog.ShowDialog() == DialogResult.OK) { int index = elements.Wheels.IndexOf(wheel); elements.Wheels.Remove(wheel); if (wheel == elements.StartupWheel) { if (elements.Wheels.Count == 0) { elements.StartupWheel = null; } else { index = Math.Min(index, elements.Wheels.Count - 1); elements.StartupWheel = elements.Wheels[index];; } } return(true); } return(false); }
public IWheelAction Clone(IWheelElements elements) { return((IWheelAction)MemberwiseClone()); }
public ElementsEditorForm(IWheelElements elements) { InitializeComponent(); this.elements = elements; UpdateWheelsList(); }
IWheelButton IButtonEditor.AddButton(IWheelElements elements) => AddButton(elements);
public SimplifiedWheelElements(IWheelElements elements) { Wheels = elements.Wheels.Select(wheel => new SimplifiedWheel(wheel, elements)).ToArray(); Buttons = elements.Buttons.Select(button => new SimplifiedWheelButton(button, elements)).ToArray(); StartupWheel = elements.Wheels.IndexOf(elements.StartupWheel); }