private void DeleteSong(object sender, EventArgs e) { if (WarningMessageBox.Show(this, "Are you sure you want to delete", "these songs?") == DialogResult.Yes) { for (int i = this.listViewSongs.SelectedItems.Count - 1; i >= 0; i--) { if (this.listViewSongs.SelectedItems[i].ImageIndex == 1) { this.currentSong.Stop(); this.playing = false; this.playingCustom = false; this.buttonPlay.Text = "Play"; } if (this.listViewSongs.SelectedItems[i].Group == this.listViewSongs.Groups["customMusic"]) { File.Delete(Path.Combine(this.dataDirectory, this.listViewSongs.SelectedItems[i].SubItems[1].Text)); this.listViewSongs.Items.RemoveAt(this.listViewSongs.SelectedItems[i].Index); } else { File.Delete(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Custom Music", this.listViewSongs.SelectedItems[i].SubItems[1].Text)); if (File.Exists(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Custom Music", "Modified", this.listViewSongs.SelectedItems[0].SubItems[1].Text))) { File.Delete(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "Custom Music", "Modified", this.listViewSongs.SelectedItems[i].SubItems[1].Text)); } this.listViewSongs.Items.RemoveAt(this.listViewSongs.SelectedItems[i].Index); } } } }
public static DialogResult Show(Form parent, string text1, string text2) { using (var form = new WarningMessageBox(text1, text2)) { return(form.ShowDialog(parent)); } }