예제 #1
0
 public LibraryPage()
 {
     InitializeComponent();
     Current = this;
     MainPageViewModel.Current.NeedShowTitle = false;
     CategoryList = new ObservableCollection <CategoryListItem>();
 }
예제 #2
0
 public LibraryPage()
 {
     this.InitializeComponent();
     Current = this;
     MainPageViewModel.Current.NeedShowTitle = Window.Current.Bounds.Width > 640;
     MainPageViewModel.Current.Title         = Consts.Localizer.GetString("LibraryText");
     MainPageViewModel.Current.LeftTopColor  = Resources["SystemControlForegroundBaseHighBrush"] as SolidColorBrush;
     CategoryList = new ObservableCollection <CategoryListItem>();
 }
예제 #3
0
        public LibraryPage()
        {
            this.InitializeComponent();
            Current = this;

            MainPageViewModel.Current.Title         = Consts.Localizer.GetString("LibraryText");
            MainPageViewModel.Current.NeedShowTitle = true;
            MainPageViewModel.Current.LeftTopColor  = Resources["SystemControlForegroundBaseHighBrush"] as SolidColorBrush;

            CategoryList = new ObservableCollection <CategoryListItem>()
            {
                new CategoryListItem
                {
                    Title      = Consts.Localizer.GetString("SongsText"),
                    HeroImages = new List <ImageSource>()
                    {
                        new BitmapImage(new Uri("ms-appx:///Assets/Images/songs.png"))
                    },
                    NavigatType = typeof(SongsPage)
                },
                new CategoryListItem
                {
                    Title      = Consts.Localizer.GetString("AlbumsText"),
                    HeroImages = new List <ImageSource>()
                    {
                        new BitmapImage(new Uri("ms-appx:///Assets/Images/albums.png"))
                    },
                    NavigatType = typeof(AlbumsPage)
                },
                new CategoryListItem
                {
                    Title      = Consts.Localizer.GetString("ArtistsText"),
                    HeroImages = new List <ImageSource>()
                    {
                        new BitmapImage(new Uri("ms-appx:///Assets/Images/artists.png"))
                    },
                    NavigatType = typeof(ArtistsPage)
                }
            };

            Task.Run(async() =>
            {
                playlists = await SQLOperator.Current().GetPlayListBriefAsync();
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    foreach (var playlist in playlists)
                    {
                        CategoryList.Add(new CategoryListItem
                        {
                            Title       = playlist.Title,
                            HeroImages  = playlist.HeroArtworks == null ? null : Array.ConvertAll(playlist.HeroArtworks, x => (ImageSource) new BitmapImage(new Uri(x))).ToList(),
                            NavigatType = typeof(PlayListPage)
                        });
                    }
                });
            });

            var item = CategoryList.FirstOrDefault(x => x.Title == Settings.Current.CategoryLastClicked);

            if (item != default(CategoryListItem))
            {
                item.IsCurrent = true;
                CategoryList.Remove(item);
                CategoryList.Insert(0, item);
            }
            else
            {
                CategoryList[0].IsCurrent = true;
            }

            if (CategoryList[0].NavigatType == typeof(PlayListPage))
            {
                Navigate(CategoryList[0].NavigatType, playlists.Find(x => x.Title == (CategoryList[0].Title)));
            }
            else
            {
                Navigate(CategoryList[0].NavigatType);
            }

            if (Window.Current.Bounds.Width <= 640)
            {
                MainPageViewModel.Current.NeedShowTitle = false;
            }
        }