예제 #1
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var myMusic = await Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Music);

            IObservableVector <StorageFolder> myMusicFolders = myMusic.Folders;

            collection = new Collection();
            foreach (var fold in myMusicFolders)
            {
                var query = fold.CreateFileQueryWithOptions(new Windows.Storage.Search.QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByTitle, new string[] { ".mp3" }));
                var list  = await query.GetFilesAsync();

                foreach (var file in list)
                {
                    Song song = await CreateSongFromFileAsync(file);

                    collection.Add(song);
                }
            }
            pageParams              = new MainPageParams();
            pageParams.CentreFrame  = CentreFrame;
            MediaHelper.MediaPlayer = MediaPlayer;
            //pageParams.NavigationControlView = NavigationControlView;
            pageParams.collection = collection;
            List <string> ListofPlaylistName = new List <string>();
            var           storageFolder      = ApplicationData.Current.LocalFolder;
            var           files = await storageFolder.GetFilesAsync();

            foreach (var file in files)
            {
                ListofPlaylistName.Add(file.Name);
            }
            PlayList.UserPlayLists    = ListofPlaylistName;
            PlayList.PlaylistAdded   += PlaylistAdded;
            PlayList.PlaylistDeleted += PlaylistDeleted;
            foreach (var name in ListofPlaylistName)
            {
                Microsoft.UI.Xaml.Controls.NavigationViewItem viewItem = new Microsoft.UI.Xaml.Controls.NavigationViewItem();
                viewItem.Content = name;
                viewItem.Tapped += PlaylistSelected;
                NavigationControlView.MenuItems.Add(viewItem);
            }

            CentreFrame.Navigate(typeof(PivotDisplay), pageParams);
        }
예제 #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            mainPageParams          = e.Parameter as MainPageParams;
            collection              = mainPageParams.collection;
            listOfSongs.DataContext = collection.GetListofSongs();


            List <string> PlaylistNames = PlayList.UserPlayLists;

            foreach (var name in PlaylistNames)
            {
                MenuFlyoutItem menuflyoutitem = new MenuFlyoutItem();
                menuflyoutitem.Text   = name;
                menuflyoutitem.Click += PlaylistName_Click;
                AddToMenuFlyout.Items.Add(menuflyoutitem);
            }
        }