public void format(myKanji kanji) { myWord word = kanji.relatedWords.Find((w) => { return(w.term == this.kanji); }); if (word == null) { word = new myWord { term = this.kanji, hn = hn, }; kanji.relatedWords.Add(word); } word.definitions.Add(new myDefinition { text = meaning, bFormated = true }); }
public void format(myKanji kanji) { myWord word = kanji.relatedWords.Find((w) => { return(w.term == this.word); }); if (word == null) { word = new myWord { term = this.word, hn = this.hn, }; kanji.relatedWords.Add(word); } foreach (var d in def.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)) { word.definitions.Add(new myDefinition { text = d }); } }
void search(string txt) { var ret = dict.Search(txt); rtb.Blocks.Clear(); List <myWord> words = new List <myWord>(); Span s = new Span(); foreach (var kanji in ret) { Hyperlink hb = crtBlck(kanji.val); s.Inlines.Add(hb); var foundKanji = kanji.relatedWords.Find((w) => { return(w.term == kanji.val.ToString()); }); if (foundKanji != null) { s.Inlines.Add(crtDefBlck(foundKanji.definitions[0])); } else { s.Inlines.Add(new Run { Text = string.Format("({0}) stroke {1}, radical ", kanji.hn, kanji.totalStrokes) }); hb = crtBlck(kanji.radical.zRadical); s.Inlines.Add(hb); //s.Inlines.Add(new Run { Text = string.Format("({0}) ", kanji.radical.iRadical) }); var rdInfo = dict.Search(kanji.radical.zRadical.ToString()); if (rdInfo.Count > 0) { var k = rdInfo[0]; if (k.hn != "") { s.Inlines.Add(new Run { Text = string.Format("({0})", k.hn) }); } if (k.simple != '\0') { s.Inlines.Add(new Run { Text = string.Format(" simple {0}", k.simple) }); } } s.Inlines.Add(new Run { Text = ", meaning: " }); foreach (var def in kanji.definitions) { s.Inlines.Add(crtDefBlck(def)); break; } s.Inlines.Add(new LineBreak()); } words.AddRange(kanji.relatedWords); } s.Inlines.Add(new LineBreak()); //found word myWord found = null; if (ret.Count > 1) { found = words.Find((w) => { return(w.term == txt); }); } var sFound = new Span(); if (found != null) { s.Inlines.Add(crtWdBlck(found)); s.Inlines.Add(new LineBreak()); //remove from list words.Remove(found); } //related word if (found != null) { s.Inlines.Add(sFound); } //s.Inlines.Add(new Run { Text = "related word:" }); //s.Inlines.Add(new LineBreak()); int count = 0; foreach (var rWd in words) { if (txt.Contains(rWd.term)) { continue; } #if !show_brift if ((count++) == m_limitContentCnt) { break; } #else { s.Inlines.Add(crtWdBlck(rWd, true)); }