/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the related words to the specified entry using the application with the /// lexical data. /// </summary> /// ------------------------------------------------------------------------------------ public void ShowRelatedWords(string entry, EntryType entryType) { LexicalProviderManager.ResetLexicalProviderTimer(); Logger.WriteEvent("Showing related word from external application for the " + entryType + " " + entry); if (entryType != EntryType.Word) { throw new ArgumentException("Unknown entry type specified."); } // An asynchronous call is necessary because the WCF server (FieldWorks) will not // respond until this method returns. This also allows methods that show dialogs on the // WCF server to not be OneWay. (Otherwise, time-out exceptions occur.) FieldWorks.ThreadHelper.InvokeAsync(() => { ITsString tss = TsStringUtils.MakeTss(entry, FieldWorks.Cache.DefaultVernWs); Mediator mediator = new Mediator(); mediator.HelpTopicProvider = FieldWorks.GetHelpTopicProvider(FwUtils.ksFlexAbbrev); mediator.FeedbackInfoProvider = FieldWorks.GetOrCreateFlexApp(); mediator.PropertyTable.SetProperty("App", FieldWorks.GetOrCreateFlexApp()); LexEntryUi.DisplayRelatedEntries(FieldWorks.Cache, mediator, mediator.HelpTopicProvider, "UserHelpFile", tss); }); }
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; } }
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> /// Displays the specified entry using the application with the lexical data. /// </summary> /// ------------------------------------------------------------------------------------ public void ShowEntry(string entry, EntryType entryType) { LexicalProviderManager.ResetLexicalProviderTimer(); Logger.WriteEvent("Showing entry from external application for the " + entryType + " " + entry); if (entryType != EntryType.Word) { throw new ArgumentException("Unknown entry type specified."); } // An asynchronous call is necessary because the WCF server (FieldWorks) will not // respond until this method returns. This also allows methods that show dialogs on the // WCF server to not be OneWay. (Otherwise, time-out exceptions occur.) FieldWorks.ThreadHelper.InvokeAsync(() => { ITsString tss = TsStringUtils.MakeString(entry, FieldWorks.Cache.DefaultVernWs); using (Mediator mediator = new Mediator()) using (PropertyTable propertyTable = new PropertyTable(mediator)) { propertyTable.SetProperty("HelpTopicProvider", FieldWorks.GetHelpTopicProvider(), true); propertyTable.SetPropertyPersistence("HelpTopicProvider", false); var flexApp = FieldWorks.GetOrCreateFlexApp(); propertyTable.SetProperty("FeedbackInfoProvider", flexApp, true); propertyTable.SetPropertyPersistence("FeedbackInfoProvider", false); propertyTable.SetProperty("App", flexApp, true); LexEntryUi.DisplayEntry(FieldWorks.Cache, mediator, propertyTable, propertyTable.GetValue <IHelpTopicProvider>("HelpTopicProvider"), "UserHelpFile", tss, null); } }); }
/// <summary> /// Look up the selected wordform in the dictionary and display its lexical entry. /// </summary> /// <param name="argument"></param> public bool OnLexiconLookup(object argument) { CheckDisposed(); IVwSelection wordsel = SelectionBeginningGrowToWord(m_rootb.Selection); if (wordsel == null) { return(false); } ITsString tss; int ichMin, ichLim, hvo, tag, ws; bool fAssocPrev; wordsel.TextSelInfo(false, out tss, out ichMin, out fAssocPrev, out hvo, out tag, out ws); wordsel.TextSelInfo(true, out tss, out ichLim, out fAssocPrev, out hvo, out tag, out ws); if (ichLim > 0) { // TODO (TimS): need to provide help to the dialog (last 2 params) LexEntryUi.DisplayOrCreateEntry(m_fdoCache, hvo, tag, ws, ichMin, ichLim, this, m_mediator, FwApp.App, "UserHelpFile"); } // LexEntryUi leui = LexEntryUi.FindEntryForWordform(m_fdoCache, hvo, tag, ichMin, ichLim); // if (leui == null) // { // MessageBox.Show(this, "Sorry...could not find a matching entry in the lexicon"); // return false; // } // leui.ShowSummaryDialog(this); return(true); }
private bool m_fOtherClicked; // set true by btnOther_Click, caller should call OtherButtonClicked after dialog closes. #endregion #region Constructor/destructor /// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for a single LexEntry object. /// </summary> /// <param name="leui">The lex entry ui.</param> /// <param name="tssForm">The TSS form.</param> /// <param name="helpProvider">The help provider.</param> /// <param name="helpFileKey">string key to get the help file name</param> /// <param name="styleSheet">The stylesheet.</param> /// ------------------------------------------------------------------------------------ internal SummaryDialogForm(LexEntryUi leui, ITsString tssForm, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { InitializeComponent(); AccessibleName = GetType().Name; 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_fOtherClicked; // set true by btnOther_Click, caller should call OtherButtonClicked after dialog closes. #endregion #region Constructor/destructor /// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for a single LexEntry object. /// </summary> /// <param name="leui">The lex entry ui.</param> /// <param name="tssForm">The TSS form.</param> /// <param name="helpProvider">The help provider.</param> /// <param name="helpFileKey">string key to get the help file name</param> /// <param name="styleSheet">The stylesheet.</param> /// ------------------------------------------------------------------------------------ internal SummaryDialogForm(LexEntryUi leui, ITsString tssForm, IHelpTopicProvider helpProvider, string helpFileKey, IVwStylesheet styleSheet) { InitializeComponent(); AccessibleName = GetType().Name; 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> /// Look up the selected wordform in the dictionary and display its lexical entry. /// </summary> /// <param name="argument"></param> public bool OnLexiconLookup(object argument) { CheckDisposed(); int ichMin, ichLim, hvo, tag, ws; if (GetSelectedWordPos(m_rootb.Selection, out hvo, out tag, out ws, out ichMin, out ichLim)) { LexEntryUi.DisplayOrCreateEntry(m_fdoCache, hvo, tag, ws, ichMin, ichLim, this, m_mediator, m_mediator.HelpTopicProvider, "UserHelpFile"); } return(true); }
/// <summary> /// Look up the selected wordform in the dictionary and display its lexical entry. /// </summary> /// <param name="argument"></param> public bool OnLexiconLookup(object argument) { CheckDisposed(); int ichMin; int ichLim; int hvo; int tag; int ws; ITsString tss; GetWordLimitsOfSelection(out ichMin, out ichLim, out hvo, out tag, out ws, out tss); if (ichLim > ichMin) { LexEntryUi.DisplayOrCreateEntry(m_cache, hvo, tag, ws, ichMin, ichLim, this, m_mediator, m_mediator.HelpTopicProvider, "UserHelpFile"); return(true); } return(false); }
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)); }