AlbumsPage.xaml.cs 2.2 KB
Newer Older
1 2
using System;
using SonicStreamer.Common.System;
Axelander's avatar
Axelander committed
3 4 5 6
using SonicStreamer.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
7
using SonicStreamer.Controls;
Axelander's avatar
Axelander committed
8 9 10 11 12

namespace SonicStreamer.Pages
{
    public sealed partial class AlbumsPage : Page
    {
13 14 15
        public readonly AlbumViewModel AlbumVm;
        public readonly PlaylistViewModel PlaylistVm;
        public readonly MainViewModel MainVm;
Axelander's avatar
Axelander committed
16 17 18 19 20

        public AlbumsPage()
        {
            InitializeComponent();

21 22 23 24 25 26
            if (ResourceLoader.Current.GetResource(ref AlbumVm, Constants.ViewModelAlbum) == false)
                AlbumVm = new AlbumViewModel();
            if (ResourceLoader.Current.GetResource(ref PlaylistVm, Constants.ViewModelPlaylist) == false)
                PlaylistVm = new PlaylistViewModel();
            if (ResourceLoader.Current.GetResource(ref MainVm, Constants.ViewModelMain) == false)
                MainVm = new MainViewModel();
Axelander's avatar
Axelander committed
27 28 29 30 31
        }

        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            Microsoft.HockeyApp.HockeyClient.Current.TrackPageView(GetType().Name);
32 33
            await AlbumVm.LoadDataAsync();
            ListViewSource.Source = AlbumVm.Items;
Axelander's avatar
Axelander committed
34 35 36 37 38 39 40 41 42 43
            var listViewBase = SemanticZoomContainer.ZoomedOutView as ListViewBase;
            if (listViewBase != null)
                listViewBase.ItemsSource = ListViewSource.View.CollectionGroups;
        }

        private void listingItemsView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Frame.Navigate(typeof(TrackListingPage), e.ClickedItem);
        }

44
        private async void AddToPlaylist_Click(object sender, RoutedEventArgs e)
Axelander's avatar
Axelander committed
45
        {
46 47 48 49 50 51 52 53
            AddToPlaylistDialog.Content = new AddToPlaylistDialog(); 

            var dialogResult = await AddToPlaylistDialog.ShowAsync();
            if (dialogResult == ContentDialogResult.Primary)
            {
                await AlbumVm.AddToPlaylistAsync();
            }
            PlaylistVm.ResetDialogInputs();
Axelander's avatar
Axelander committed
54 55
        }

56
        private async void AddToPlaylistDialog_OnOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
Axelander's avatar
Axelander committed
57
        {
58
            await PlaylistVm.LoadDialogDataAsync();
Axelander's avatar
Axelander committed
59 60 61
        }
    }
}