private void extendNewLimit(JsonObject deck) { deck["extendNew"] = JsonValue.CreateNumberValue(numberBox.Number); collection.Deck.Save(deck); collection.Sched.ExtendLimits(numberBox.Number, 0); CustomStudyCreateEvent?.Invoke(studyOption, currentDeckId, 0); }
private async Task CreateCustomStudy() { var deck = collection.Deck.Current(); if (HandleNotCreatingDynamicDeckCases(deck)) { return; } //Not like in java and python ver, we do nothing if no cards are available if (studyOption != CustomStudyOption.CramMode) { var max = int.Parse(chosenLabelValue.Text); if (max == 0) { return; } } customStudyFlyout.IsOpen = false; JsonObject dynamicDeck; long dynamicDeckId; var currentCustomDeck = collection.Deck.GetDeckByName(DEFAULT_DYN_DECKNAME); if (currentCustomDeck != null) { dynamicDeckId = (long)JsonHelper.GetNameNumber(currentCustomDeck, "id"); bool isDyn = collection.Deck.IsDyn(dynamicDeckId); if (!isDyn) { await UIHelper.ShowMessageDialog("Please rename the deck named \"" + DEFAULT_DYN_DECKNAME + "\" to another name first."); return; } else { collection.Sched.EmptyDyn(dynamicDeckId); dynamicDeck = currentCustomDeck; collection.Deck.Select(dynamicDeckId); } } else { dynamicDeckId = collection.Deck.NewDynamicDeck(DEFAULT_DYN_DECKNAME); dynamicDeck = collection.Deck.Get(dynamicDeckId); } ProgressDialog dialog = new ProgressDialog(); dialog.ProgressBarLabel = "Buidling custom study deck..."; dialog.ShowInDeterminateStateNoStopAsync("Custom Study"); CreateDynamicDeckConfigs(dynamicDeck, deck); var task = Task.Run(async() => { var cards = collection.Sched.RebuildDyn(); collection.SaveAndCommitAsync(); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (cards == null || cards.Count == 0) { await UIHelper.ShowMessageDialog(UIConst.WARN_CUSTOM_STUDY_NOCARDS_MATCH); } CustomStudyCreateEvent?.Invoke(studyOption, currentDeckId, dynamicDeckId); dialog.Hide(); }); }); }