コード例 #1
0
 private async void LoadData()
 {
     this.IsBusy = true;
     var newestAlbums = await this.m_dataService.GetNewestAlbums(9);
     if (newestAlbums != null)
     {
         int iIndex = 0;
         foreach (var album in newestAlbums)
         {
             if (album != null)
             {
                 DataItemViewModel dataItem = new DataItemViewModel();
                 if (iIndex == 0)
                 {
                     dataItem = new BigDataItemViewModel();
                 }
                 iIndex++;
                 dataItem.Title = album.Title;
                 dataItem.Subtitle = album.Artist.Name;
                 dataItem.Image = album.Cover;
                 dataItem.Data = album;
                 this.DataGroup.Items.Add(dataItem);
             }
         }
         this.IsBusy = false;
     }
 }
コード例 #2
0
 private void SelectItem(DataItemViewModel dataItem)
 {
     if (dataItem != null)
     {
         Album album = dataItem.Data as Album;
         if (album != null)
         {
             this.m_navigationService.Navigate(typeof(AlbumDetailPage), album.Id);
         }
     }
 }
コード例 #3
0
 private void SelectItem(DataItemViewModel dataItem)
 {
     if (dataItem != null)
     {
         Track track = dataItem.Data as Track;
         if (track != null)
         {
             this.m_navigationService.Navigate(typeof(AlbumDetailPage), typeof(MasterPage), track.Album.Id);
         }
     }
 }
コード例 #4
0
        public async void OnNavigatedTo(object navigationParameter, NavigationMode navigationMode)
        {
            string queryString = navigationParameter as string;
            if (string.IsNullOrEmpty(queryString) == false)
            {
                this.PageTitle = string.Format(CultureInfo.CurrentCulture,
                    this.m_resourceService.GetString("IDS_SearchPane_PageTitle", "Results for {0}"), queryString);
                try
                {
                    Query query = new Query
                    {
                        SearchPhrase = queryString,
                        PageSize = 9
                    };
                    var searchResult = await this.m_dataService.GetSearchResults(query);
                    if (searchResult != null)
                    {
                        Album[] albums = searchResult.Albums;
                        if (albums != null && albums.Count() > 0)
                        {
                            DataGroupViewModel albumGroup = new DataGroupViewModel
                            {
                                Title = this.m_resourceService.GetString("IDS_SearchPane_GroupTitleAlbums", "Albums"),
                                Data = new SearchCategory
                                {
                                    Mode = DataModel.FilterMode.Albbums,
                                    Query = queryString
                                }
                            };
                            foreach (var album in albums)
                            {
                                if (album != null)
                                {
                                    DataItemViewModel dataItem = new DataItemViewModel();
                                    dataItem.Title = album.Title;
									dataItem.ImageSource = this.m_dataService.GetImage(album.AlbumId, true);
                                    dataItem.Subtitle = album.Artist.Name;
                                    dataItem.Data = album;
                                    albumGroup.Items.Add(dataItem);
                                }
                            }
                            this.SearchResultGroups.Add(albumGroup);
                        }
                        Track[] tracks = searchResult.Tracks;
                        if (tracks != null && tracks.Count() > 0)
                        {
                            DataGroupViewModel trackGroup = new DataGroupViewModel
                            {
                                Title = this.m_resourceService.GetString("IDS_SearchPane_GroupTitleTracks", "Tracks"),
                                Data = new SearchCategory
                                {
                                    Mode = DataModel.FilterMode.Tracks,
                                    Query = queryString
                                }
                            };
                            foreach (var track in tracks)
                            {
                                if (track != null)
                                {
                                    DataItemViewModel dataItem = new DataItemViewModel();
                                    dataItem.Title = track.Name;
									dataItem.ImageSource = this.m_dataService.GetImage(track.Album.AlbumId, true);
                                    dataItem.Subtitle = track.Album.Artist.Name;
                                    dataItem.Data = track;
                                    trackGroup.Items.Add(dataItem);
                                }
                            }
                            this.SearchResultGroups.Add(trackGroup);
                        }
                    }
                }
                catch (AggregateException aggregateException)
                {
					string errorMessage = string.Empty;
                    foreach (var innerException in aggregateException.Flatten().InnerExceptions)
                    {
						if (innerException != null && !string.IsNullOrEmpty(innerException.Message))
						{
							errorMessage += innerException.Message + Environment.NewLine;
						}
                    }
					if (!string.IsNullOrEmpty(errorMessage))
					{
						this.m_dialogservice.ShowDialog(errorMessage);
					}

                }
            }
        }