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);
            }
        }
Example #2
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);
            }
        }
Example #4
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);
            });
        }
Example #5
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));
                });
            });
        }
Example #7
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;
 }
Example #8
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));
            }
        }
Example #9
0
        public async Task GetAlbumListAsync()
        {
            if (Link == null)
            {
                return;
            }
            HttpClient hc = new HttpClient();

            hc.DefaultRequestHeaders.UserAgent.Add(new Windows.Web.Http.Headers.HttpProductInfoHeaderValue("Mozilla / 5.0(Windows NT 10.0; WOW64) AppleWebKit / 537.36(KHTML, like Gecko) Chrome / 45.0.2454.101 Safari / 537.36"));
            string response = await hc.GetStringAsync(new Uri(Link, UriKind.Absolute));

            HtmlDocument hdoc = new HtmlDocument();

            hdoc.LoadHtml(response);

            var tmp = (from divtags in hdoc.DocumentNode.Descendants("div").Where(x => x.Attributes[0].Value == "box_pageview")
                       select divtags).First();
            string realLink = tmp.ChildNodes[2].Attributes["onclick"].Value.Split('\'')[1];
            int    numpage  = tmp.ChildNodes.Count - 2;

            AlbumList.Clear();
            for (int i = 1; i <= numpage; i++)
            {
                string link = realLink.Replace("page=2", "page=" + i);
                response = await hc.GetStringAsync(new Uri(link, UriKind.Absolute));

                response = response.Replace("\\n", "\n").Replace("\\/", "/").Replace("\\\"", "\"");
                hdoc.LoadHtml(response);
                var litags = from litag in hdoc.DocumentNode.Descendants("li")
                             select new Album()
                {
                    Link   = litag.ChildNodes[1].ChildNodes[1].Attributes["href"].Value,
                    Cover  = litag.ChildNodes[1].ChildNodes[1].ChildNodes[3].ChildNodes[0].Attributes["src"].Value,
                    Title  = litag.ChildNodes[3].ChildNodes[1].InnerText,
                    Artist = litag.ChildNodes[3].ChildNodes[3].ChildNodes[0].InnerText
                };
                AlbumList.AddRange(litags);
            }
            hc.Dispose();
            return;
        }
Example #10
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);
            });
        }