/// <summary> /// Handles the create button event for a macro. /// </summary> public void CreateMacroEvent() { if (tagService.AllTags.Tags == null || !tagService.AllTags.Tags.Any()) { Messages.ShowWarningMessage($"To create a macro you first need to have at least one tag", "No tags found"); } else { MacroForm macroForm = new MacroForm(); macroForm.macroLabel.Text = createMacroText; macroForm.tagComboBox.DataSource = tagService.AllTags.Tags; macroForm.tagComboBox.DisplayMember = "Name"; macroForm.tagComboBox.ValueMember = "Name"; macroForm.AcceptEventHandler += AcceptCreateMacroEvent; macroForm.Show(); } }
/// <summary> /// Handles the click event on the edit button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditMacroEvent(object sender, EventArgs e) { if (tagService.AllTags.Tags == null || !tagService.AllTags.Tags.Any()) { Messages.ShowWarningMessage($"To create a macro you first need to have at least one tag", "No tags found"); } else if (sender is Button button) { Macro macro = GetMacro(button.Name); MacroForm macroForm = new MacroForm(); macroForm.SetOriginalMacro(macro); macroForm.macroLabel.Text = editMacroText; macroForm.nameTextBox.Text = macro.Name; macroForm.textTextBox.Text = macro.Text; macroForm.tagComboBox.DataSource = tagService.AllTags.Tags; macroForm.tagComboBox.DisplayMember = "Name"; macroForm.tagComboBox.ValueMember = "Name"; macroForm.tagComboBox.SelectedItem = tagService.GetTagByMacro(macro.Name); macroForm.AcceptEventHandler += AcceptEditMacroEvent; macroForm.Show(); } }