Beispiel #1
0
        private async void TracksCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (TracksCollection.Elements.Count > 0 && e.NewItems?.Count == SongCount)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MusicLibraryLoaded.Invoke(this, new RoutedEventArgs()); });  //no use raising an event when library isn't ready.

                OldItems = TracksCollection.Elements;
                TracksCollection.CollectionChanged -= TracksCollection_CollectionChanged;
            }
        }
        private async void TracksCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (TracksCollection.Elements.Count > 0 && e.NewItems?.Count == SongCount)
            {
                await RemoveDuplicateGroups().ConfigureAwait(false);

                Messenger.Instance.NotifyColleagues(MessageTypes.MSG_LIBRARY_LOADED, new List <object>()
                {
                    TracksCollection, grouped
                });
                MusicLibraryLoaded.Invoke(this, new RoutedEventArgs());
                OldItems = TracksCollection.Elements;
                TracksCollection.CollectionChanged -= TracksCollection_CollectionChanged;
            }
        }
 /// <summary>
 /// Loads library from the database file.
 /// </summary>
 async void LoadLibrary()
 {
     if (File.Exists(ApplicationData.Current.LocalFolder.Path + @"\breadplayer.db"))
     {
         //OldItems = db.GetTracks();
         TracksCollection = new GroupedObservableCollection <string, Mediafile>(t => t.Title, await db.GetTracks(), t => t.Title);
         RecentlyPlayedCollection.AddRange(db.recent.FindAll());
         if (TracksCollection.Elements.Count > 0)
         {
             MusicLibraryLoaded.Invoke(this, new RoutedEventArgs());                                     //no use raising an event when library isn't ready.
         }
         ViewSource.Source          = TracksCollection.Elements;
         ViewSource.IsSourceGrouped = false;
     }
 }
Beispiel #4
0
 private async void HandleUpdateSongCountMessage(Message message)
 {
     if (message.Payload is short || message.Payload is Int32)
     {
         message.HandledStatus = MessageHandledStatus.HandledCompleted;
         SongCount             = Convert.ToInt32(message.Payload);
         IsLibraryLoading      = true;
     }
     else
     {
         IsLibraryLoading = false;
         await SharedLogic.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             MusicLibraryLoaded?.Invoke(this, new RoutedEventArgs());
         });
     }
 }
        private async void TracksCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (TracksCollection.Elements.Count > 0 && e.NewItems?.Count == SongCount)
            {
                await RemoveDuplicateGroups().ConfigureAwait(false);

                Messenger.Instance.NotifyColleagues(MessageTypes.MSG_LIBRARY_LOADED, new List <object>()
                {
                    TracksCollection, grouped
                });

                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MusicLibraryLoaded.Invoke(this, new RoutedEventArgs()); }); //no use raising an event when library isn't ready.

                OldItems = TracksCollection.Elements;
                TracksCollection.CollectionChanged -= TracksCollection_CollectionChanged;
            }
        }
Beispiel #6
0
        private async void HandleImportFolder(Message message)
        {
            if (message.Payload is IEnumerable <Mediafile> songs)
            {
                message.HandledStatus = MessageHandledStatus.HandledCompleted;

                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("Adding songs into library. Please wait...");

                TracksCollection.AddRange(songs);
                await SharedLogic.Instance.NotificationManager.ShowMessageAsync("Saving songs into database. Please wait...");

                await LibraryService.AddMediafiles(songs).ConfigureAwait(false);

                IsLibraryLoading = false;
                await BreadDispatcher.InvokeAsync(() =>
                {
                    MusicLibraryLoaded?.Invoke(this, new RoutedEventArgs());
                });
            }
        }