Esempio n. 1
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            // Only send event if name and color are filled and the name is correct.
            bool isMatch = regex.IsMatch(nameTextBox.Text);

            if (
                !string.IsNullOrWhiteSpace(nameTextBox.Text) &&
                isMatch &&
                !string.IsNullOrWhiteSpace(textTextBox.Text) &&
                tagComboBox.SelectedItem != null &&
                tagComboBox.SelectedItem is Tag tag
                )
            {
                EditMacroEvent editTagEvent = new EditMacroEvent
                {
                    Original = OriginalMacro,
                    Created  = new EditMacro
                    {
                        Macro = new Macro
                        {
                            Name = nameTextBox.Text.Trim(),
                            Text = textTextBox.Text.Trim()
                        },
                        Tag = tag
                    }
                };

                AcceptEventHandler.Invoke(editTagEvent, e);
                Close();
            }
            else if (!isMatch)
            {
                Messages.ShowWarningMessage("Currently the macro name can only contain letters and numbers", "Incorrect macro name");
            }
            else
            {
                Messages.InvalidForm();
            }
        }
Esempio n. 2
0
        private void acceptButton_Click(object sender, EventArgs e)
        {
            // Only send event if name and color are filled.
            if (!string.IsNullOrWhiteSpace(nameTextBox.Text) && colorDialog.Color != null)
            {
                EditTagEvent editTagEvent = new EditTagEvent
                {
                    Original = OriginalTag,
                    Created  = new Tag
                    {
                        Name   = nameTextBox.Text.Trim(),
                        Color  = $"#{colorDialog.Color.ToArgb() & 0x00FFFFFF:X6}",
                        Macros = OriginalTag?.Macros
                    }
                };

                AcceptEventHandler.Invoke(editTagEvent, e);
                Close();
            }
            else
            {
                Messages.InvalidForm();
            }
        }