public HiraganaCourseViewModel(Item item = null) { Title = item?.Text; Item = item; NextCommand = new Command(() => Next()); var temp = HiraganaCoursesData.Courses[Item.Id]; if (temp != null) { NextStep = temp.Next; foreach (var data in temp.Items) { Data.Add(data); } } if (Data.Count > 0) { DataCount = Data.Count; int index = new Random().Next(0, Data.Count - 1); CurrentItem = Data[index]; JapaneseCharacterText = CurrentItem.JapanCharacter; EnglishCharacterText = CurrentItem.EnglishCharacter; Data.Remove(CurrentItem); PlaySound(); } }
void Next() { if (IsBusy) { return; } IsBusy = true; LearnedCount++; if (LearnedCount > DataCount) { LearnedCount = DataCount; } float currentProgress = ((float)LearnedCount / (float)DataCount) * 100f; if (currentProgress > 100) { currentProgress = 100; } Progress = currentProgress / 100; ProgressText = ((int)currentProgress) + "%"; //TODO - Set has learned: CurrentItem if (Data.Count > 0) { int index = new Random().Next(0, Data.Count - 1); CurrentItem = Data[index]; JapaneseCharacterText = CurrentItem.JapanCharacter; EnglishCharacterText = CurrentItem.EnglishCharacter; Data.Remove(CurrentItem); PlaySound(); } else { Settings.SetHiraganaProgression(Item.Id, LearningProgression.Learned); if (!string.IsNullOrEmpty(NextStep)) { if (NextStep.StartsWith("Hiragana_Course_")) { //Course if (Settings.GetHiraganaProgression(NextStep) == LearningProgression.Locked) { Settings.SetHiraganaProgression(NextStep, LearningProgression.NotLearned); } } else { //Exam if (Settings.GetHiraganaExamProgression(NextStep) == ExamProgression.Locked) { Settings.SetHiraganaExamProgression(NextStep, ExamProgression.NotYetDone); } } } Settings.SaveSettings(); Audio.Manager.StopBackgroundMusic(); HiraganaListPage.Instance.RefreshList(); Page?.Close(); } IsBusy = false; }