private void buttonAdd_Click(object sender, EventArgs e) { Song aSong = new Song(); FormSong Songs = new FormSong(aSong); if (Songs.ShowDialog() == DialogResult.OK) SongList.Add(aSong); }
private void buttonAdd_Click(object sender, EventArgs e) { Song aSong = new Song(); FormSong Songs = new FormSong(aSong); if (Songs.ShowDialog() == DialogResult.OK) _MediaCollection.MediaList.Add(aSong); buttonEdit.Enabled = true; buttonDelete.Enabled = true; }
public Form1() { InitializeComponent(); theSong = new Song(); theSong.SongName = "Star Spangled Banner"; theSong.ArtistName = "Franscis Scott Key"; theSong.AlbumName = "Unknown"; theSong.YearReleased = 1814; theSong.DurationInSeconds = 133; theSong.TrackNumber = 1; theSong.TrackCount = 1; theSong.Genre = "Contemporary"; theSong.MyRating = 5; textBox_SongName.Text = theSong.SongName; textBox_ArtistName.Text = theSong.ArtistName; textBox_AlbumName.Text = theSong.AlbumName; textBox_YearReleased.Text = Convert.ToString(theSong.YearReleased); textBox_DurationInSeconds.Text = Convert.ToString(theSong.DurationInSeconds); textBox_TrackNumber.Text = Convert.ToString(theSong.TrackNumber); textBox_TrackCount.Text = Convert.ToString(theSong.TrackCount); textBox_Genre.Text = theSong.Genre; Text = theSong.GetTitle(); switch (theSong.MyRating) { case 1: radioButton_Rating1.Checked = true; break; case 2: radioButton_Rating2.Checked = true; break; case 3: radioButton_Rating3.Checked = true; break; case 4: radioButton_Rating4.Checked = true; break; case 5: radioButton_Rating5.Checked = true; break; } }
private void buttonEdit_Click(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { Song aSong = listBox1.SelectedItem as Song; FormSong Songs = new FormSong(aSong); Song song1 = new Song(); song1.SongName = aSong.SongName; song1.ArtistName = aSong.ArtistName; song1.AlbumName = aSong.AlbumName; song1.YearReleased = aSong.YearReleased; song1.DurationInSeconds = aSong.DurationInSeconds; song1.TrackNumber = aSong.TrackNumber; song1.TrackCount = aSong.TrackCount; song1.Genre = aSong.Genre; song1.MyRating = aSong.MyRating; if (Songs.ShowDialog() == DialogResult.OK) { //ListBox Refresh _MediaCollection.MediaList.Add(aSong); _MediaCollection.MediaList.Remove(aSong); } else { aSong.SongName = song1.SongName; aSong.ArtistName = song1.ArtistName; aSong.AlbumName = song1.AlbumName; aSong.YearReleased = song1.YearReleased; aSong.DurationInSeconds = song1.DurationInSeconds; aSong.TrackNumber = song1.TrackNumber; aSong.TrackCount = song1.TrackCount; aSong.Genre = song1.Genre; aSong.MyRating = song1.MyRating; aSong = this.listBox1.SelectedItem as Song; _MediaCollection.MediaList.Add(aSong); _MediaCollection.MediaList.Remove(aSong); } } else MessageBox.Show("There are no seongs to edit...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
public MainForm() { InitializeComponent(); SongList = new BindingList<Song>(); Song song1 = new Song(); song1.SongName = "Star Spangled Banner"; song1.ArtistName = "Franscis Scott Key"; song1.AlbumName = "Unknown"; song1.YearReleased = 1814; song1.DurationInSeconds = 133; song1.TrackNumber = 1; song1.TrackCount = 15; song1.Genre = "Contemporary"; song1.MyRating = 5; SongList.Add(song1); listBox1.DataSource = SongList; }
public void Load(string filePath) { MediaList.Clear(); using (StreamReader Stream1 = new StreamReader(filePath)) { try { while (Stream1.EndOfStream != true) { string line = Stream1.ReadLine(); if (String.IsNullOrEmpty(line) == false) { Song S = new Song(line); MediaList.Add(S); } } } catch (Exception ex) { throw new Exception("Error Opening File", ex); } } }
public FormSong(Song aSong) { InitializeComponent(); theSong = aSong; textBox_SongName.Text = theSong.SongName; textBox_ArtistName.Text = theSong.ArtistName; textBox_AlbumName.Text = theSong.AlbumName; textBox_YearReleased.Text = Convert.ToString(theSong.YearReleased); textBox_DurationInSeconds.Text = Convert.ToString(theSong.DurationInSeconds); textBox_TrackNumber.Text = Convert.ToString(theSong.TrackNumber); textBox_TrackCount.Text = Convert.ToString(theSong.TrackCount); textBox_Genre.Text = theSong.Genre; Text = theSong.GetTitle(); switch (theSong.MyRating) { case 1: radioButton_Rating1.Checked = true; break; case 2: radioButton_Rating2.Checked = true; break; case 3: radioButton_Rating3.Checked = true; break; case 4: radioButton_Rating4.Checked = true; break; case 5: radioButton_Rating5.Checked = true; break; } }