/// <summary> /// Displays the received results, discarding existing data. /// </summary> /// <param name="lookupId">ID of lookup whose results are shown. If ID is smaller than last seen value, we don't show results.</param> /// <param name="entryProvider">The entry provider; ownership passed by caller to me.</param> /// <param name="results">Cedict lookup results to show.</param> /// <param name="script">Defines which script(s) to show.</param> /// <returns>True if results got shown; false if they're discarded because newer results are already on display.</returns> public bool SetResults(int lookupId, ICedictEntryProvider entryProvider, ReadOnlyCollection <CedictResult> results, SearchScript script) { #if DEBUG // Make us crash at bottom if first result "柏林" (comes up for "bolin") if (results.Count > 0) { CedictEntry entry = entryProvider.GetEntry(results[0].EntryId); if (entry.ChSimpl == "柏林") { crashForTest = true; } else { crashForTest = false; } } #endif try { return(doSetResults(lookupId, entryProvider, results, script)); } finally { if (entryProvider != null) { entryProvider.Dispose(); } } }
private void renderAnnotation(HtmlTextWriter writer) { CedictEntry entry = prov.GetEntry(ann.EntryId); string entryClass = "entry"; if (tones == UiTones.Pleco) { entryClass += " toneColorsPleco"; } else if (tones == UiTones.Dummitt) { entryClass += " toneColorsDummitt"; } writer.AddAttribute(HtmlTextWriterAttribute.Class, entryClass); writer.RenderBeginTag(HtmlTextWriterTag.Div); // <div class="entry"> writer.AddAttribute(HtmlTextWriterAttribute.Class, "hw-ann"); writer.RenderBeginTag(HtmlTextWriterTag.Span); // <span class="hw-simp"> renderHanzi(query, entry, ann.StartInQuery, ann.LengthInQuery, writer); writer.RenderEndTag(); // <span class="hw-ann"> writer.AddAttribute(HtmlTextWriterAttribute.Class, "hw-pinyin"); writer.RenderBeginTag(HtmlTextWriterTag.Span); // <span class="hw-pinyin"> bool firstSyll = true; foreach (var pinyin in entry.Pinyin) { if (!firstSyll) { writer.WriteEncodedText(" "); } firstSyll = false; writer.WriteEncodedText(pinyin.GetDisplayString(true)); } writer.RenderEndTag(); // <span class="hw-pinyin"> writer.AddAttribute(HtmlTextWriterAttribute.Class, "senses"); writer.RenderBeginTag(HtmlTextWriterTag.Div); // <div class="senses"> for (int i = 0; i != entry.SenseCount; ++i) { renderSense(writer, entry.GetSenseAt(i), i, null); } writer.RenderEndTag(); // <div class="senses"> writer.RenderEndTag(); // <div class="entry"> }
/// <summary> /// Ctor: takes data to display. /// </summary> /// <param name="owner">Zen control that owns me.</param> /// <param name="tprov">Localized display text provider.</param> /// <param name="lookupThroughLink">Delegate to call when user initiates lookup by clicking on a link.</param> /// <param name="getEntry">Delegate to call when an entry must be retrieved (for "copy" context menu).</param> /// <param name="entryProvider">Dictionary entry provider.</param> /// <param name="cr">The lookup result this control will show.</param> /// <param name="maxHeadLength">Longest headword in full results list.</param> /// <param name="script">Scripts to show in headword.</param> /// <param name="odd">Odd/even position in list, for alternating BG color.</param> public OneResultControl(ZenControlBase owner, float scale, ITextProvider tprov, LookupThroughLinkDelegate lookupThroughLink, ParentPaintDelegate parentPaint, GetEntryDelegate getEntry, ICedictEntryProvider entryProvider, CedictResult cr, SearchScript script, bool last) : base(owner) { this.scale = scale; this.tprov = tprov; this.lookupThroughLink = lookupThroughLink; this.parentPaint = parentPaint; this.getEntry = getEntry; this.entry = entryProvider.GetEntry(cr.EntryId); this.res = cr; this.analyzedScript = script; this.last = last; padLeft = (int)(5.0F * scale); padTop = (int)(4.0F * scale); padBottom = (int)(8.0F * scale); padMid = (int)(20.0F * scale); padRight = (int)(10.0F * scale); }
/// <summary> /// Displays the received results, discarding existing data. /// </summary> /// <param name="lookupId">ID of lookup whose results are shown. If ID is smaller than last seen value, we don't show results.</param> /// <param name="entryProvider">The entry provider; ownership passed by caller to me.</param> /// <param name="results">Cedict lookup results to show.</param> /// <param name="script">Defines which script(s) to show.</param> /// <returns>True if results got shown; false if they're discarded because newer results are already on display.</returns> public bool SetResults(int lookupId, ICedictEntryProvider entryProvider, ReadOnlyCollection<CedictResult> results, SearchScript script) { #if DEBUG // Make us crash at bottom if first result "柏林" (comes up for "bolin") if (results.Count > 0) { CedictEntry entry = entryProvider.GetEntry(results[0].EntryId); if (entry.ChSimpl == "柏林") crashForTest = true; else crashForTest = false; } #endif try { return doSetResults(lookupId, entryProvider, results, script); } finally { if (entryProvider != null) entryProvider.Dispose(); } }