private void RenamePlayList_MouseDown(object sender, MouseButtonEventArgs e) { window = App.Current.MainWindow as MainWindow; AddNewPlayList dlg = new AddNewPlayList(TypeOfWindow.Rename); if (dlg.ShowDialog() == true) { if (window.collectionOfPlayLists.currentPlayList.Name == playListCurrent.Text) { window.collectionOfPlayLists.currentPlayList.Name = dlg.NameOfPlayList; //window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0).Name = dlg.NameOfPlayList; } else { window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0).Name = dlg.NameOfPlayList; } playListCurrent.Text = dlg.NameOfPlayList; playListView.Items.Clear(); InitPlayListView(window.collectionOfPlayLists.currentPlayList); } }
private void NewPlayList_MouseDown(object sender, MouseButtonEventArgs e) { window = App.Current.MainWindow as MainWindow; AddNewPlayList dlg = new AddNewPlayList(TypeOfWindow.Add); if (dlg.ShowDialog() == true) { if (!window.collectionOfPlayLists.playLists.Select(p => p.Name).Contains(dlg.NameOfPlayList)) { window.collectionOfPlayLists.playLists.Add(new PlayList() { Name = dlg.NameOfPlayList }); if (window.collectionOfPlayLists.playLists.Count > 3) { IsAnimatible = true; if (window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.currentPlayList) - 1 < 0) { playListPrev.Text = window.collectionOfPlayLists.playLists[window.collectionOfPlayLists.playLists.Count - 1].Name; } else { playListPrev.Text = window.collectionOfPlayLists.playLists[window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.currentPlayList) - 1].Name; } playListCurrent.Text = window.collectionOfPlayLists.currentPlayList.Name; if (window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.currentPlayList) + 1 > window.collectionOfPlayLists.playLists.Count) { playListNext.Text = window.collectionOfPlayLists.playLists[0].Name; } else { if (window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.currentPlayList) + 1 >= window.collectionOfPlayLists.playLists.Count) { playListNext.Text = window.collectionOfPlayLists.playLists[0].Name; } else { playListNext.Text = window.collectionOfPlayLists.playLists[window.collectionOfPlayLists.playLists.IndexOf(window.collectionOfPlayLists.currentPlayList) + 1].Name; } } playListPrev.Visibility = System.Windows.Visibility.Visible; playListNext.Visibility = System.Windows.Visibility.Visible; } else { IsAnimatible = false; if (window.collectionOfPlayLists.playLists.Count == 1) { playListPrev.Visibility = System.Windows.Visibility.Hidden; playListNext.Visibility = System.Windows.Visibility.Hidden; playListCurrent.Text = window.collectionOfPlayLists.playLists[0].Name; } else if (window.collectionOfPlayLists.playLists.Count == 2) { playListNext.Visibility = System.Windows.Visibility.Hidden; playListPrev.Text = window.collectionOfPlayLists.playLists[0].Name; playListCurrent.Text = window.collectionOfPlayLists.playLists[1].Name; playListPrev.Visibility = System.Windows.Visibility.Visible; } else { playListNext.Text = window.collectionOfPlayLists.playLists[2].Name; playListPrev.Text = window.collectionOfPlayLists.playLists[0].Name; playListCurrent.Text = window.collectionOfPlayLists.playLists[1].Name; playListPrev.Visibility = System.Windows.Visibility.Visible; playListNext.Visibility = System.Windows.Visibility.Visible; } } InitPlayListView(window.collectionOfPlayLists.currentPlayList); } else { MessageBox.Show("You have already playlist with that name!", "Player", MessageBoxButton.OK, MessageBoxImage.Error); } } }