public void ChooseFolder() { FolderBrowserDialog Fbd_selectDirectory = new FolderBrowserDialog(); if (Fbd_selectDirectory.ShowDialog() == DialogResult.OK) { Txt_folderSelected.Text = Fbd_selectDirectory.SelectedPath; directory = Fbd_selectDirectory.SelectedPath; Files = Directory.GetFiles(Txt_folderSelected.Text, "*.mp3"); Rtb_output.AppendText("\n" + Files.Length + " MP3 File(s) found"); if (Files.Length == 0) { DialogResult dr = MessageBox.Show("You selected a folder with no MP3 Files in it, Would you like to pick another folder?", "No Files Found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); switch (dr) { case DialogResult.Yes: ChooseFolder(); break; case DialogResult.No: return; } } else { for (int i = 0; i < Files.Length; i++) { Lbx_files.Items.Add(Files[i].Substring(Txt_folderSelected.TextLength + 1)); } selected = 0; Lbx_files.SetSelected(selected, true); } } }
private void Btn_next_Click(object sender, EventArgs e) { if (selected < Lbx_files.Items.Count - 1) { selected++; Lbx_files.SetSelected(selected, true); } else { return; } }
private void Btn_previous_Click(object sender, EventArgs e) { if (selected != 0) { selected--; Lbx_files.SetSelected(selected, true); } else { return; } }
private void Btn_write_Click(object sender, EventArgs e) { if (Chk_song.Checked && Txt_song.Text == "") { MessageBox.Show("Song field enabled but left blank", "Song Field Blank", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Chk_artist.Checked && Txt_artist.Text == "") { MessageBox.Show("Artist field enabled but left blank", "Artist Field Blank", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Chk_album.Checked && Txt_album.Text == "") { MessageBox.Show("Album field enabled but left blank", "Album Field Blank", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Chk_year.Checked && Txt_year.Text == "") { MessageBox.Show("Year field enabled but left blank", "Year Field Blank", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { TagLib.File MetaFile = TagLib.File.Create(Txt_folderSelected.Text + "\\" + Txt_selectedSong.Text); if (Chk_song.Checked) { MetaFile.Tag.Title = Txt_song.Text; } if (Chk_artist.Checked) { MetaFile.Tag.Performers = new string[1] { Txt_artist.Text } } ; if (Chk_album.Checked) { MetaFile.Tag.Album = Txt_album.Text; } if (Chk_year.Checked) { MetaFile.Tag.Year = Convert.ToUInt16(Txt_year.Text); } MetaFile.Save(); Rtb_output.AppendText("\n" + Txt_selectedSong.Text + " : Tags have been wrote"); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + Txt_folderSelected.Text + "\\" + Txt_selectedSong.Text, "An Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Error); Console.WriteLine(ex); } if (Properties.Settings.Default.ContOnWrite) { if (selected < Lbx_files.Items.Count - 1) { selected++; Lbx_files.SetSelected(selected, true); } else { return; } } }