/// <summary/> public void ShowSummaryDialog(IWin32Window owner, ITsString tssWf, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { CheckDisposed(); bool otherButtonClicked = false; using (SummaryDialogForm form = new SummaryDialogForm(this, tssWf, helpProvider, helpFileKey, styleSheet)) { form.ShowDialog(owner); if (form.ShouldLink) { form.LinkToLexicon(); } otherButtonClicked = form.OtherButtonClicked; } if (otherButtonClicked) { var entry = ShowFindEntryDialog(Object.Cache, Mediator, m_propertyTable, tssWf, owner); if (entry != null) { using (var leuiNew = new LexEntryUi(entry)) { leuiNew.ShowSummaryDialog(owner, entry.HeadWord, helpProvider, helpFileKey, styleSheet); } } else { // redisplay the original entry (recursively) ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet); } } }
private void m_btnLookup_Click(object sender, System.EventArgs e) { using (LexEntryUi leui = GetSelWord()) { if (leui == null) { ShowNotInDictMessage(this); return; } int[] domains; int[] lexrels; IVwCacheDa cdaTemp; if (!LoadDomainAndRelationInfo(m_cache, leui.Object.Hvo, out domains, out lexrels, out cdaTemp, this)) { return; } m_cdaTemp.ClearAllData(); // copy the names loaded into the even more temporary cda to the main one. foreach (int hvoDomain in domains) { m_cdaTemp.CacheStringProp(hvoDomain, RelatedWordsVc.ktagName, (cdaTemp as ISilDataAccess).get_StringProp(hvoDomain, RelatedWordsVc.ktagName)); } foreach (int hvoLexRel in lexrels) { m_cdaTemp.CacheStringProp(hvoLexRel, RelatedWordsVc.ktagName, (cdaTemp as ISilDataAccess).get_StringProp(hvoLexRel, RelatedWordsVc.ktagName)); } m_hvoEntry = leui.Object.Hvo; SetupForEntry(domains, lexrels); m_view.SetEntry(m_hvoEntry); } }
/// ------------------------------------------------------------ /// <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); } } }
public void FindEntryForWordform_EmptyString() { using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, TsStringUtils.EmptyString(Cache.DefaultVernWs))) { Assert.IsNull(lexEntryUi); } }
public void DisplayOrCreateEntry_EmptyString() { ITsStrBldr emptyString = TsStrBldrClass.Create(); Cache.MainCacheAccessor.SetString(1, 2, emptyString.GetString()); // We shouldn't get an exception if we call DisplayOrCreateEntry with an empty string LexEntryUi.DisplayOrCreateEntry(Cache, 1, 2, 3, 0, 0, null, null, null, null); }
public void FindEntryForWordform_EmptyString() { using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, Cache.TsStrFactory.MakeString(string.Empty, Cache.DefaultVernWs))) { Assert.IsNull(lexEntryUi); } }
internal static void DisplayEntries(FdoCache cache, IWin32Window owner, Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn) { ITsString tssWf = tssWfIn; List <int> rghvo = LexEntryUi.FindEntriesForWordform(cache, tssWf); // if we do not find a match for the word then try converting it to lowercase and see if there // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of // words which are capitalized at the beginning of sentences. LT-7444 RickM if (rghvo == null || rghvo.Count == 0) { //We need to be careful when converting to lowercase therefore use Icu.ToLower() //get the WS of the tsString int wsWf = StringUtils.GetWsAtOffset(tssWf, 0); //use that to get the locale for the WS, which is used for string wsLocale = cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsWf).IcuLocale; string sLower = Icu.ToLower(tssWf.Text, wsLocale); ITsTextProps ttp = tssWf.get_PropertiesAt(0); ITsStrFactory tsf = TsStrFactoryClass.Create(); tssWf = tsf.MakeStringWithPropsRgch(sLower, sLower.Length, ttp); rghvo = LexEntryUi.FindEntriesForWordform(cache, tssWf); } StringTable stOrig; Mediator mediator; IVwStylesheet styleSheet; bool fRestore = EnsureFlexTypeSetup(cache, mediatorIn, out stOrig, out mediator, out styleSheet); if (rghvo == null || rghvo.Count == 0) { int hvoLe = ShowFindEntryDialog(cache, mediator, tssWf, owner); if (hvoLe == 0) { // Restore the original string table in the mediator if needed. if (fRestore) { mediator.StringTbl = stOrig; } return; } rghvo = new List <int>(1); rghvo.Add(hvoLe); } using (SummaryDialogForm form = new SummaryDialogForm(rghvo, tssWf, helpProvider, helpFileKey, styleSheet, cache, mediator)) { form.ShowDialog(owner); if (form.ShouldLink) { form.LinkToLexicon(); } } // Restore the original string table in the mediator if needed. if (fRestore) { mediator.StringTbl = stOrig; } }
/// ------------------------------------------------------------------------------------ /// <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); } } }
internal static void DisplayEntry(LcmCache cache, IWin32Window owner, Mediator mediator, PropertyTable propertyTable, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn) { ITsString tssWf = tssWfIn; LexEntryUi leui = null; try { leui = FindEntryForWordform(cache, tssWf); // if we do not find a match for the word then try converting it to lowercase and see if there // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of // words which are capitalized at the beginning of sentences. LT-7444 RickM if (leui == null) { //We need to be careful when converting to lowercase therefore use Icu.ToLower() //get the WS of the tsString int wsWf = TsStringUtils.GetWsAtOffset(tssWf, 0); //use that to get the locale for the WS, which is used for string wsLocale = cache.ServiceLocator.WritingSystemManager.Get(wsWf).IcuLocale; string sLower = Icu.UnicodeString.ToLower(tssWf.Text, wsLocale); ITsTextProps ttp = tssWf.get_PropertiesAt(0); tssWf = TsStringUtils.MakeString(sLower, ttp); leui = FindEntryForWordform(cache, tssWf); } EnsureWindowConfiguration(propertyTable); IVwStylesheet styleSheet = GetStyleSheet(cache, propertyTable); if (leui == null) { ILexEntry entry = ShowFindEntryDialog(cache, mediator, propertyTable, tssWf, owner); if (entry == null) { return; } leui = new LexEntryUi(entry); } if (mediator != null) { leui.Mediator = mediator; } if (propertyTable != null) { leui.PropTable = propertyTable; } leui.ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet); } finally { if (leui != null) { leui.Dispose(); } } }
private bool m_fShouldLink; // set true by btnLexicon_Click, caller should call LinkToLexicon after dialog closes. #endregion #region Constructor/destructor /// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for a single LexEntry object. /// </summary> /// <param name="leui"></param> /// <param name="wf"></param> /// <param name="helpProvider"></param> /// <param name="helpFileKey">string key to get the help file name</param> /// ------------------------------------------------------------------------------------ public SummaryDialogForm(LexEntryUi leui, ITsString tssForm, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { InitializeComponent(); m_rghvo = new List<int>(1); m_rghvo.Add(leui.Object.Hvo); m_cache = leui.Object.Cache; m_mediator = leui.Mediator; Initialize(tssForm, helpProvider, helpFileKey, styleSheet); }
private bool m_fShouldLink; // set true by btnLexicon_Click, caller should call LinkToLexicon after dialog closes. #endregion #region Constructor/destructor /// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for a single LexEntry object. /// </summary> /// <param name="leui"></param> /// <param name="wf"></param> /// <param name="helpProvider"></param> /// <param name="helpFileKey">string key to get the help file name</param> /// ------------------------------------------------------------------------------------ public SummaryDialogForm(LexEntryUi leui, ITsString tssForm, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { InitializeComponent(); m_rghvo = new List <int>(1); m_rghvo.Add(leui.Object.Hvo); m_cache = leui.Object.Cache; m_mediator = leui.Mediator; Initialize(tssForm, helpProvider, helpFileKey, styleSheet); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void btnOther_Click(object sender, System.EventArgs e) { int hvo = LexEntryUi.ShowFindEntryDialog(m_cache, m_mediator, m_tssWf, Owner); if (hvo != 0 && m_rghvo != null && !m_rghvo.Contains(hvo) && m_flidDummy != 0) { m_rghvo.Clear(); m_rghvo.Add(hvo); m_cache.VwCacheDaAccessor.CacheVecProp(m_cache.LangProject.LexDbOAHvo, m_flidDummy, m_rghvo.ToArray(), m_rghvo.Count); m_xv.RefreshDisplay(); } }
public void FindEntryNotMatchingCase() { // Setup var servLoc = Cache.ServiceLocator; var langProj = Cache.LangProject; var lexDb = langProj.LexDbOA; // Create a WfiWordform with some string. // We need this wordform to get a real hvo, flid, and ws. // Make Spanish be the vern ws. var spanish = servLoc.WritingSystemManager.Get("es"); langProj.AddToCurrentVernacularWritingSystems(spanish); langProj.CurAnalysisWss = "en"; langProj.DefaultVernacularWritingSystem = spanish; var defVernWs = spanish.Handle; var entry1 = servLoc.GetInstance <ILexEntryFactory>().Create( "Uppercaseword", "Uppercasegloss", new SandboxGenericMSA()); var entry2 = servLoc.GetInstance <ILexEntryFactory>().Create( "lowercaseword", "lowercasegloss", new SandboxGenericMSA()); // SUT // First make sure it works with the same case using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, TsStringUtils.MakeString("Uppercaseword", Cache.DefaultVernWs))) { Assert.IsNotNull(lexEntryUi); Assert.AreEqual(entry1.Hvo, lexEntryUi.Object.Hvo, "Found wrong object"); } using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, TsStringUtils.MakeString("lowercaseword", Cache.DefaultVernWs))) { Assert.IsNotNull(lexEntryUi); Assert.AreEqual(entry2.Hvo, lexEntryUi.Object.Hvo, "Found wrong object"); } // Now make sure it works with the wrong case using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, TsStringUtils.MakeString("uppercaseword", Cache.DefaultVernWs))) { Assert.IsNotNull(lexEntryUi); Assert.AreEqual(entry1.Hvo, lexEntryUi.Object.Hvo, "Found wrong object"); } using (var lexEntryUi = LexEntryUi.FindEntryForWordform(Cache, TsStringUtils.MakeString("LowerCASEword", Cache.DefaultVernWs))) { Assert.IsNotNull(lexEntryUi); Assert.AreEqual(entry2.Hvo, lexEntryUi.Object.Hvo, "Found wrong object"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ private void btnOther_Click(object sender, System.EventArgs e) { var entry = LexEntryUi.ShowFindEntryDialog(m_cache, m_mediator, m_tssWf, Owner); if (entry != null && m_rghvo != null && !m_rghvo.Contains(entry.Hvo)) { m_rghvo.Clear(); m_rghvo.Add(entry.Hvo); var sda = (ObjectListPublisher)m_xv.DecoratedDataAccess; sda.CacheVecProp(RootHvo, m_rghvo.ToArray()); } if (entry != null) { OtherResult = entry; } }
private void m_view_SelChanged(object sender, EventArgs e) { // Todo: create or update XmlView of selected word if any. using (LexEntryUi leui = GetSelWord()) { bool fEnable = m_view.GotRangeSelection && leui != null; m_btnCopy.Enabled = fEnable; m_btnInsert.Enabled = fEnable; m_btnLookup.Enabled = fEnable; if (leui == null) { return; } if (m_detailView == null) { // Give the detailView the bottom 1/3 of the available height. this.SuspendLayout(); int totalHeight = m_view.Height; m_view.Height = totalHeight * 2 / 3; m_detailView = MakeSummaryView(leui.Object.Hvo, m_cache, m_styleSheet, m_mediator); m_detailView.Left = m_view.Left; m_detailView.Width = m_view.Width; m_detailView.Top = m_view.Bottom + 5; m_detailView.Height = totalHeight / 3; m_detailView.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; m_detailView.EditingHelper.DefaultCursor = Cursors.Arrow; this.Controls.Add(m_detailView); this.ResumeLayout(); // JohnT: I'm not sure why this is needed here and not // elsewhere, but without it, the root box somehow never // receives an OnSizeChanged call and never actually // constructs. m_detailView.RootBox.Reconstruct(); } else { m_detailView.RootObjectHvo = leui.Object.Hvo; } } }
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)); }
public void DisplayOrCreateEntry_EmptyString() { // Create a WfiWordform with some string. // We need this wordform to get a real hvo, flid, and ws. // Make Spanish be the vern ws. LgWritingSystem spanish = Cache.GetObject(Cache.WritingSystemFactory.GetWsFromStr("es")) as LgWritingSystem; Cache.LanguageProject.VernWssRC.Add(spanish); Cache.LanguageProject.CurVernWssRS.Add(spanish); Cache.LanguageProject.CurAnalysisWssRS.Remove(spanish); Cache.LanguageProject.AnalysisWssRC.Remove(spanish); int defVernWs = spanish.Hvo; ITsString form = Cache.TsStrFactory.MakeString(String.Empty, defVernWs); WfiWordform wf = new WfiWordform(); Cache.LanguageProject.WordformInventoryOA.WordformsOC.Add(wf); wf.FormAccessor.set_String(defVernWs, form); // We shouldn't get an exception if we call DisplayOrCreateEntry with an empty string LexEntryUi.DisplayOrCreateEntry(Cache, wf.Hvo, (int)WfiWordform.WfiWordformTags.kflidForm, defVernWs, 0, 0, null, null, null, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// This method implements the FindInDictionary menu item. It is called using /// reflection by xCore, not directly. /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFindInDictionary(object args) { LexEntryUi.DisplayEntries(m_cache, Form.ActiveForm, m_mediator, null, null, ((IWfiWordform)Object).Form.get_String(m_cache.ServiceLocator.WritingSystems.DefaultVernacularWritingSystem.Handle), null); return(true); }
/// <summary/> public void ShowSummaryDialog(IWin32Window owner, ITsString tssWf, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { CheckDisposed(); bool otherButtonClicked = false; using (SummaryDialogForm form = new SummaryDialogForm(this, tssWf, helpProvider, helpFileKey, styleSheet)) { form.ShowDialog(owner); if (form.ShouldLink) form.LinkToLexicon(); otherButtonClicked = form.OtherButtonClicked; } if (otherButtonClicked) { var entry = ShowFindEntryDialog(this.Object.Cache, this.Mediator, tssWf, owner); if (entry != null) { using (var leuiNew = new LexEntryUi(entry)) { leuiNew.ShowSummaryDialog(owner, entry.HeadWord, helpProvider, helpFileKey, styleSheet); } } else { // redisplay the original entry (recursively) ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet); } } }
internal static void DisplayEntry(FdoCache cache, IWin32Window owner, Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn) { ITsString tssWf = tssWfIn; LexEntryUi leui = null; Mediator mediator = null; try { leui = FindEntryForWordform(cache, tssWf); // if we do not find a match for the word then try converting it to lowercase and see if there // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of // words which are capitalized at the beginning of sentences. LT-7444 RickM if (leui == null) { //We need to be careful when converting to lowercase therefore use Icu.ToLower() //get the WS of the tsString int wsWf = TsStringUtils.GetWsAtOffset(tssWf, 0); //use that to get the locale for the WS, which is used for string wsLocale = cache.ServiceLocator.WritingSystemManager.Get(wsWf).IcuLocale; string sLower = Icu.ToLower(tssWf.Text, wsLocale); ITsTextProps ttp = tssWf.get_PropertiesAt(0); tssWf = cache.TsStrFactory.MakeStringWithPropsRgch(sLower, sLower.Length, ttp); leui = FindEntryForWordform(cache, tssWf); } // Ensure that we have a valid mediator with the proper string table. bool fRestore; StringTable stOrig; mediator = EnsureValidMediator(mediatorIn, out fRestore, out stOrig); FdoCache cache2 = (FdoCache)mediator.PropertyTable.GetValue("cache"); if (cache2 != cache) mediator.PropertyTable.SetProperty("cache", cache); EnsureWindowConfiguration(mediator); IVwStylesheet styleSheet = GetStyleSheet(cache, mediator); if (leui == null) { ILexEntry entry = ShowFindEntryDialog(cache, mediator, tssWf, owner); if (entry == null) { // Restore the original string table in the mediator if needed. if (fRestore) mediator.StringTbl = stOrig; return; } leui = new LexEntryUi(entry); } if (mediator != null) leui.Mediator = mediator; leui.ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet); // Restore the original string table in the mediator if needed. if (fRestore) mediator.StringTbl = stOrig; } finally { if (leui != null) leui.Dispose(); if (mediator != mediatorIn) mediator.Dispose(); } }
internal static void DisplayEntry(FdoCache cache, IWin32Window owner, Mediator mediatorIn, IHelpTopicProvider helpProvider, string helpFileKey, ITsString tssWfIn) { ITsString tssWf = tssWfIn; LexEntryUi leui = null; Mediator mediator = null; try { leui = FindEntryForWordform(cache, tssWf); // if we do not find a match for the word then try converting it to lowercase and see if there // is an entry in the lexicon for the Wordform in lowercase. This is needed for occurences of // words which are capitalized at the beginning of sentences. LT-7444 RickM if (leui == null) { //We need to be careful when converting to lowercase therefore use Icu.ToLower() //get the WS of the tsString int wsWf = TsStringUtils.GetWsAtOffset(tssWf, 0); //use that to get the locale for the WS, which is used for string wsLocale = cache.ServiceLocator.WritingSystemManager.Get(wsWf).IcuLocale; string sLower = Icu.ToLower(tssWf.Text, wsLocale); ITsTextProps ttp = tssWf.get_PropertiesAt(0); tssWf = cache.TsStrFactory.MakeStringWithPropsRgch(sLower, sLower.Length, ttp); leui = FindEntryForWordform(cache, tssWf); } // Ensure that we have a valid mediator with the proper string table. bool fRestore; StringTable stOrig; mediator = EnsureValidMediator(mediatorIn, out fRestore, out stOrig); FdoCache cache2 = (FdoCache)mediator.PropertyTable.GetValue("cache"); if (cache2 != cache) { mediator.PropertyTable.SetProperty("cache", cache); } EnsureWindowConfiguration(mediator); IVwStylesheet styleSheet = GetStyleSheet(cache, mediator); if (leui == null) { ILexEntry entry = ShowFindEntryDialog(cache, mediator, tssWf, owner); if (entry == null) { // Restore the original string table in the mediator if needed. if (fRestore) { mediator.StringTbl = stOrig; } return; } leui = new LexEntryUi(entry); } if (mediator != null) { leui.Mediator = mediator; } leui.ShowSummaryDialog(owner, tssWf, helpProvider, helpFileKey, styleSheet); // Restore the original string table in the mediator if needed. if (fRestore) { mediator.StringTbl = stOrig; } } finally { if (leui != null) { leui.Dispose(); } if (mediator != mediatorIn) { mediator.Dispose(); } } }
public void FindEntryForWordform_EmptyString() { ITsStrBldr emptyString = TsStrBldrClass.Create(); Assert.IsNull(LexEntryUi.FindEntryForWordform(Cache, emptyString.GetString())); }
private static CmObjectUi MakeUi(FdoCache cache, int hvo, int clsid) { IFwMetaDataCache mdc = cache.DomainDataByFlid.MetaDataCache; // If we've encountered an object with this Clsid before, and this clsid isn't in // the switch below, the dictioanry will give us the appropriate clsid that IS in the // map, so the loop below will have only one iteration. Otherwise, we start the // search with the clsid of the object itself. int realClsid = m_subclasses.ContainsKey(clsid) ? m_subclasses[clsid] : clsid; // Each iteration investigates whether we have a CmObjectUi subclass that // corresponds to realClsid. If not, we move on to the base class of realClsid. // In this way, the CmObjectUi subclass we return is the one designed for the // closest base class of obj that has one. CmObjectUi result = null; while (result == null) { switch (realClsid) { // Todo: lots more useful cases. case WfiAnalysisTags.kClassId: result = new WfiAnalysisUi(); break; case PartOfSpeechTags.kClassId: result = new PartOfSpeechUi(); break; case CmPossibilityTags.kClassId: result = new CmPossibilityUi(); break; case CmObjectTags.kClassId: result = new CmObjectUi(); break; case LexPronunciationTags.kClassId: result = new LexPronunciationUi(); break; case LexSenseTags.kClassId: result = new LexSenseUi(); break; case LexEntryTags.kClassId: result = new LexEntryUi(); break; case MoMorphSynAnalysisTags.kClassId: result = new MoMorphSynAnalysisUi(); break; case MoStemMsaTags.kClassId: result = new MoStemMsaUi(); break; case MoDerivAffMsaTags.kClassId: result = new MoDerivAffMsaUi(); break; case MoInflAffMsaTags.kClassId: result = new MoInflAffMsaUi(); break; case MoAffixAllomorphTags.kClassId: case MoStemAllomorphTags.kClassId: result = new MoFormUi(); break; case ReversalIndexEntryTags.kClassId: result = new ReversalIndexEntryUi(); break; case WfiWordformTags.kClassId: result = new WfiWordformUi(); break; case WfiGlossTags.kClassId: result = new WfiGlossUi(); break; default: realClsid = mdc.GetBaseClsId(realClsid); // This isn't needed because CmObject.kClassId IS 0. // if (realClsid == 0) // { // // Somehow the class doesn't have CmObject in its inheritance path! // Debug.Assert(false); // // this may help make us more robust if this somehow happens. // realClsid = (uint)CmObject.kClassId; // } break; } } if (realClsid != clsid) m_subclasses[clsid] = realClsid; result.m_hvo = hvo; result.m_cache = cache; return result; }
/// ------------------------------------------------------------------------------------ /// <summary> /// This method implements the FindInDictionary menu item. It is called using /// reflection by xCore, not directly. /// </summary> /// <param name="args"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ protected bool OnFindInDictionary(object args) { LexEntryUi.DisplayEntries(m_cache, Form.ActiveForm, m_mediator, null, null, (this.Object as WfiWordform).Form.GetAlternativeTss(m_cache.DefaultVernWs)); return(true); }