/// ------------------------------------------------------------ /// <summary> /// Assuming the selection can be expanded to a word and a corresponding LexEntry can /// be found, show the related words dialog with the words related to the selected one. /// </summary> /// <param name="cache">The cache.</param> /// <param name="owner">The owning window.</param> /// <param name="mediator">The mediator.</param> /// <param name="propertyTable"></param> /// <param name="helpProvider">The help provider.</param> /// <param name="helpFileKey">The help file key.</param> /// <param name="tssWf">The ITsString for the word form.</param> /// <param name="hideInsertButton"></param> /// ------------------------------------------------------------ // Currently only called from WCF (11/21/2013 - AP) public static void DisplayRelatedEntries(LcmCache cache, IWin32Window owner, Mediator mediator, PropertyTable propertyTable, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWf, bool hideInsertButton) { if (tssWf == null || tssWf.Length == 0) { return; } using (LexEntryUi leui = FindEntryForWordform(cache, tssWf)) { // This doesn't work as well (unless we do a commit) because it may not see current typing. //LexEntryUi leui = LexEntryUi.FindEntryForWordform(cache, hvo, tag, ichMin, ichLim); if (leui == null) { RelatedWords.ShowNotInDictMessage(owner); return; } int hvoEntry = leui.Object.Hvo; int[] domains; int[] lexrels; IVwCacheDa cdaTemp; if (!RelatedWords.LoadDomainAndRelationInfo(cache, hvoEntry, out domains, out lexrels, out cdaTemp, owner)) { return; } IVwStylesheet styleSheet = GetStyleSheet(cache, propertyTable); using (RelatedWords rw = new RelatedWords(cache, null, hvoEntry, domains, lexrels, cdaTemp, styleSheet, mediator, hideInsertButton)) { rw.ShowDialog(owner); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Assuming the selection can be expanded to a word and a corresponding LexEntry can /// be found, show the related words dialog with the words related to the selected one. /// </summary> /// <param name="cache">The cache.</param> /// <param name="sel">The sel.</param> /// <param name="owner">The owner.</param> /// <param name="mediator"></param> /// <param name="propertyTable"></param> /// <param name="helpProvider"></param> /// <param name="helpFileKey"></param> /// ------------------------------------------------------------------------------------ public static void DisplayRelatedEntries(LcmCache cache, IVwSelection sel, IWin32Window owner, Mediator mediator, PropertyTable propertyTable, IHelpTopicProvider helpProvider, string helpFileKey) { if (sel == null) { return; } IVwSelection sel2 = sel.EndPoint(false); if (sel2 == null) { return; } IVwSelection sel3 = sel2.GrowToWord(); if (sel3 == null) { return; } ITsString tss; int ichMin, ichLim, hvo, tag, ws; bool fAssocPrev; sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws); sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws); if (tss.Text == null) { return; } ITsString tssWf = tss.GetSubstring(ichMin, ichLim); using (LexEntryUi leui = FindEntryForWordform(cache, tssWf)) { // This doesn't work as well (unless we do a commit) because it may not see current typing. //LexEntryUi leui = LexEntryUi.FindEntryForWordform(cache, hvo, tag, ichMin, ichLim); if (leui == null) { if (tssWf != null && tssWf.Length > 0) { RelatedWords.ShowNotInDictMessage(owner); } return; } int hvoEntry = leui.Object.Hvo; int[] domains; int[] lexrels; IVwCacheDa cdaTemp; if (!RelatedWords.LoadDomainAndRelationInfo(cache, hvoEntry, out domains, out lexrels, out cdaTemp, owner)) { return; } IVwStylesheet styleSheet = GetStyleSheet(cache, propertyTable); using (RelatedWords rw = new RelatedWords(cache, sel3, hvoEntry, domains, lexrels, cdaTemp, styleSheet, mediator, false)) { rw.ShowDialog(owner); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Assuming the selection can be expanded to a word and a corresponding LexEntry can /// be found, show the related words dialog with the words related to the selected one. /// </summary> /// <param name="cache">The cache.</param> /// <param name="sel">The sel.</param> /// <param name="owner">The owner.</param> /// <param name="mediatorIn"></param> /// <param name="helpProvider"></param> /// <param name="helpFileKey"></param> /// ------------------------------------------------------------------------------------ public static void DisplayRelatedEntries(FdoCache cache, IVwSelection sel, IWin32Window owner, Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey) { if (sel == null) return; IVwSelection sel2 = sel.EndPoint(false); if (sel2 == null) return; IVwSelection sel3 = sel2.GrowToWord(); if (sel3 == null) return; ITsString tss; int ichMin, ichLim, hvo, tag, ws; bool fAssocPrev; sel3.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws); sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws); if (tss.Text == null) return; ITsString tssWf = tss.GetSubstring(ichMin, ichLim); LexEntryUi leui = FindEntryForWordform(cache, tssWf); // This doesn't work as well (unless we do a commit) because it may not see current typing. //LexEntryUi leui = LexEntryUi.FindEntryForWordform(cache, hvo, tag, ichMin, ichLim); if (leui == null) { if (tssWf != null && tssWf.Length > 0) RelatedWords.ShowNotInDictMessage(owner); return; } int hvoEntry = leui.Object.Hvo; int[] domains; int[] lexrels; IVwCacheDa cdaTemp; if (!RelatedWords.LoadDomainAndRelationInfo(cache, hvoEntry, out domains, out lexrels, out cdaTemp, owner)) return; StringTable stOrig; Mediator mediator; IVwStylesheet styleSheet; bool fRestore = EnsureFlexTypeSetup(cache, mediatorIn, out stOrig, out mediator, out styleSheet); using (RelatedWords rw = new RelatedWords(cache, sel3, hvoEntry, domains, lexrels, cdaTemp, styleSheet)) { rw.ShowDialog(owner); } if (fRestore) mediator.StringTbl = stOrig; }