internal async void ChangeSort(int selectedIndex)
        {
            var albums = await FileReader.GetAllAlbumsAsync();

            IEnumerable <GroupedItem <AlbumViewModel> > grouped;

            switch (selectedIndex)
            {
            case 0:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                break;

            case 1:
                grouped = GroupedItem <AlbumViewModel> .CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

                break;

            case 2:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());

                break;

            default:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                break;
            }
            AlbumList.Clear();
            foreach (var item in grouped)
            {
                AlbumList.Add(item);
            }
        }
Пример #2
0
        public ArtistViewModel(Artist artist)
        {
            Name       = artist.Name;
            Cover      = artist.Cover;
            ArtistInfo = artist;
            if (artist.Cover != null)
            {
                BgImage           = new BitmapImage();
                BgImage.UriSource = new Uri(artist.Cover);
            }
            if (artist.TrackList != null)
            {
                foreach (var track in artist.TrackList)
                {
                    TrackList.Add(new TrackViewModel(track));
                }
            }

            if (artist.AlbumList != null)
            {
                foreach (var album in artist.AlbumList)
                {
                    AlbumList.Add(new AlbumViewModel(album));
                }
            }
        }
Пример #3
0
        public async Task GetAlbums()
        {
            var albums = await FileReader.GetAllAlbumsAsync();

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());
            IEnumerable <GroupedItem <AlbumViewModel> > grouped;

            switch (Settings.Current.AlbumsSort)
            {
            case SortMode.Alphabet:
                grouped = GroupedItem <AlbumViewModel> .CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

                SortIndex = 1;
                break;

            case SortMode.Year:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                SortIndex = 0;
                break;

            case SortMode.Artist:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());

                SortIndex = 2;
                break;

            default:
                grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

                SortIndex = 0;
                break;
            }

            var aCount = await FileReader.GetArtistsCountAsync();

            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                AlbumList.Clear();
                foreach (var item in grouped)
                {
                    AlbumList.Add(item);
                }
                SongsCount   = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartAlbums"), albums.Count);
                ArtistsCount = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartArtists"), aCount);


                var tileId = "albums";
                IsPinned   = SecondaryTile.Exists(tileId);

                if (IsPinned)
                {
                    Core.Tools.Tile.UpdateImage(tileId, AlbumList.SelectMany(a => a.Where(c => c.ArtworkUri != null).Select(b => b.ArtworkUri.OriginalString)).Distinct().OrderBy(x => Guid.NewGuid()).Take(10).ToList(), Consts.Localizer.GetString("AlbumsText"), Consts.Localizer.GetString("AlbumsTile"));
                }
            });
        }
        public async Task GetAlbums()
        {
            var albumList = await _albumService.Get <IEnumerable <Album> >(SelectedPerformer.Id, "GetAlbumsByPerformerId");

            AlbumList.Clear();
            foreach (var item in albumList)
            {
                AlbumList.Add(item);
            }
        }
Пример #5
0
        public async Task LoadMoreAlbumAsync()
        {
            if (ArtistInfo == null)
            {
                return;
            }
            var albumList = await ArtistInfo.LoadMoreAlbumList(++albumPage);

            foreach (var album in albumList)
            {
                AlbumList.Add(new AlbumViewModel(album));
            }
        }
Пример #6
0
        public async Task GetAlbums(ArtistViewModel artist)
        {
            var albums = await FileReader.GetAlbumsAsync(artist.RawName);

            var b = ThreadPool.RunAsync(async x =>
            {
                var aa = albums.ToList();
                aa.Shuffle();
                var list = new List <Uri>();
                for (int j = 0; j < aa.Count && j < 6; j++)
                {
                    if (aa[j].PicturePath.IsNullorEmpty())
                    {
                        continue;
                    }
                    list.Add(new Uri(aa[j].PicturePath));
                }
                list.Shuffle();
                await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    HeroImage = list.ConvertAll(y => (ImageSource) new BitmapImage(y));
                });

                var art = await MainPageViewModel.Current.GetArtistInfoAsync(artist.RawName);
                if (art != null)
                {
                    await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                    {
                        Artist.Description = art.Description;
                        Artist.Avatar      = art.AvatarUri;
                    });
                }
            });

            var a      = albums.OrderByDescending(x => x.Year);
            var genres = (from alb in a
                          where !alb.Genres.IsNullorEmpty()
                          group alb by alb.Genres into grp
                          orderby grp.Count() descending
                          select grp.Key).FirstOrDefault();
            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                AlbumList.Clear();
                foreach (var item in a)
                {
                    AlbumList.Add(new AlbumViewModel(item));
                }
                SongsCount = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartAlbums"), AlbumList.Count);
                Genres     = genres.IsNullorEmpty() ? Consts.Localizer.GetString("VariousGenresText") : string.Join(Consts.CommaSeparator, genres);
            });
        }
 public void Load(SearchResult SearchInfo)
 {
     this.SearchInfo = SearchInfo;
     foreach (Album item in SearchInfo.Albums)
     {
         AlbumList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration)));
     }
     foreach (Track item in SearchInfo.Tracks)
     {
         TrackList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration)));
     }
     foreach (Video item in SearchInfo.Videos)
     {
         VideoList.Add(new SearchItem(item.Title, item.Artists[0].Name, TimeHelper.ConverIntToString(item.Duration)));
     }
 }
Пример #8
0
        public async Task LoadAlbums()
        {
            AlbumList.Clear();

            var request = new Model.Requests.AlbumsSearchRequest
            {
                ArtistId = ArtistId,
                Filter   = (int)ReviewStatus.Approved
            };
            var list = await _serviceAlbums.Get <List <Model.Albums> >(request);

            foreach (var item in list)
            {
                AlbumList.Add(item);
            }
        }
        public async Task GetAlbums()
        {
            var albums = await FileReader.GetAllAlbumsAsync();

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroupsByAlpha(albums.ConvertAll(x => new AlbumViewModel(x)));

            //var grouped = GroupedItem<AlbumViewModel>.CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.GetFormattedArtists());

            var grouped = GroupedItem <AlbumViewModel> .CreateGroups(albums.ConvertAll(x => new AlbumViewModel(x)), x => x.Year, true);

            var aCount = await FileReader.GetArtistsCountAsync();

            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                AlbumList.Clear();
                foreach (var item in grouped)
                {
                    AlbumList.Add(item);
                }
                SongsCount   = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartAlbums"), albums.Count);
                ArtistsCount = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartArtists"), aCount);
            });

            var b = ThreadPool.RunAsync(async x =>
            {
                var aa = albums.ToList();
                aa.Shuffle();
                var list = new List <Uri>();
                for (int j = 0; j < aa.Count && list.Count < 6; j++)
                {
                    if (aa[j].PicturePath.IsNullorEmpty())
                    {
                        continue;
                    }
                    list.Add(new Uri(aa[j].PicturePath));
                }
                list.Shuffle();
                await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                {
                    HeroImage = list.ConvertAll(y => (ImageSource) new BitmapImage(y));
                });
            });
        }
Пример #10
0
 public void Coppy(ArtistViewModel artistVM)
 {
     Name       = artistVM.Name;
     ArtistInfo = artistVM.ArtistInfo;
     Cover      = artistVM.Cover;
     BgImage    = artistVM.BgImage;
     AlbumList.Clear();
     TrackList.Clear();
     foreach (var album in artistVM.AlbumList)
     {
         AlbumList.Add(album);
     }
     foreach (var track in artistVM.TrackList)
     {
         TrackList.Add(track);
     }
     trackPage = artistVM.trackPage;
     albumPage = artistVM.albumPage;
 }
Пример #11
0
        public async Task LoadDataInitAsync()
        {
            if (ArtistInfo == null)
            {
                return;
            }
            await ArtistInfo.LoadDataInitAsync();

            TrackList.Clear();
            AlbumList.Clear();
            foreach (var track in ArtistInfo.TrackList)
            {
                TrackList.Add(new TrackViewModel(track));
            }
            foreach (var album in ArtistInfo.AlbumList)
            {
                AlbumList.Add(new AlbumViewModel(album));
            }
        }
Пример #12
0
        public async Task Init(ArtistViewModel artist)
        {
            var b = ThreadPool.RunAsync(async x =>
            {
                var art = await MainPageViewModel.Current.GetArtistInfoAsync(artist.RawName);
                if (art != null)
                {
                    await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
                    {
                        Artist.Description = art.Description;
                        Artist.Avatar      = art.AvatarUri;
                    });
                }
            });

            var opr = SQLOperator.Current();

            var albums = await opr.GetAlbumsOfArtistAsync(artist.RawName);

            var songs = await opr.GetSongsAsync(albums.SelectMany(s => s.Songs));

            var empty = artist.RawName.IsNullorEmpty();

            for (int i = songs.Count - 1; i >= 0; i--)
            {
                if (empty)
                {
                    if (songs[i].Performers == null || songs[i].Performers.Length == 0)
                    {
                        continue;
                    }
                    else
                    {
                        songs.RemoveAt(i);
                    }
                }
                else
                {
                    var flag = false;
                    if (songs[i].Performers != null)
                    {
                        foreach (var p in songs[i].Performers)
                        {
                            if (artist.RawName == p)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        if (songs[i].AlbumArtists == null || songs[i].AlbumArtists.Length == 0)
                        {
                            songs.RemoveAt(i);
                            continue;
                        }
                        else
                        {
                            foreach (var p in songs[i].AlbumArtists)
                            {
                                if (artist.RawName == p)
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (!flag)
                    {
                        songs.RemoveAt(i);
                    }
                }
            }
            var grouped = GroupedItem <SongViewModel> .CreateGroupsByAlpha(songs.ConvertAll(x => new SongViewModel(x)));

            var a      = albums.OrderByDescending(x => x.Year);
            var genres = (from alb in a
                          where !alb.Genres.IsNullorEmpty()
                          group alb by alb.Genres into grp
                          orderby grp.Count() descending
                          select grp.Key).FirstOrDefault();
            await CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
            {
                AlbumList.Clear();
                foreach (var item in a)
                {
                    AlbumList.Add(new AlbumViewModel(item));
                }
                SongsList.Clear();
                foreach (var item in grouped)
                {
                    item.Aggregate((x, y) =>
                    {
                        y.Index = x.Index + 1;
                        return(y);
                    });
                    SongsList.Add(item);
                }
                SongsCount = SmartFormat.Smart.Format(Consts.Localizer.GetString("SmartAlbums"), AlbumList.Count);
                Genres     = genres.IsNullorEmpty() ? Consts.Localizer.GetString("VariousGenresText") : string.Join(Consts.CommaSeparator, genres);
            });
        }
Пример #13
0
        private void load_default()
        {
            PictureList pl;

            pl = Picture.ExtractListFromPath(Environment.GetFolderPath(Environment.SpecialFolder.CommonPictures));
            Album a = new Album(pl, "Shared Pictures");
            albums = new AlbumList();
            albums.Add(a);
            albums.SetActive(a);
        }
Пример #14
0
        private void ListAlbumCallback()
        {
            var web = (HttpWebRequest)WebRequest.Create(string.Format("https://api.vkontakte.ru/method/photos.getAlbums?uid={0}&access_token={1}", _uid, Client.Instance.Access_token.token));
            web.Method = "POST";
            web.ContentType = "application/x-www-form-urlencoded";
            web.BeginGetResponse(delegate(IAsyncResult e)
                                     {
                                         var request = (HttpWebRequest)e.AsyncState;
                                         var response = (HttpWebResponse)request.EndGetResponse(e);

                                         var responseReader = new StreamReader(response.GetResponseStream());
                                         _al = new AlbumList();
                                         try
                                         {
                                             var responseString = responseReader.ReadToEnd();
                                             var o = JObject.Parse(responseString);
                                             try
                                             {
                                                 var responseArray = (JArray)o["response"];
                                                 foreach (var albumItem in responseArray.Select(album => new AlbumItem
                                                                                                             {
                                                                                                                 Aid = (string) album["aid"],
                                                                                                                 ThumbId = (string) album["thumb_id"],
                                                                                                                 OwnerId = (string) album["owner_id"],
                                                                                                                 Title = (string) album["title"],
                                                                                                                 Description = (string) album["description"],
                                                                                                                 Created = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(Convert.ToInt32((string) album["created"]))),
                                                                                                                 Updated = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Convert.ToDouble(Convert.ToInt32((string) album["updated"]))),
                                                                                                                 Size = (string) album["size"] + " фот."
                                                                                                             }))
                                                 {
                                                     _thumbIdList.Add(albumItem.OwnerId + "_" + albumItem.ThumbId);
                                                     _al.Add(albumItem);
                                                 }
                                                 Dispatcher.BeginInvoke(ListAlbumThumbCallback);
                                             }
                                             catch
                                             {
                                                 Dispatcher.BeginInvoke(() =>
                                                 {
                                                     NoAlbums.Text = "альбомов нет";
                                                     progressBar1.IsIndeterminate = false;
                                                 });
                                                 return;
                                             }
                                         }
                                         catch (Exception ex)
                                         {
                                             Dispatcher.BeginInvoke(() => { MessageBox.Show(ex.Message); progressBar1.IsIndeterminate = false; });
                                         }
                                     }, web);
            progressBar1.IsIndeterminate = true;
        }