/// <summary>
        /// Command callback.
        /// Calls for the SRS item edition window to edit the SRS item
        /// referred by the current question.
        /// </summary>
        private void OnEditSrsEntry()
        {
            if (CurrentQuestion != null)
            {
                // Show the modal entry edition window.
                EditSrsEntryWindow wnd = new EditSrsEntryWindow(CurrentQuestionGroup.Reference.Clone());
                wnd.ShowDialog();

                // When it is closed, get the result.
                ExtendedSrsEntry result = wnd.Result;
                if (wnd.IsSaved)
                {
                    if (result != null
                        && result.NextAnswerDate.HasValue
                        && result.NextAnswerDate.Value.ToLocalTime() <= DateTime.Now
                        && !result.SuspensionDate.HasValue)
                    {
                        // The result exists and is still due for review.
                        // Update the current group.
                        CurrentQuestionGroup.Reference = result.Reference;
                        RaisePropertyChanged("CurrentQuestion");
                    }
                    else
                    {
                        // The result has been deleted or is no longer due
                        // for review. Remove the question group from the batch.
                        ReviewState = SrsReviewStateEnum.Ignore;
                        _currentBatch.Remove(CurrentQuestionGroup);
                        FillCurrentBatch();

                        AnsweredReviewsCount++;
                        ToNextQuestion();
                    }
                }
            }
        }
        /// <summary>
        /// Called when the AddToSrsCommand is fired.
        /// Opens the SRS entry window.
        /// </summary>
        private void OnAddToSrs()
        {
            // Prepare the new entry.
            SrsEntry entry = new SrsEntry();
            entry.LoadFromKanji(_kanjiEntity.DbKanji);

            // Show the modal entry edition window.
            EditSrsEntryWindow wnd = new EditSrsEntryWindow(entry);
            wnd.ShowDialog();

            // When it is closed, get the result.
            ExtendedSrsEntry result = wnd.Result;
            if (wnd.IsSaved && result != null
                && result.AssociatedKanji == _kanjiEntity.DbKanji.Character)
            {
                // The result exists and is still associated with this kanji.
                // We can use it in this ViewModel.
                SrsEntry = result;
            }
        }
        /// <summary>
        /// Called when the EditSrsEntryCommand is fired.
        /// Opens the SRS entry edition window.
        /// </summary>
        private void OnEditSrsEntry()
        {
            if (SrsEntry != null)
            {
                // Show the modal entry edition window.
                EditSrsEntryWindow wnd = new EditSrsEntryWindow(SrsEntry.Reference.Clone());
                wnd.ShowDialog();

                // When it is closed, get the result.
                ExtendedSrsEntry result = wnd.Result;
                if (wnd.IsSaved)
                {
                    if (result != null &&
                        result.AssociatedKanji == _kanjiEntity.DbKanji.Character)
                    {
                        // The result exists and is still associated with this kanji.
                        // We can use it in this ViewModel.
                        SrsEntry = result;
                    }
                    else
                    {
                        // The result has been saved but is no longer associated with
                        // this kanji. Set the value to null.
                        SrsEntry = null;
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Displays the SRS item edition window to allow the
        /// user to add a new kanji or vocab item to the SRS.
        /// </summary>
        /// <param name="isKanji">True to add a kanji item.
        /// False to add a vocab item.</param>
        private void AddSrsItem(bool isKanji)
        {
            // Prepare the new entry.
            SrsEntry entry = new SrsEntry();
            if (isKanji)
            {
                entry.AssociatedKanji = string.Empty;
            }
            else
            {
                entry.AssociatedVocab = string.Empty;
            }

            // Show the modal entry edition window.
            EditSrsEntryWindow wnd = new EditSrsEntryWindow(entry);
            wnd.ShowDialog();

            // When it is closed, get the result.
            ExtendedSrsEntry result = wnd.Result;
            if (wnd.IsSaved && result != null)
            {
                // The new element was added.
                // Refresh the dashboard.
                SrsBusiness.Instance.UpdateReviewInfoAsync();
            }
        }