private void deleteGroupToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripDropDownItem menuItem = sender as ToolStripDropDownItem; if (menuItem == null) { return; } TabPage tab = menuItem.Tag as TabPage; if (tab == null) { return; } RadioChannelGroup group = tab.Tag as RadioChannelGroup; if (group == null) { return; } DialogResult result = MessageBox.Show(string.Format("Are you sure you want to delete the group '{0}'?", group.GroupName), "", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } bool groupIsEmpty = (group.ReferringRadioGroupMap().Count <= 0); group.Delete(); tabControl1.TabPages.Remove(tab); if (!groupIsEmpty && tabControl1.SelectedIndex == 0) { this.RefreshContextMenu(); this.RefreshAllChannels(); } else { this.RefreshContextMenu(); } }
private void mpButtonDelGroup_Click(object sender, EventArgs e) { GroupSelectionForm dlgGrpSel = new GroupSelectionForm(); if (dlgGrpSel.ShowDialog(typeof(RadioChannelGroup), this) != DialogResult.OK) { return; } RadioChannelGroup group = dlgGrpSel.Group as RadioChannelGroup; if (group == null) { return; } DialogResult result = MessageBox.Show(string.Format("Are you sure you want to delete the group '{0}'?", group.GroupName), "", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } bool isGroupEmpty = (group.ReferringRadioGroupMap().Count <= 0); group.Delete(); if (!isGroupEmpty) { this.RefreshAll(); } else { this.RefreshContextMenu(); this.RefreshTabs(); } }