Ejemplo n.º 1
0
        /// <summary>
        /// Command callback.
        /// Called to open the SRS item edition window to add the
        /// calling vocab to the SRS.
        /// </summary>
        /// <param name="vocab">Calling vocab.</param>
        private void OnAddToSrs(ExtendedVocab vocab)
        {
            // Prepare the new entry.
            SrsEntry entry = new SrsEntry();

            entry.LoadFromVocab(vocab.DbVocab);

            // 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 &&
                ((!string.IsNullOrEmpty(vocab.DbVocab.KanjiWriting) &&
                  result.AssociatedVocab == vocab.DbVocab.KanjiWriting) ||
                 (string.IsNullOrEmpty(vocab.DbVocab.KanjiWriting) &&
                  result.AssociatedVocab == vocab.DbVocab.KanaWriting)))
            {
                // The result exists and is still associated with this kanji.
                // We can use it in this ViewModel.
                vocab.SrsEntry = result;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Command callback.
        /// Called to open the SRS item edition window to edit the
        /// SRS entry that matches the calling vocab.
        /// </summary>
        /// <param name="vocab">Calling vocab.</param>
        private void OnEditSrsEntry(ExtendedVocab vocab)
        {
            if (vocab.SrsEntry != null)
            {
                // Show the modal entry edition window.
                EditSrsEntryWindow wnd = new EditSrsEntryWindow(
                    vocab.SrsEntry.Reference.Clone());
                wnd.ShowDialog();

                // When it is closed, get the result.
                ExtendedSrsEntry result = wnd.Result;
                if (wnd.IsSaved)
                {
                    if (result != null && ((!string.IsNullOrEmpty(vocab.DbVocab.KanjiWriting) &&
                                            result.AssociatedVocab == vocab.DbVocab.KanjiWriting) ||
                                           (string.IsNullOrEmpty(vocab.DbVocab.KanjiWriting) &&
                                            result.AssociatedVocab == vocab.DbVocab.KanaWriting)))
                    {
                        // The result exists and is still associated with this kanji.
                        // We can use it in this ViewModel.
                        vocab.SrsEntry = result;
                    }
                    else
                    {
                        // The result has been saved but is no longer associated with
                        // this kanji. Set the value to null.
                        vocab.SrsEntry = null;
                    }
                }
            }
        }
Ejemplo n.º 3
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(NavigationActor.Instance.MainWindow);

            // 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();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Calls the SRS entry edition window to edit the
        /// given item.
        /// </summary>
        /// <param name="item">Item to edit.</param>
        private void EditSingleItem(FilteringSrsEntry item)
        {
            if (item != null)
            {
                // Show the modal entry edition window.
                EditSrsEntryWindow wnd = new EditSrsEntryWindow(item.Reference.Clone());
                wnd.ShowDialog();

                // When it is closed, get the result.
                ExtendedSrsEntry result = wnd.Result;
                if (wnd.IsSaved)
                {
                    if (result != null)
                    {
                        // Item edited.
                        item = new FilteringSrsEntry(result.Reference)
                        {
                            IsSelected = item.IsSelected
                        };
                    }

                    ReapplyFilter();
                }
            }
        }
Ejemplo n.º 5
0
        /// <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;
                    }
                }
            }
        }
        /// <summary>
        /// Command callback.
        /// Calls for the SRS item edition window to edit the SRS item
        /// referred by the current question.
        /// </summary>
        private async void OnEditSrsEntry()
        {
            if (CurrentQuestion != null)
            {
                // Show the modal entry edition window.
                EditSrsEntryWindow wnd = new EditSrsEntryWindow(CurrentQuestionGroup.Reference.Clone());
                await wnd.ShowDialog(NavigationActor.Instance.MainWindow);

                // 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);
                        if (!IsWrappingUp)
                        {
                            FillCurrentBatch();
                        }

                        AnsweredReviewsCount++;
                        ToNextQuestion();
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <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;
            }
        }