public void AddToLibrary() { OpenFileDialog windowsDial = new OpenFileDialog(); windowsDial.FileName = "File"; windowsDial.DefaultExt = ".avi"; windowsDial.Filter = "Music file (.mp3)|*.mp3|" + "Video File (.avi, .wmv)|*.avi;*.wmv|" + "Picture File (*.bmp, *.jpg, *.jpeg, *.png)|*.bmp;*.jpg;*.jpeg;*.png"; Nullable <bool> result = windowsDial.ShowDialog(); if (result == true) { PlayListElement tmpElement = new PlayListElement(); tmpElement.Pathname = windowsDial.FileName; string ext = Path.GetExtension(tmpElement.Pathname); if (ext == ".mp3") { this.Library.Music.Add(tmpElement); } else if (ext == ".avi" || ext == ".wmv") { this.Library.Video.Add(tmpElement); } else if (ext == ".bmp" || ext == ".jpg" || ext == ".jpeg" || ext == ".png") { this.Library.Picture.Add(tmpElement); } { this.Library.save("C:\\Users\\" + Environment.UserName + "\\Documents\\LibraryMediaPLayer.xml"); } } }
public void AddElementInPlaylist() { OpenFileDialog windowsDial = new OpenFileDialog(); windowsDial.FileName = "File"; windowsDial.DefaultExt = ".avi"; windowsDial.Filter = "Music file (.mp3)|*.mp3|" + "Video File (.avi, .wmv)|*.avi;*.wmv"; Nullable <bool> result = windowsDial.ShowDialog(); if (result == true) { PlayListElement tmpElement = new PlayListElement(); tmpElement.Pathname = windowsDial.FileName; this.Playlist.Elements.Add(tmpElement); this.NumberElementInPlaylist = this.Playlist.Elements.Count(); PlaylistFound = true; this.FileFound = true; } }