/// <summary> /// Return a word selection based on the beginning of the current selection. /// Here the "beginning" of the selection is the offset corresponding to word order, /// not the selection anchor. /// </summary> /// <returns>null if we couldn't handle the selection</returns> private static IVwSelection SelectionBeginningGrowToWord(IVwSelection sel) { if (sel == null) return null; var sel2 = sel.EndBeforeAnchor ? sel.EndPoint(true) : sel.EndPoint(false); if (sel2 == null) return null; var sel3 = sel2.GrowToWord(); return sel3; }
public void FindInDictionary(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess, IVwSelection sel) { using (FdoCache cache = new FdoCache(ode, mdc, oleDbAccess)) { 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); // TODO (TimS): need to supply help information (last 2 params) LexEntryUi.DisplayOrCreateEntry(cache, hvo, tag, ws, ichMin, ichLim, null, null, null, string.Empty); return; } }
/// <summary> /// Return a word selection based on the beginning of the current selection. /// Here the "beginning" of the selection is the offset corresponding to word order, /// not the selection anchor. /// </summary> /// <returns>null if we couldn't handle the selection</returns> private static IVwSelection SelectionBeginningGrowToWord(IVwSelection sel) { if (sel == null) { return(null); } var sel2 = sel.EndBeforeAnchor ? sel.EndPoint(true) : sel.EndPoint(false); if (sel2 == null) { return(null); } var sel3 = sel2.GrowToWord(); return(sel3); }
/// <summary> /// Return a word selection based on the beginning of the current selection. /// Here the "beginning" of the selection is the offset corresponding to word order, /// not the selection anchor. /// </summary> /// <returns>null if we couldn't handle the selection</returns> private IVwSelection SelectionBeginningGrowToWord(IVwSelection sel) { if (sel == null) { return(null); } // REVISIT (EricP) Need to check if Ws is IsRightToLeft? var sel2 = sel.EndBeforeAnchor ? sel.EndPoint(true) : sel.EndPoint(false); if (sel2 == null) { return(null); } var sel3 = sel2.GrowToWord(); return(sel3); }
/// ------------------------------------------------------------------------------------ /// <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); } } }
private LexEntryUi GetSelWord() { IVwSelection sel = m_view.RootBox.Selection; if (sel == null) { return(null); } IVwSelection sel2 = sel.EndPoint(false); if (sel2 == null) { return(null); } IVwSelection sel3 = sel2.GrowToWord(); if (sel3 == null) { return(null); } 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); ITsString tssWf = (m_cdaTemp as ISilDataAccess).get_StringProp(hvo, tag); if (tssWf == null || tssWf.Length == 0) { return(null); } // Ignore what part of it is selected...we want the entry whose whole citation form // the selection is part of. //string wf = tssWf.Text.Substring(ichMin, ichLim - ichMin); return(LexEntryUi.FindEntryForWordform(m_cache, tssWf)); }
/// <summary> /// Returns true if there's anything to select. This is needed so that the toolbar /// button is disabled when there's nothing to select and look up. Otherwise, crashes /// can result when it's clicked but there's nothing there to process! It's misleading /// to the user if nothing else. It would be nice if the processing could be minimized, /// but this seems to be minimal. /// </summary> /// <returns>true</returns> public bool LexiconLookupEnabled() { CheckDisposed(); if (m_rootb == null) { return(false); } IVwSelection sel = m_rootb.Selection; if (sel == null) { return(false); } IVwSelection sel2 = sel.EndPoint(false); if (sel2 == null) { return(false); } IVwSelection sel3 = sel2.GrowToWord(); if (sel3 == null) { return(false); } ITsString tss; int ichLim, hvo, tag, ws; bool fAssocPrev; sel3.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws); if (ichLim == 0) { return(false); } // We're not disqualified, so we must be enabled! return(true); }
public void FindInDictionary(IOleDbEncap ode, IFwMetaDataCache mdc, IVwOleDbDa oleDbAccess, IVwSelection sel) { using (FdoCache cache = new FdoCache(ode, mdc, oleDbAccess)) { 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); // TODO (TimS): need to supply help information (last 2 params) LexEntryUi.DisplayOrCreateEntry(cache, hvo, tag, ws, ichMin, ichLim, null, null, null, string.Empty); return; } }
/// <summary> /// Return a word selection based on the beginning of the current selection. /// Here the "beginning" of the selection is the offset corresponding to word order, /// not the selection anchor. /// </summary> /// <returns>null if we couldn't handle the selection</returns> private IVwSelection SelectionBeginningGrowToWord(IVwSelection sel) { if (sel == null) return null; // REVISIT (EricP) Need to check if Ws is IsRightToLeft? var sel2 = sel.EndBeforeAnchor ? sel.EndPoint(true) : sel.EndPoint(false); if (sel2 == null) return null; var sel3 = sel2.GrowToWord(); return sel3; }
/// ------------------------------------------------------------------------------------ /// <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); 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; 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, mediatorIn, false)) { rw.ShowDialog(owner); } if (fRestore) mediator.StringTbl = stOrig; } }