private void buttonAddGroup_Click(object sender, EventArgs e)
        {
            var inputForm = new InputStringForm();

            inputForm.Text    = "Create New Custom Group";
            inputForm.Message = "Name of the custom group";

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            var newGroup = new CustomGroup(inputForm.Value);

            CustomGroups.Add(newGroup);

            listGroups.Items.Add(newGroup);
            listGroups.SelectedIndex = listGroups.Items.Count - 1;

            Redraw();
        }
        private void listPatterns_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = listPatterns.IndexFromPoint(e.Location);

            if (index < 0 || index >= listPatterns.Items.Count)
            {
                return;
            }

            int selectedIndex = listGroups.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= listGroups.Items.Count)
            {
                return;
            }

            CustomGroup group = CustomGroups[selectedIndex];

            var inputForm = new InputStringForm();

            inputForm.Text    = "Modify Regex Pattern";
            inputForm.Message = "Regex Pattern";
            inputForm.Value   = group.Patterns[index];

            DialogResult result = inputForm.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }

            group.Patterns[index]      = inputForm.Value;
            listPatterns.SelectedIndex = index;

            Redraw();
        }
        private void buttonRemovePattern_Click(object sender, EventArgs e)
        {
            if (listPatterns.SelectedIndices.Count == 0)
            {
                return;
            }

            int selectedIndex = listGroups.SelectedIndex;

            if (selectedIndex < 0 || selectedIndex >= listGroups.Items.Count)
            {
                return;
            }

            CustomGroup group = CustomGroups[selectedIndex];

            foreach (int index in listPatterns.SelectedIndices.OfType <int>().OrderByDescending(x => x))
            {
                group.Patterns.RemoveAt(index);
                listPatterns.Items.RemoveAt(index);
            }

            Redraw();
        }