コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
        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
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
        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();
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
        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;
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
 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]);
 }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
        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
ファイル: MainWindow.xaml.cs プロジェクト: Guad/MusicTimeGUI
        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();
        }