Example #1
0
        private GroupedObservableCollection <string, RdlnDocument> GetGrouped(IEnumerable <RdlnDocument> documents, string order)
        {
            GroupedObservableCollection <string, RdlnDocument> groups = null;

            if (String.IsNullOrEmpty(order))
            {
                groups = new GroupedObservableCollection <string, RdlnDocument>(d => { return(d.Category == null ? string.Empty : d.Category); }, documents);
            }
            else
            {
                groups = new GroupedObservableCollection <string, RdlnDocument>(d => { return((d.GetRawFieldValue(order) ?? string.Empty).ToUpperInvariant()); }, documents);
            }
            //switch (order)
            //{
            //    case Constants.GroupCategories.AUTHOR:
            //        groups = new GroupedObservableCollection<string, RdlnDocument>(d => { return d.Author == null ? string.Empty : d.Author; }, documents);
            //        break;
            //    case Constants.GroupCategories.CATEGORY:
            //        groups = new GroupedObservableCollection<string, RdlnDocument>(d => { return d.Category == null ? string.Empty : d.Category; }, documents);
            //        break;
            //    default:
            //        groups = new GroupedObservableCollection<string, RdlnDocument>(d => { return d.Title == null ? String.Empty : d.Title[0].ToString(CultureInfo.InvariantCulture).ToUpper(CultureInfo.InvariantCulture); }, documents);
            //        break;
            //}
            return(groups);
        }
Example #2
0
        /// <summary>
        /// Loads library from the database file.
        /// </summary>
        void LoadLibrary()
        {
            if (File.Exists(ApplicationData.Current.LocalFolder.Path + @"\library.db"))
            {
                OldItems           = db.GetTracks().ToList();
                TracksCollection   = new GroupedObservableCollection <string, Mediafile>(t => t.Title, OldItems, t => t.Title);
                PlaylistCollection = new ThreadSafeObservableCollection <Playlist>(OldItems.SelectMany(t => t.Playlists).DistinctBy(t => t.Name).ToList());

                Options.Add(new ContextMenuCommand(AddToPlaylistCommand, "New Playlist"));
                foreach (var list in PlaylistCollection)
                {
                    var cmd = new ContextMenuCommand(AddToPlaylistCommand, list.Name);
                    Options.Add(cmd);
                    var Playlists = new Dictionary <Playlist, IEnumerable <Mediafile> >();
                    Playlists.Add(list, db.PlaylistSort(list.Name));
                    ShellVM.PlaylistsItems.Add(new SplitViewMenu.SimpleNavMenuItem
                    {
                        Arguments       = Playlists,
                        Label           = list.Name,
                        DestinationPage = typeof(PlaylistView),
                        Symbol          = Symbol.List
                    });
                    GC.Collect();
                }
            }
            else
            {
                PlaylistCollection = new ThreadSafeObservableCollection <Playlist>();
            }
        }
Example #3
0
        private static void InitGroup(ListView lst, string value)
        {
            var originalSource = lst.GetValue(OriginalItemsSourceProperty);

            if (originalSource == null)
            {
                originalSource = lst.ItemsSource;
                lst.SetValue(OriginalItemsSourceProperty, originalSource);
            }

#if __WPF__
            var view = CollectionViewSource.GetDefaultView(originalSource);
            view.GroupDescriptions.Add(new PropertyGroupDescription(value));
#else
            var view   = new CollectionViewSource();
            var source = new GroupedObservableCollection <object, object>(x => x.GetType().GetProperty(value).GetValue(x));
            foreach (var x in (IEnumerable)originalSource)
            {
                source.Add(x);
            }
            view.IsSourceGrouped = true;
            view.Source          = source;
#endif
            //var view = (CollectionView)CollectionViewSource.GetDefaultView(this.ItemsSource);
            //view.GroupDescriptions.Add(new PropertyGroupDescription(GroupBy));
            lst.ItemsSource = view;
        }
Example #4
0
        internal async Task UpdateDocuments(IEnumerable <string> filters = null)
        {
            var docs = DatabaseManager.Connection.Table <RdlnDocument>().ToList();

            if (filters != null && filters.Any())
            {
                docs = docs.Where(d => filters.Contains(d.Category)).ToList();
            }

            var group = Constants.GroupCategories.CATEGORY;

            try
            {
                group = await ApplicationData.Current.LocalFolder.ReadAsync <string>(Constants.Settings.ORDER).ConfigureAwait(true);

                Categories.Clear();
                var categories = DatabaseManager.Connection.Table <RdlnCategory>().ToList();
                foreach (var category in categories)
                {
                    Categories.Add(category.Name);
                }
            }
            finally
            {
                GroupedDocuments = GetGrouped(docs, group);

                RaisePropertyChanged(nameof(GroupedDocuments));
                RaisePropertyChanged(nameof(LibraryIsEmpty));
            }
        }
Example #5
0
 public async Task SplitList(GroupedObservableCollection <string, Mediafile> collection, int nSize = 30)
 {
     for (int i = 0; i < service.SongCount; i += nSize)
     {
         collection.AddRange(await service.GetRangeOfMediafiles(i, Math.Min(nSize, service.SongCount - i)).ConfigureAwait(false), false, false);
     }
 }
 public static IListenerRegistration Subscribe <TModel, TViewModel, TKey>(IQuery query,
                                                                          GroupedObservableCollection <TKey, TViewModel> viewModels,
                                                                          Func <TModel, TViewModel> getViewModel,
                                                                          Action?afterSnapshotProcessed = null)
     where TModel : BaseModel
     where TViewModel : CardViewModel <TModel>
 {
     viewModels.Clear();
     return(query.AddSnapshotListener((snapshot, ex) =>
     {
         if (snapshot is null)
         {
             viewModels.Clear();
         }
         else if (viewModels.Elements.Any())
         {
             foreach (var change in snapshot.DocumentChanges)
             {
                 var doc = change.Document;
                 if (change.Type == DocumentChangeType.Added)
                 {
                     viewModels.Add(getViewModel(doc.ToObject <TModel>() !));
                 }
                 else
                 {
                     var vm = viewModels.Elements.SingleOrDefault(x => x.UID == doc.Id);
                     if (vm is null)
                     {
                         return;
                     }
                     if (change.Type == DocumentChangeType.Modified)
                     {
                         var oldKey = viewModels.GroupKeySelector(vm);
                         var oldPriority = viewModels.PrioritySelector(vm);
                         vm.Update(change.Document.ToObject <TModel>() !);
                         var newKey = viewModels.GroupKeySelector(vm) !;
                         if (!newKey.Equals(oldKey))
                         {
                             viewModels.MoveGroup(vm, oldKey);
                         }
                         else if (oldPriority != viewModels.PrioritySelector(vm))
                         {
                             viewModels.UpdatePriority(vm);
                         }
                     }
                     else
                     {
                         viewModels.Remove(vm);
                     }
                 }
             }
         }
         else if (!snapshot.IsEmpty)
         {
             snapshot.Documents.ForEach(x => viewModels.Add(getViewModel(x.ToObject <TModel>() !)));
         }
         afterSnapshotProcessed?.Invoke();
     }));
 }
Example #7
0
 private void HandleMessage(Message message)
 {
     TracksCollection = message.Payload as GroupedObservableCollection <string, Mediafile>;
     if (TracksCollection != null)
     {
         message.HandledStatus = MessageHandledStatus.HandledContinue;
     }
 }
        public void Construction_WhenCalledWithNoInitialItems_ShouldAllowForSubsequentItemsToBeAdded()
        {
            var sut = new GroupedObservableCollection <char, string>(s => s[0]);

            Assert.That(sut.Count, Is.EqualTo(0));

            sut.Add("Hello");

            CollectionAssert.AreEqual(new[] { "Hello" }, sut.EnumerateItems());
        }
        public void Construction_WhenCalledWithInitialItems_ShouldPrePopulateCollection()
        {
            var sut = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);

            CollectionAssert.AreEqual(new[] { 'A', 'B', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(new[] { "Apple", "Banana", "Pear", "Pineapple" }, sut.EnumerateItems());
            CollectionAssert.AreEqual(new[] { "Apple" }, sut[0]);
            CollectionAssert.AreEqual(new[] { "Banana" }, sut[1]);
            CollectionAssert.AreEqual(new[] { "Pear", "Pineapple" }, sut[2]);
        }
        public void ReplaceWith_WhenReplacementIsIdentical_ShouldHaveNoEffect()
        {
            var sut            = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(smallListOfItems, sut.EnumerateItems());
        }
Example #11
0
 /// <summary>
 /// Refresh the view, based on filters and sorting mechanisms.
 /// </summary>
 public async void RefreshView(string genre = "All genres", string propName = "Title", bool doOrderFiles = true)
 {
     if (doOrderFiles)
     {
         Sort = propName;
         if (propName != "Unsorted")
         {
             if (files == null)
             {
                 files = TracksCollection.Elements;
             }
             grouped                    = true;
             TracksCollection           = new GroupedObservableCollection <string, Mediafile>(GetSortFunction(propName));
             ViewSource.Source          = TracksCollection;
             ViewSource.IsSourceGrouped = true;
             TracksCollection.AddRange(files, true, false);
             TracksCollection.CollectionChanged += TracksCollection_CollectionChanged1;
             if (propName == "Year")
             {
                 AlphabetList = TracksCollection.Keys.ToList();
             }
             else
             {
                 AlphabetList = "&#ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray().Select(x => x.ToString()).ToList();
             }
         }
         else
         {
             ViewSource.Source          = TracksCollection.Elements;
             ViewSource.IsSourceGrouped = false;
             grouped = false;
             Messenger.Instance.NotifyColleagues(MessageTypes.MSG_LIBRARY_LOADED, new List <object>()
             {
                 TracksCollection, grouped
             });
         }
     }
     else
     {
         Genre            = genre;
         TracksCollection = null;
         await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
         {
             TracksCollection = new GroupedObservableCollection <string, Mediafile>(t => t.Title);
             if (genre != "All genres")
             {
                 TracksCollection.AddRange(await LibraryService.Query("Genre", genre).ConfigureAwait(false), true);
             }
             else
             {
                 TracksCollection.AddRange(OldItems, true);
             }
         });
     }
 }
        public void ReplaceWith_WhenSoleItemInGroupMissingInNewSet_ShouldRemoveGroup()
        {
            var sut            = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems.Except(new[] { "Banana" }));

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { 'A', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(replacementSet.EnumerateItems(), sut.EnumerateItems());
        }
Example #13
0
        /// <summary>
        /// Refresh the view, based on filters and sorting mechanisms.
        /// </summary>
        public async Task RefreshView(string genre = "All genres", string propName = "Title", bool doOrderFiles = true)
        {
            if (doOrderFiles)
            {
                Sort = propName;
                if (propName != "Unsorted")
                {
                    await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
                    {
                        if (files == null)
                        {
                            files = TracksCollection.Elements;
                        }
                        grouped                    = true;
                        TracksCollection           = new GroupedObservableCollection <string, Mediafile>(GetSortFunction(propName));
                        ViewSource.Source          = TracksCollection;
                        ViewSource.IsSourceGrouped = true;
                        TracksCollection.AddRange(files, true, false);
                        TracksCollection.CollectionChanged += TracksCollection_CollectionChanged1;
                        UpdateJumplist(propName);

                        await RemoveDuplicateGroups();
                    });
                }
                else
                {
                    ViewSource.Source          = TracksCollection.Elements;
                    ViewSource.IsSourceGrouped = false;
                    grouped = false;
                    Messenger.Instance.NotifyColleagues(MessageTypes.MSG_LIBRARY_LOADED, new List <object>()
                    {
                        TracksCollection, grouped
                    });
                }
            }
            else
            {
                Genre            = genre;
                TracksCollection = null;
                await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
                {
                    TracksCollection = new GroupedObservableCollection <string, Mediafile>(t => t.Title);
                    if (genre != "All genres")
                    {
                        TracksCollection.AddRange(await LibraryService.Query("Genre", genre).ConfigureAwait(false), true);
                    }
                    else
                    {
                        TracksCollection.AddRange(OldItems, true);
                    }
                });
            }
        }
        public void ReplaceWith_NewItemAddedToEndOfExistingSet_ShouldBeAddedInCorrectPlace()
        {
            var sut            = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var newList        = new[] { "Potato", "Pineapple", "Plant", "Pear" };
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], newList);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { 'P' }, sut.Keys);
            CollectionAssert.AreEqual(newList, sut.EnumerateItems());
        }
        public void ReplaceWith_WhenSetCompletelyRestructured_ShouldResultInCorrectOrder()
        {
            var sut     = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var newList = smallListOfItems.ToList();

            newList.Insert(3, "Pzzz");
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], newList);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { 'A', 'B', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(newList, sut.EnumerateItems());
        }
        public void ReplaceWith_NewItemAddedToStartOfExistingSet_ShouldBeAddedInCorrectPlace()
        {
            var sut     = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var newList = smallListOfItems.ToList();

            newList.Insert(2, "Peach");
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], newList);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { 'A', 'B', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(newList, sut.EnumerateItems());
        }
Example #17
0
        private async void SetGroup(string order)
        {
            var currentOrder = await ApplicationData.Current.LocalFolder.ReadAsync <string>(Constants.Settings.ORDER).ConfigureAwait(true);

            if (currentOrder != order)
            {
                var documents = GroupedDocuments.EnumerateItems();
                GroupedDocuments = GetGrouped(documents, order);

                RaisePropertyChanged(nameof(GroupedDocuments));

                await ApplicationData.Current.LocalFolder.SaveAsync(Constants.Settings.ORDER, order).ConfigureAwait(false);
            }
        }
 /// <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;
     }
 }
        public void ReplaceWith_WhenNewGroupRequiredAtStartOfCurrentGroups_ShouldResultInNewGroup()
        {
            var sut     = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var newList = smallListOfItems.ToList();

            newList.Insert(0, "0number");
            newList.Insert(0, "0number2");
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], newList);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { '0', 'A', 'B', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(newList, sut.EnumerateItems());
        }
        public void ReplaceWith_WhenOrderOfItemsInGroupChanged_ShouldReflectChangeInOrder()
        {
            var sut     = new GroupedObservableCollection <char, string>(s => s[0], smallListOfItems);
            var newList = smallListOfItems.ToList();

            newList[2] = smallListOfItems[3];
            newList[3] = smallListOfItems[2];
            var replacementSet = new GroupedObservableCollection <char, string>(s => s[0], newList);

            var result = sut.ReplaceWith(replacementSet, StringComparer.OrdinalIgnoreCase);

            Assert.AreSame(sut, result);
            CollectionAssert.AreEqual(new[] { 'A', 'B', 'P' }, sut.Keys);
            CollectionAssert.AreEqual(replacementSet.EnumerateItems(), sut.EnumerateItems());
        }
 /// <summary>
 /// Refresh the view, based on filters and sorting mechanisms.
 /// </summary>
 public async void RefreshView(string genre = "All genres", string propName = "Title", bool doOrderFiles = true)
 {
     if (doOrderFiles)
     {
         Sort = propName;
         if (propName != "Unsorted")
         {
             if (files == null)
             {
                 files = TracksCollection.Elements;
             }
             TracksCollection           = new GroupedObservableCollection <string, Mediafile>(GetSortFunction(propName));
             ViewSource.Source          = TracksCollection;
             ViewSource.IsSourceGrouped = true;
             TracksCollection.AddRange(files, true, false);
             TracksCollection.CollectionChanged += TracksCollection_CollectionChanged1;
             grouped = true;
         }
         else
         {
             ViewSource.Source          = TracksCollection.Elements;
             ViewSource.IsSourceGrouped = false;
             grouped = false;
         }
     }
     else
     {
         Genre            = genre;
         TracksCollection = null;
         await Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
         {
             TracksCollection = new GroupedObservableCollection <string, Mediafile>(t => t.Title);
             if (genre != "All genres")
             {
                 TracksCollection.AddRange(await LibraryService.Query("Genre", genre).ConfigureAwait(false), true);
             }
             else
             {
                 TracksCollection.AddRange(OldItems, true);
             }
         });
     }
 }
Example #22
0
        /// <summary>
        /// Refresh the view, based on filters and sorting mechanisms.
        /// </summary>
        public async void RefreshView(string genre = "All genres", string propName = "Title", bool doOrderFiles = true)
        {
            IEnumerable <Mediafile> files = null;

            if (doOrderFiles)
            {
                if (propName != "Unsorted")
                {
                    files            = TracksCollection.Elements.Where(t => t.Path != "").OrderBy(t => GetPropValue(t, propName)).ToList();
                    TracksCollection = null;
                    TracksCollection = new GroupedObservableCollection <string, Mediafile>(t => propName == "Title" ? (GetPropValue(t, propName) as string).Remove(1).ToUpper() : (GetPropValue(t, propName) as string), files, a => a.Title.Remove(1).ToUpper());
                }
            }
            else
            {
                //FileCollection.Clear();
                //files = genre != "All genres" ? OldItems.Where(t => t.Genre == genre) : OldItems;
                //FileCollection.AddRange(files);
            }
        }
Example #23
0
        async Task LoadCollectionAsync(Func <Mediafile, string> sortFunc, bool group)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                TracksCollection = new GroupedObservableCollection <string, Mediafile>(sortFunc);
                TracksCollection.CollectionChanged += TracksCollection_CollectionChanged;

                if (group)
                {
                    ViewSource.Source = TracksCollection;
                }
                else
                {
                    ViewSource.Source = TracksCollection.Elements;
                }

                ViewSource.IsSourceGrouped = group;

                TracksCollection.AddRange(await Database.GetTracks().ConfigureAwait(false), true);
                grouped = group;
            });
        }
Example #24
0
        async Task LoadCollectionAsync(Func <Mediafile, string> sortFunc, bool group)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                grouped          = group;
                TracksCollection = new GroupedObservableCollection <string, Mediafile>(sortFunc);
                TracksCollection.CollectionChanged += TracksCollection_CollectionChanged;

                SongCount = LibraryService.SongCount;
                if (group)
                {
                    ViewSource.Source = TracksCollection;
                }
                else
                {
                    ViewSource.Source = TracksCollection.Elements;
                }

                ViewSource.IsSourceGrouped = group;
                await SplitList(TracksCollection, 300).ConfigureAwait(false);
            });
        }
        async Task LoadCollectionAsync(Func <Mediafile, string> sortFunc, bool group)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
            {
                TracksCollection = new GroupedObservableCollection <string, Mediafile>(sortFunc);
                TracksCollection.CollectionChanged += TracksCollection_CollectionChanged;
                Messenger.Instance.NotifyColleagues(MessageTypes.MSG_LIBRARY_LOADED, TracksCollection);

                if (group)
                {
                    ViewSource.Source = TracksCollection;
                }
                else
                {
                    ViewSource.Source = TracksCollection.Elements;
                }

                ViewSource.IsSourceGrouped = group;

                TracksCollection.AddRange(await LibraryService.GetAllMediafiles().ConfigureAwait(false), true);
                grouped = group;
            });
        }
        private void ContactsAutoSuggestBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
        {
            GroupedObservableCollection <string, Contact> suggestions = new GroupedObservableCollection <string, Contact>(s => s.Name[0].ToString().ToUpper(), new List <Contact>());

            if (args.ChosenSuggestion != null)
            {
                // User selected an item from the suggestion list, take an action on it here.
                foreach (var item in DataService.Instance.Contacts.Where(c => c.Name.Contains(args.ChosenSuggestion.ToString())))
                {
                    suggestions.Add(item);
                }
            }
            else
            {
                // Use args.QueryText to determine what to do.
                // User selected an item from the suggestion list, take an action on it here.
                foreach (var item in DataService.Instance.Contacts.Where(c => c.Name.Contains(args.QueryText)))
                {
                    suggestions.Add(item);
                }
            }
            ContactsGroupedSource.Source = suggestions;
        }
        public RootHost()
        {
            InitializeComponent();

            isPageInSplitMode = true;
            ////ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar;
            ////formattableTitleBar.ButtonBackgroundColor = Colors.Transparent;
            ////formattableTitleBar.ButtonForegroundColor = Colors.Gray;

            CoreApplicationViewTitleBar coreTitleBar = CoreApplication.GetCurrentView().TitleBar;

            coreTitleBar.ExtendViewIntoTitleBar = false;

            SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            SystemNavigationManager.GetForCurrentView().BackRequested += RootHost_BackRequested;

            SizeChanged += RootHost_SizeChanged;

            ContactsGrouped = new GroupedObservableCollection <char, Contact>(s => s.Name != null && s.Name.Count() > 0 ? s.Name[0] : ' ', DataService.Instance.Contacts);
            ContactsGroupedSource.Source = ContactsGrouped;

            DataService.Instance.Contacts.ContactsAdded   += Contacts_ContactsAdded;
            DataService.Instance.Contacts.ContactsRemoved += Contacts_ContactsRemoved;

            rootframe.Navigated += Rootframe_Navigated;


            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                if (ApiInformation.IsEventPresent(typeof(HardwareButtons).FullName, "BackPressed"))
                {
                    HardwareButtons.BackPressed += HardwareButtons_BackPressed;
                }
            }

            InitialNavigation();
        }
Example #28
0
        private async void He_KeyUp(object sender, KeyRoutedEventArgs e)
        {
            await Task.Run(async() =>
            {
                await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    if (He.Text.Length > 0)
                    {
                        var list = LibVM.LibVM.OldItems.Where(w => w.Title.ToUpper().Contains(He.Text.ToUpper())).ToList();
                        var col  = new GroupedObservableCollection <string, Mediafile>(t => t.Title.Remove(1), list, a => a.Title.Remove(1));
                        LibVM.LibVM.TracksCollection = null;
                        LibVM.LibVM.TracksCollection = col;
                    }
                    else
                    {
                        var col = new GroupedObservableCollection <string, Mediafile>(t => t.Title.Remove(1), LibVM.LibVM.OldItems, a => a.Title.Remove(1));
                        LibVM.LibVM.TracksCollection = null;
                        LibVM.LibVM.TracksCollection = col;

                        GC.Collect();
                    }
                });
            });
        }
Example #29
0
 public static Grouping <IGroupKey, Mediafile> GetNextGroup(this GroupedObservableCollection <IGroupKey, Mediafile> collection)
 {
     return(collection?.ElementAt(GetCurrentlyPlayingGroupIndex(collection) + 1));
 }
Example #30
0
 public static int GetCurrentlyPlayingGroupIndex(this GroupedObservableCollection <IGroupKey, Mediafile> collection)
 {
     return(collection?.IndexOf(GetCurrentlyPlayingGroup(collection)) ?? 0);
 }