示例#1
0
        /// <summary>
        /// Navigates to the kanji referred by the given character.
        /// Filters using the referred vocab kanji writing string.
        /// Writes a navigation history entry to trace back to the
        /// navigation state active before the operation.
        /// </summary>
        /// <param name="character">
        /// Character driving the navigation.</param>
        public void Navigate(KanjiWritingCharacter character)
        {
            if (KanjiDetailsVm != null)
            {
                // Temporarily unsubscribe the event.
                KanjiDetailsVm.KanjiNavigated -= OnKanjiNavigated;
            }

            // Add the current state to the navigation history.
            PushNavigationHistoryEntry();

            // Create a new filter matching the vocab word selected.
            _kanjiFilter = new KanjiFilter()
            {
                TextFilter = character.OriginalVocab.KanjiWriting,
                // Ignore the levels because not only are they irrelevant,
                // they might not even be the same for the kanji as for the vocab.
                JlptLevel = Levels.IgnoreJlptLevel,
                WkLevel   = Levels.IgnoreWkLevel
            };

            // Apply the filter
            KanjiFilterVm.SetFilter(_kanjiFilter);
            KanjiListVm.Navigate(_kanjiFilter, character.Kanji);

            // Create a new KanjiDetailsVm.
            // Do not use the SetKanjiDetailsVm method as to not dispose
            // the previous value.
            KanjiDetailsVm = new KanjiDetailsViewModel(new ExtendedKanji(character.Kanji));

            // Re-subscribe the event.
            KanjiDetailsVm.KanjiNavigated += OnKanjiNavigated;
        }
示例#2
0
        /// <summary>
        /// Sets a new value for the KanjiDetailsVm property, while
        /// making sure the previous value is correctly disposed
        /// and events correctly bound.
        /// </summary>
        /// <param name="value">New value.</param>
        private void SetKanjiDetailsVm(KanjiDetailsViewModel value)
        {
            if (value != _kanjiDetailsVm)
            {
                // Dispose the previously created VM if existing.
                if (_kanjiDetailsVm != null)
                {
                    _kanjiDetailsVm.KanjiNavigated -= OnKanjiNavigated;
                    _kanjiDetailsVm.Dispose();
                }

                // Set the value.
                KanjiDetailsVm = value;

                // Subscribe to the appropriate events if needed.
                if (_kanjiDetailsVm != null)
                {
                    _kanjiDetailsVm.KanjiNavigated += OnKanjiNavigated;
                }
            }
        }
        /// <summary>
        /// Sets a new value for the KanjiDetailsVm property, while
        /// making sure the previous value is correctly disposed
        /// and events correctly bound.
        /// </summary>
        /// <param name="value">New value.</param>
        private void SetKanjiDetailsVm(KanjiDetailsViewModel value)
        {
            if (value != _kanjiDetailsVm)
            {
                // Dispose the previously created VM if existing.
                if (_kanjiDetailsVm != null)
                {
                    _kanjiDetailsVm.KanjiNavigated -= OnKanjiNavigated;
                    _kanjiDetailsVm.Dispose();
                }

                // Set the value.
                KanjiDetailsVm = value;

                // Subscribe to the appropriate events if needed.
                if (_kanjiDetailsVm != null)
                {
                    _kanjiDetailsVm.KanjiNavigated += OnKanjiNavigated;
                }
            }
        }
        /// <summary>
        /// Navigates to the kanji referred by the given character.
        /// Filters using the referred vocab kanji writing string.
        /// Writes a navigation history entry to trace back to the
        /// navigation state active before the operation.
        /// </summary>
        /// <param name="character">
        /// Character driving the navigation.</param>
        public void Navigate(KanjiWritingCharacter character)
        {
            if (KanjiDetailsVm != null)
            {
                // Temporarily unsubscribe the event.
                KanjiDetailsVm.KanjiNavigated -= OnKanjiNavigated;
            }

            // Add the current state to the navigation history.
            PushNavigationHistoryEntry();

            // Create a new filter matching the vocab word selected.
            _kanjiFilter = new KanjiFilter()
            {
                TextFilter = character.OriginalVocab.KanjiWriting
            };

            // Apply the filter
            KanjiFilterVm.SetFilter(_kanjiFilter);
            KanjiListVm.Navigate(_kanjiFilter, character.Kanji);

            // Create a new KanjiDetailsVm.
            // Do not use the SetKanjiDetailsVm method as to not dispose
            // the previous value.
            KanjiDetailsVm = new KanjiDetailsViewModel(new ExtendedKanji(character.Kanji));

            // Re-subscribe the event.
            KanjiDetailsVm.KanjiNavigated += OnKanjiNavigated;
        }