private void PlayPlaylistButton_Click(object sender, RoutedEventArgs e) { if (_shownPlaylist == null) { return; } if (_currentSong != -1 && _currentSong != _history.Count - 1) { _history.RemoveRange(_currentSong, _history.Count - _currentSong); } var pos = _history.Count; foreach (var song in _shownPlaylist.Songs) { var s = new KnownSongInfo() { Artist = song.Artist, Name = song.Name, }; s.SetSong(new Song() { Artist = song.Artist, Name = song.Name, Uri = song.Uri, }); _history.Add(s); } _currentSong = pos; PlaySong(_history[pos]); }
private void Button_Click(object sender, RoutedEventArgs e) { string query = textBox.Text; if (string.IsNullOrWhiteSpace(query)) { return; } Thread searchThread = new Thread((ThreadStart) delegate { SearchProgressRing.Dispatcher.BeginInvoke((Action) delegate { SearchProgressRing.IsActive = true; textBox.IsEnabled = false; searchButton.IsEnabled = false; SearchResultsGrid.IsEnabled = false; }); IEnumerable <Song> result; try { result = SourceFetch.Search(query); } catch (Exception ex) { MessageBox.Show(ex.Message, "Web Error!"); return; } ObservableCollection <KnownSongInfo> songs = new ObservableCollection <KnownSongInfo>(); foreach (Song song in result) { var s = new KnownSongInfo() { Artist = song.Artist, Name = song.Name }; s.SetSong(song); songs.Add(s); } SearchResultsGrid.Dispatcher.BeginInvoke((Action) delegate { SearchResultsGrid.ItemsSource = songs; }); SearchProgressRing.Dispatcher.BeginInvoke((Action) delegate { SearchProgressRing.IsActive = false; textBox.IsEnabled = true; searchButton.IsEnabled = true; SearchResultsGrid.IsEnabled = true; }); }); searchThread.Start(); }
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; }
private void PlayPlaylistButton_Click(object sender, RoutedEventArgs e) { if (_shownPlaylist == null) return; if (_currentSong != -1 && _currentSong != _history.Count - 1) { _history.RemoveRange(_currentSong, _history.Count - _currentSong); } var pos = _history.Count; foreach (var song in _shownPlaylist.Songs) { var s = new KnownSongInfo() { Artist = song.Artist, Name = song.Name, }; s.SetSong(new Song() { Artist = song.Artist, Name = song.Name, Uri = song.Uri, }); _history.Add(s); } _currentSong = pos; PlaySong(_history[pos]); }
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; }
private void Button_Click(object sender, RoutedEventArgs e) { string query = textBox.Text; if (string.IsNullOrWhiteSpace(query)) return; Thread searchThread = new Thread((ThreadStart) delegate { SearchProgressRing.Dispatcher.BeginInvoke((Action) delegate { SearchProgressRing.IsActive = true; textBox.IsEnabled = false; searchButton.IsEnabled = false; SearchResultsGrid.IsEnabled = false; }); IEnumerable<Song> result; try { result = SourceFetch.Search(query); } catch (Exception ex) { MessageBox.Show(ex.Message, "Web Error!"); return; } ObservableCollection<KnownSongInfo> songs = new ObservableCollection<KnownSongInfo>(); foreach (Song song in result) { var s = new KnownSongInfo() {Artist = song.Artist, Name = song.Name}; s.SetSong(song); songs.Add(s); } SearchResultsGrid.Dispatcher.BeginInvoke((Action)delegate { SearchResultsGrid.ItemsSource = songs; }); SearchProgressRing.Dispatcher.BeginInvoke((Action)delegate { SearchProgressRing.IsActive = false; textBox.IsEnabled = true; searchButton.IsEnabled = true; SearchResultsGrid.IsEnabled = true; }); }); searchThread.Start(); }