예제 #1
0
        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]);
        }
예제 #2
0
        private void SetSongPicture(KnownSongInfo info)
        {
            songPicture.Source = new BitmapImage(new Uri("DefaultAlbum.png", UriKind.Relative));
            Thread pic = new Thread((ThreadStart) delegate
            {
                string uri;
                try
                {
                    uri = info.GetSong().AdditionalInfo.CoverUri64;
                }
                catch (WebException ex)
                {
                    MessageBox.Show(ex.Message, "Web Error!");
                    return;
                }
                catch (NullReferenceException)
                {
                    // No album cover found.
                    return;
                }
                SetPicture(uri);
            });

            pic.Start();
        }
예제 #3
0
 private void PlaySong(KnownSongInfo song)
 {
     manager.Stop();
     songNameLabel.Content   = song.Name;
     songArtistLabel.Content = song.Artist;
     _isSongPlaying          = true;
     IsPaused = false;
     manager.Play(song.GetSong().Uri);
     SetSongPicture(song);
 }
예제 #4
0
        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();
        }
예제 #5
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;
        }
예제 #6
0
 private void SetSongPicture(KnownSongInfo info)
 {
     songPicture.Source = new BitmapImage(new Uri("DefaultAlbum.png", UriKind.Relative));
     Thread pic = new Thread((ThreadStart) delegate
     {
         string uri;
         try
         {
             uri = info.GetSong().AdditionalInfo.CoverUri64;
         }
         catch (WebException ex)
         {
             MessageBox.Show(ex.Message, "Web Error!");
             return;
         }
         catch (NullReferenceException)
         {
             // No album cover found.
             return;
         }
         SetPicture(uri);
     });
     pic.Start();
 }
예제 #7
0
 private void PlaySong(KnownSongInfo song)
 {
     manager.Stop();
     songNameLabel.Content = song.Name;
     songArtistLabel.Content = song.Artist;
     _isSongPlaying = true;
     IsPaused = false;
     manager.Play(song.GetSong().Uri);
     SetSongPicture(song);
 }
예제 #8
0
 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]);
 }
예제 #9
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;
        }
예제 #10
0
        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();
        }