/// <summary> /// Builds a kanji details ViewModel handling the given kanji. /// </summary> /// <param name="kanjiEntity">Kanji to handle.</param> public KanjiDetailsViewModel(ExtendedKanji kanjiEntity) { KanjiEntity = kanjiEntity; if (KanjiEntity.DbKanji.SrsEntries.Any()) { SrsEntry = new ExtendedSrsEntry( KanjiEntity.DbKanji.SrsEntries.First()); } VocabFilter filter = new VocabFilter() { Kanji = new KanjiEntity[] { _kanjiEntity.DbKanji } }; VocabListVm = new VocabListViewModel(filter); VocabListVm.KanjiNavigated += OnKanjiNavigated; VocabFilterVm = new VocabFilterViewModel(filter); VocabFilterVm.FilterChanged += OnVocabFilterChanged; ToggleDetailsCommand = new RelayCommand(OnToggleDetails); AddToSrsCommand = new RelayCommand(OnAddToSrs); EditSrsEntryCommand = new RelayCommand(OnEditSrsEntry); FilterReadingCommand = new RelayCommand <string>(OnFilterReading); NextStrokeCommand = new RelayCommand(OnNextStroke); PreviousStrokeCommand = new RelayCommand(OnPreviousStroke); LastStrokeCommand = new RelayCommand(OnLastStroke); FirstStrokeCommand = new RelayCommand(OnFirstStroke); WaniKaniCommand = new RelayCommand(OnWaniKani); PrepareSvg(); }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(null); } ExtendedKanji kanji = value as ExtendedKanji; if (kanji == null) { throw new ArgumentException("Value must be ExtendedKanji."); } List <object> results = new List <object>(); if (!string.IsNullOrWhiteSpace(kanji.DbKanji.OnYomi)) { results.Add(new KanjiReadingLabel() { Label = "On'yomi" }); results.AddRange(GetReadingList(kanji.DbKanji.OnYomi, Properties.Settings.Default.OnYomiReadingType)); } if (!string.IsNullOrWhiteSpace(kanji.DbKanji.KunYomi)) { results.Add(new KanjiReadingLabel() { Label = "Kun'yomi" }); results.AddRange(GetReadingList(kanji.DbKanji.KunYomi, Properties.Settings.Default.KunYomiReadingType)); } if (!string.IsNullOrWhiteSpace(kanji.DbKanji.Nanori) && Properties.Settings.Default.ShowNanori) { results.Add(new KanjiReadingLabel() { Label = "Nanori" }); results.AddRange(GetReadingList(kanji.DbKanji.Nanori, Properties.Settings.Default.NanoriReadingType)); } return(results); }