Пример #1
0
        private void DisplayPlaylist(Playlist list)
        {
            MainTabControl.SelectedItem = PlaylistTabItem;
            PlaylistNameTextbox.Text = list.Name;

            ObservableCollection<KnownSongInfo> songs = new ObservableCollection<KnownSongInfo>();
            foreach (SavedSong song in list.Songs)
            {
                var s = new KnownSongInfo() { Artist = song.Artist, Name = song.Name };
                s.SetSong(new Song()
                {
                    Artist = song.Artist,
                    Name = song.Name,
                    Uri = song.Uri,
                });
                songs.Add(s);
            }
            CurrentPlaylistDataGrid.ItemsSource = songs;
            _shownPlaylist = list;
        }
Пример #2
0
        private void DeletePlaylistButton_Click(object sender, RoutedEventArgs e)
        {
            PlaylistStackPanel.Children.Remove(_shownPlaylistButton);
            SearchContextMenu.Items.Remove(_mainPlaylistData[_shownPlaylist].AssociatedContextItem);

            PlaylistSaver.Data.Remove(_shownPlaylist);
            PlaylistSaver.SaveAll();
            MainTabControl.SelectedItem = SearchTabItem;
            _shownPlaylist = null;
            _shownPlaylistButton = null;
        }
Пример #3
0
 private void DiscoverButton_Click(object sender, RoutedEventArgs e)
 {
     MainTabControl.SelectedItem = SearchTabItem;
     _shownPlaylist = null;
     _shownPlaylistButton = null;
 }
Пример #4
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            //Create new playlist
            Playlist playlist = new Playlist();
            playlist.Name = "New Playlist";
            playlist.Songs = new List<SavedSong>();
            PlaylistSaver.Data.Add(playlist);
            PlaylistSaver.SaveAll();

            var mi = new MenuItem();
            mi.Header = "Add to " + playlist.Name;
            mi.Click += MenuItem_OnClick;
            SearchContextMenu.Items.Add(mi);

            var btn = CreatePlaylistButton();
            btn.Content = playlist.Name;
            btn.Click += (s, _) =>
            {
                _shownPlaylistButton = (Button) s;
                DisplayPlaylist(playlist);
            };

            _mainPlaylistData.Add(playlist, new PlaylistData()
            {
                AssociatedButton = btn,
                AssociatedContextItem = mi,
            });

            _shownPlaylist = playlist;
            _shownPlaylistButton = btn;
            PlaylistStackPanel.Children.Insert(PlaylistStackPanel.Children.Count-1,btn);
        }