private void removeItemVideoMenu_Click(object sender, EventArgs e) { if (lbxVideo.SelectedItems.Count > 0) { foreach (string videoSelectedItem in lbxVideo.SelectedItems.OfType <String>().ToList()) { lbxVideo.Items.Remove(videoSelectedItem); lbxVideoFavorite.Items.Remove(videoSelectedItem); CurrentVideoPlayList.Remove(videoSelectedItem); } lbxVideo.ClearSelected(); } }
private void btnOpen_Click(object sender, EventArgs e) { if (tabControl.SelectedTab == tabMusic) { openFileDialog.Filter = @"Music|*.mp3"; openFileDialog.FileName = "music"; openFileDialog.ShowDialog(); Dictionary <string, string> newFiles = openFileDialog.FileNames .ToList() .Where(filePath => File.Exists(filePath)) .ToDictionary(Path.GetFileName, filePath => filePath); foreach (var kv in newFiles) { if (CurrentMusicPlayList.ContainsKey(kv.Key)) { continue; } CurrentMusicPlayList.Add(kv.Key, kv.Value); } lbxMusics.Items.Clear(); lbxMusics.Items.AddRange(Enumerable.ToArray(CurrentMusicPlayList.Keys)); lbxMusics.Sorted = true; return; } if (tabControl.SelectedTab == tabVideo) { openFileDialog.Filter = @"Video|*.mp4;*.avi;*.mkv;*.mwn"; openFileDialog.FileName = "Video"; openFileDialog.ShowDialog(); Dictionary <string, string> newFiles = openFileDialog.FileNames .ToList() .Where(filePath => File.Exists(filePath)) .ToDictionary(Path.GetFileName, filePath => filePath); foreach (var kv in newFiles) { if (CurrentVideoPlayList.ContainsKey(kv.Key)) { continue; } CurrentVideoPlayList.Add(kv.Key, kv.Value); } lbxVideo.Items.Clear(); lbxVideo.Items.AddRange(Enumerable.ToArray(CurrentVideoPlayList.Keys)); } }