/// <summary> /// Update collections in the navigation bar. /// </summary> public void UpdateCollections() { var list = (List <Collection>)DbOperator.GetCollections(); list.Reverse(); ViewModel.Collection = list; }
private static void InitLocalDb() { var defCol = DbOperator.GetCollections().Where(k => k.Locked); if (!defCol.Any()) { DbOperator.AddCollection("最喜爱的", true); } }
/// <summary> /// Popup a dialog for adding music to a collection. /// </summary> private void BtnLike_Click(object sender, RoutedEventArgs e) { if (!ValidateDb()) { return; } var entry = App.Beatmaps.GetBeatmapByIdentity(App.PlayerList.CurrentIdentity); //var entry = App.PlayerList?.CurrentInfo.Entry; if (entry == null) { MsgBox.Show(this, "该图不存在于该osu!db中。", Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (!ViewModel.IsMiniMode) { FramePop.Navigate(new SelectCollectionPage(this, entry)); } else { var collection = DbOperator.GetCollections().First(k => k.Locked); if (App.PlayerList.CurrentInfo.IsFaved) { DbOperator.RemoveMapFromCollection(entry, collection); App.PlayerList.CurrentInfo.IsFaved = false; } else { SelectCollectionPage.AddToCollection(collection, entry); App.PlayerList.CurrentInfo.IsFaved = true; } } SetFaved(App.PlayerList.CurrentInfo.Identity); }
public void RefreshList() { ViewModel.Collections = new ObservableCollection <CollectionViewModel>( CollectionViewModel.CopyFrom(DbOperator.GetCollections().OrderByDescending(k => k.CreateTime))); }