/// <summary/> protected virtual void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().ToString() + " *******"); if (fDisposing && !IsDisposed) { // Dispose managed resources here. if (m_PulldownArrowPic != null) { m_PulldownArrowPic.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. m_PulldownArrowPic = null; m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. m_tssMissingMorphs = null; m_tssEmptyAnalysis = null; m_tssEmptyVern = null; m_tssMissingMorphGloss = null; m_tssMissingMorphPos = null; IsDisposed = true; }
void VerifySelection(SandboxBase sandbox, bool fPicture, int tagText, int tagObj, int morphIndex) { Assert.That(sandbox.RootBox.Selection, Is.Not.Null); Assert.That(sandbox.MorphIndex, Is.EqualTo(morphIndex)); int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttpBogus; // Main array of information retrived from sel that made combo. SelLevInfo[] rgvsli; bool fIsPictureSel; // icon selected. IVwSelection sel = sandbox.RootBox.Selection; fIsPictureSel = sel.SelType == VwSelType.kstPicture; int cvsli = sel.CLevels(false) - 1; rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttpBogus); Assert.That(fIsPictureSel, Is.EqualTo(fPicture)); Assert.That(tagTextProp, Is.EqualTo(tagText)); if (tagTextProp == SandboxBase.ktagSbNamedObjName) { int tagObjProp = rgvsli[0].tag; Assert.That(tagObjProp, Is.EqualTo(tagObj)); } //sandbox.InterlinLineChoices. }
private SandboxBase.InterlinComboHandler GetComboHandler(SandboxBase sandbox, int flid, int morphIndex) { // first select the proper pull down icon. int tagIcon = 0; switch (flid) { case InterlinLineChoices.kflidMorphemes: tagIcon = SandboxBase.ktagMorphFormIcon; break; case InterlinLineChoices.kflidLexEntries: tagIcon = SandboxBase.ktagMorphEntryIcon; break; case InterlinLineChoices.kflidWordGloss: tagIcon = SandboxBase.ktagWordGlossIcon; break; case InterlinLineChoices.kflidWordPos: tagIcon = SandboxBase.ktagWordPosIcon; break; } return(SandboxBase.InterlinComboHandler.MakeCombo(null, tagIcon, sandbox, morphIndex) as SandboxBase.InterlinComboHandler); }
public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_cache = caches.MainCache; //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this. m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.DefaultAnalWs; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture); IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs); if (wsObj != null) { m_fRtl = wsObj.RightToLeftScript; } }
public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_cache = caches.MainCache; //prior to 9-20-2011 this was not set, if we find there was a reason get rid of this. m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.DefaultAnalWs; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = VwConstructorServices.ConvertImageToComPicture(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic.Picture); IWritingSystem wsObj = caches.MainCache.ServiceLocator.WritingSystemManager.Get(m_sandbox.RawWordformWs); if (wsObj != null) m_fRtl = wsObj.RightToLeftScript; }
private SandboxBase SetupSandbox(Func <AnalysisOccurrence> createDataForSandbox) { var occurrence = createDataForSandbox(); var lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs); var sandbox = new SandboxBase(Cache, null, null, lineChoices, occurrence.Analysis.Hvo); sandbox.MakeRoot(); return(sandbox); }
public void EntryHandler_NeedSelectSame_SelectSenseWhenAnalysisHasNoPos_ReturnsTrue() { // Make an entry with a morph and a sense with no MSA. var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); var morph = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = morph; morph.Form.SetVernacularDefaultWritingSystem("kick"); morph.MorphTypeRA = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot); var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.SetAnalysisDefaultWritingSystem("strike with foot"); // Make an analysis from that MSA. var wf = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); wf.Form.SetVernacularDefaultWritingSystem("kick"); var wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create(); wf.AnalysesOC.Add(wa); var mb = Cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create(); wa.MorphBundlesOS.Add(mb); mb.SenseRA = sense; mb.MorphRA = morph; // Make a sandbox and sut InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze); using (var sut = new SandboxBase.IhMissingEntry(null)) { using (var sandbox = new SandboxBase(Cache, m_mediator, m_propertyTable, null, lineChoices, wa.Hvo)) { sut.SetSandboxForTesting(sandbox); var mockList = MockRepository.GenerateMock <IComboList>(); sut.SetComboListForTesting(mockList); sut.SetMorphForTesting(0); sut.LoadMorphItems(); Assert.That(sut.NeedSelectSame(), Is.True); } // But if it already has an MSA it is not true. var msa = Cache.ServiceLocator.GetInstance <IMoStemMsaFactory>().Create(); entry.MorphoSyntaxAnalysesOC.Add(msa); sense.MorphoSyntaxAnalysisRA = msa; mb.MsaRA = msa; using (var sandbox = new SandboxBase(Cache, m_mediator, m_propertyTable, null, lineChoices, wa.Hvo)) { sut.SetSandboxForTesting(sandbox); Assert.That(sut.NeedSelectSame(), Is.False); } } }
public void ComboHandler_CreateCoreMorphItemBasedOnSandboxCurrentState_DeletedSense_DoesNotThrow() { // Make an entry with a morph and a sense with no MSA. var entry = Cache.ServiceLocator.GetInstance <ILexEntryFactory>().Create(); var morph = Cache.ServiceLocator.GetInstance <IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = morph; morph.Form.SetVernacularDefaultWritingSystem("kick"); morph.MorphTypeRA = Cache.ServiceLocator.GetInstance <IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot); // Set up first sense var sense = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.SetAnalysisDefaultWritingSystem("silly"); // Make an analysis from that MSA. var wf = Cache.ServiceLocator.GetInstance <IWfiWordformFactory>().Create(); wf.Form.SetVernacularDefaultWritingSystem("kick"); var wa = Cache.ServiceLocator.GetInstance <IWfiAnalysisFactory>().Create(); wf.AnalysesOC.Add(wa); var mb = Cache.ServiceLocator.GetInstance <IWfiMorphBundleFactory>().Create(); wa.MorphBundlesOS.Add(mb); mb.SenseRA = sense; mb.MorphRA = morph; // Set up second sense var sense2 = Cache.ServiceLocator.GetInstance <ILexSenseFactory>().Create(); entry.SensesOS.Add(sense2); sense2.Gloss.SetAnalysisDefaultWritingSystem("problem"); // Make a sandbox and sut InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze); using (var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo)) { var mockList = new MockComboHandler(); sandbox.m_ComboHandler = mockList; // Merge the first sense into the second (invalidating analysis and sandbox cache) using (var handler = GetComboHandler(sandbox, InterlinLineChoices.kflidLexEntries, 0)) { // wipe out the sense that the morph bundle was based on. sense2.MergeObject(sense, true); Assert.AreEqual(entry.SensesOS[0], sense2); Assert.DoesNotThrow(() => { // ReSharper disable once UnusedVariable - Assignment is SUT var i = handler.IndexOfCurrentItem; }); } } }
public void EntryHandler_NeedSelectSame_SelectSenseWhenAnalysisHasNoPos_ReturnsTrue() { // Make an entry with a morph and a sense with no MSA. var entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create(); var morph = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = morph; morph.Form.SetVernacularDefaultWritingSystem("kick"); morph.MorphTypeRA = Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot); var sense = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.SetAnalysisDefaultWritingSystem("strike with foot"); // Make an analysis from that MSA. var wf = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create(); wf.Form.SetVernacularDefaultWritingSystem("kick"); var wa = Cache.ServiceLocator.GetInstance<IWfiAnalysisFactory>().Create(); wf.AnalysesOC.Add(wa); var mb = Cache.ServiceLocator.GetInstance<IWfiMorphBundleFactory>().Create(); wa.MorphBundlesOS.Add(mb); mb.SenseRA = sense; mb.MorphRA = morph; // Make a sandbox and sut InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze); using (var sut = new SandboxBase.IhMissingEntry(null)) { using (var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo)) { sut.SetSandboxForTesting(sandbox); var mockList = MockRepository.GenerateMock<IComboList>(); sut.SetComboListForTesting(mockList); sut.SetMorphForTesting(0); sut.LoadMorphItems(); Assert.That(sut.NeedSelectSame(), Is.True); } // But if it already has an MSA it is not true. var msa = Cache.ServiceLocator.GetInstance<IMoStemMsaFactory>().Create(); entry.MorphoSyntaxAnalysesOC.Add(msa); sense.MorphoSyntaxAnalysisRA = msa; mb.MsaRA = msa; using (var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo)) { sut.SetSandboxForTesting(sandbox); Assert.That(sut.NeedSelectSame(), Is.False); } } }
int m_cchPrevMorphemes; // Total length of morphemes before m_imorph. public MorphemeBreaker(CachePair caches, string input, int hvoSbWord, int wsVern, SandboxBase sandbox) { m_caches = caches; m_sda = caches.DataAccess; m_cda = (IVwCacheDa)m_sda; m_input = input; m_hvoSbWord = hvoSbWord; m_cOldMorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); ITsStrFactory m_tsf = TsStrFactoryClass.Create(); m_wsVern = wsVern; m_types = m_caches.MainCache.ServiceLocator.GetInstance<IMoMorphTypeRepository>(); m_sandbox = sandbox; }
/// <summary> /// This contructor is only to be used by the /// </summary> /// <param name="owner"></param> /// <param name="caches"></param> /// <param name="choices"></param> /// <param name="anal"></param> public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices, WfiAnalysis anal) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo. //m_hvoWordform = hvoWordform; //m_hvoWfiAnalysis = hvoWfiAnalysis; m_anal = anal; //m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; //m_tssForm = tssForm; }
public GetRealAnalysisMethod(IHelpTopicProvider helpTopicProvider, SandboxBase owner, CachePair caches, int hvoSbWord, AnalysisTree oldAnalysis, IWfiAnalysis wa, IWfiGloss gloss, InterlinLineChoices choices, ITsString tssForm, bool fWantOnlyWfiAnalysis) : this() { m_helpTopicProvider = helpTopicProvider; m_sandbox = owner; m_caches = caches; m_hvoSbWord = hvoSbWord; m_oldAnalysis = oldAnalysis; m_wf = oldAnalysis.Wordform; m_wa = wa; m_wg = gloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; m_tssForm = tssForm; m_fWantOnlyWfiAnalysis = fWantOnlyWfiAnalysis; }
/// <summary> /// This contructor is only to be used by the /// </summary> /// <param name="owner"></param> /// <param name="caches"></param> /// <param name="choices"></param> /// <param name="anal"></param> public UpdateRealAnalysisMethod(SandboxBase owner, CachePair caches, InterlinLineChoices choices, IWfiAnalysis anal) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = kSbWord; // kSbWord really is a constant, not a real hvo. //m_hvoWordform = hvoWordform; //m_hvoWfiAnalysis = hvoWfiAnalysis; m_anal = anal; //m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; //m_tssForm = tssForm; var servLoc = m_caches.MainCache.ServiceLocator; m_moFormRepos = servLoc.GetInstance<IMoFormRepository>(); m_senseRepos = servLoc.GetInstance<ILexSenseRepository>(); m_msaRepos = servLoc.GetInstance<IMoMorphSynAnalysisRepository>(); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + " ******************"); // Must not be run more than once. if (m_isDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_combo != null) { m_combo.SelectedIndexChanged -= new EventHandler(m_combo_SelectedIndexChanged); FwComboBox combo = m_combo as FwComboBox; if (combo != null && combo.Parent == null) { combo.Dispose(); } else { ComboListBox clb = (m_combo as ComboListBox); if (clb != null) { clb.Dispose(); } } } } // Dispose unmanaged resources here, whether disposing is true or false. m_cache = null; m_owner = null; m_isDisposed = true; }
/// <summary> /// Change root of Sandbox or create it; Lay it out and figure its size; /// tell m_vc the size. /// </summary> /// <returns></returns> private void ChangeOrCreateSandbox(AnalysisOccurrence selected) { this.SuspendLayout(); panelSandbox.SuspendLayout(); if (InterlinDoc != null) { InterlinDoc.RecordGuessIfNotKnown(selected); } int color = (int)CmObjectUi.RGB(DefaultBackColor); //if this sandbox is presenting a wordform with multiple possible analyses then set the //bg color indicator if (selected.Analysis.Analysis == null && selected.Analysis.Wordform != null && SandboxBase.GetHasMultipleRelevantAnalyses(selected.Analysis.Wordform)) { color = InterlinVc.MultipleApprovedGuessColor; } if (m_sandbox == null) { m_sandbox = CreateNewSandbox(selected); m_sandbox.MultipleAnalysisColor = color; } else { //set the color before switching so that the color is correct when DisplayWordForm is called m_sandbox.MultipleAnalysisColor = color; m_sandbox.SwitchWord(selected); } UpdateButtonState(); // add the sandbox plus some padding. panelSandbox.ResumeLayout(); this.ResumeLayout(); SetSandboxSize(); }
/// -------------------------------------------------------------------------------- /// <summary> /// make a combo handler based upon the given comboIcon and morph /// </summary> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="tagComboIcon">The tag combo icon.</param> /// <param name="sandbox">The sandbox.</param> /// <param name="imorph">The index of the morph.</param> /// <returns></returns> /// -------------------------------------------------------------------------------- internal static IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider, int tagComboIcon, SandboxBase sandbox, int imorph) { int hvoSbMorph = sandbox.Caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, imorph); return MakeCombo(helpTopicProvider, tagComboIcon, sandbox, hvoSbMorph, null, 0); }
public UpdateMorphEntryAction(SandboxBase sandbox, int hvoMorph) { m_oldVals = new int[m_tags.Length]; m_newVals = new int[m_tags.Length]; m_sandbox = sandbox; m_sda = m_sandbox.Caches.DataAccess; m_originalAnalysis = m_sandbox.Analysis; m_hvoMorph = hvoMorph; for (int i = 0; i < m_tags.Length; i++ ) m_oldVals[i] = m_sda.get_ObjectProp(m_hvoMorph, m_tags[i]); }
// Call this to create the appropriate subclass and set up the combo and return it. // May return null if no appropriate combo can be created at the current position. // Caller should hide all combos before calling, then // call Activate to add the combo to its controls (thus making it visible) // or display the ComboListBox if a non-null value // is returned. static internal IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider, IVwSelection vwselNew, SandboxBase sandbox, bool fMouseDown) { // Figure what property is selected and create a suitable class if appropriate. int cvsli = vwselNew.CLevels(false); // CLevels includes the string property itself, but AllTextSelInfo doesn't need // it. cvsli--; // Out variables for AllTextSelInfo. int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttpBogus; // Main array of information retrived from sel that made combo. SelLevInfo[] rgvsli; // Analysis can now be zero (e.g., displaying alterate case form for non-existent WfiWordform) // and I don't believe it's a problem for the code below (JohnT). // if (sandbox.Analysis == 0) // { // // We aren't fully initialized yet, so don't do anything. // return null; // } if (cvsli < 0) return null; try { rgvsli = SelLevInfo.AllTextSelInfo(vwselNew, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttpBogus); } catch { // If anything goes wrong just give up. return null; } int hvoMorph = 0; int hvoSelObject = 0; if (tagTextProp >= ktagMinIcon && tagTextProp < ktagLimIcon) // its an icon { // If we're just hovering don't launch the pull-down. if (!fMouseDown) return null; if (rgvsli.Length >= 1) hvoMorph = hvoSelObject = rgvsli[0].hvo; return MakeCombo(helpTopicProvider, tagTextProp, sandbox, hvoMorph, rgvsli, hvoSelObject); } return null; }
protected override void DisposeUnmanagedResources() { // Dispose unmanaged resources here, whether disposing is true or false. m_rgvsli = null; m_caches = null; m_sandbox = null; m_rootb = null; m_items = null; m_comboList = null; }
private SandboxBase SetupSandbox(Func<AnalysisOccurrence> createDataForSandbox) { var occurrence = createDataForSandbox(); var lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs); var sandbox = new SandboxBase(Cache, null, null, lineChoices, occurrence.Analysis.Hvo); sandbox.MakeRoot(); return sandbox; }
internal SandboxEditMonitor(SandboxBase sandbox) { m_sandbox = sandbox; m_sda = sandbox.Caches.DataAccess; m_hvoSbWord = m_sandbox.RootWordHvo; m_sda.AddNotification(this); }
protected override void DisposeUnmanagedResources() { m_sda = null; m_sandbox = null; }
/// <summary> /// make a combo handler based upon the given comboIcon and morph /// </summary> /// <param name="tagComboIcon"></param> /// <param name="sandbox"></param> /// <param name="hvoMorph"></param> /// <returns></returns> public static IComboHandler MakeCombo(int tagComboIcon, SandboxBase sandbox, int hvoMorph) { return MakeCombo(tagComboIcon, sandbox, hvoMorph, null, 0); }
internal MorphManager(SandboxBase sandbox) { m_sandbox = sandbox; m_sda = sandbox.Caches.DataAccess; m_hvoSbWord = m_sandbox.RootWordHvo; m_sda.AddNotification(this); m_hasBeenAdded = true; }
/// <summary/> protected virtual void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().ToString() + " *******"); if (fDisposing && !IsDisposed) { // Dispose managed resources here. if (m_PulldownArrowPic != null) m_PulldownArrowPic.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. m_PulldownArrowPic = null; m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. m_tssMissingMorphs = null; m_tssEmptyAnalysis = null; m_tssEmptyVern = null; m_tssMissingMorphGloss = null; m_tssMissingMorphPos = null; IsDisposed = true; }
void VerifySelection(SandboxBase sandbox, bool fPicture, int tagText, int tagObj, int morphIndex) { Assert.That(sandbox.RootBox.Selection, Is.Not.Null); Assert.That(sandbox.MorphIndex, Is.EqualTo(morphIndex)); int ihvoRoot; int tagTextProp; int cpropPrevious; int ichAnchor; int ichEnd; int ws; bool fAssocPrev; int ihvoEnd; ITsTextProps ttpBogus; // Main array of information retrived from sel that made combo. SelLevInfo[] rgvsli; bool fIsPictureSel; // icon selected. IVwSelection sel = sandbox.RootBox.Selection; fIsPictureSel = sel.SelType == VwSelType.kstPicture; int cvsli = sel.CLevels(false) - 1; rgvsli = SelLevInfo.AllTextSelInfo(sel, cvsli, out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd, out ws, out fAssocPrev, out ihvoEnd, out ttpBogus); Assert.That(fIsPictureSel, Is.EqualTo(fPicture)); Assert.That(tagTextProp, Is.EqualTo(tagText)); if (tagTextProp == SandboxBase.ktagSbNamedObjName) { int tagObjProp = rgvsli[0].tag; Assert.That(tagObjProp, Is.EqualTo(tagObj)); } //sandbox.InterlinLineChoices. }
private static IComboHandler MakeCombo(IHelpTopicProvider helpTopicProvider, int tagComboIcon, SandboxBase sandbox, int hvoMorph, SelLevInfo[] rgvsli, int hvoSelObject) { IVwRootBox rootb = sandbox.RootBox; int hvoSbWord = sandbox.RootWordHvo; InterlinComboHandler handler = null; CachePair caches = sandbox.Caches; switch (tagComboIcon) { case ktagMorphFormIcon: handler = new IhMorphForm(); break; case ktagMorphEntryIcon: handler = new IhMorphEntry(helpTopicProvider); break; case ktagWordPosIcon: handler = new IhWordPos(); break; case ktagAnalysisIcon: ComboListBox clb2 = new ComboListBox(); clb2.StyleSheet = sandbox.StyleSheet; ChooseAnalysisHandler caHandler = new ChooseAnalysisHandler( caches.MainCache, hvoSbWord, sandbox.Analysis, clb2); caHandler.Owner = sandbox; caHandler.AnalysisChosen += new EventHandler( sandbox.Handle_AnalysisChosen); caHandler.SetupCombo(); return caHandler; case ktagWordGlossIcon: // line 6, word gloss. if (sandbox.ShouldAddWordGlossToLexicon) { if (hvoMorph == 0) { // setup the first hvoMorph hvoMorph = caches.DataAccess.get_VecItem(kSbWord, ktagSbWordMorphs, 0); } handler = new IhLexWordGloss(helpTopicProvider); } else { handler = new IhWordGloss(); } break; default: return null; } // Use the base class handler for most handlers. Override where needed. if (!(handler is IhWordPos)) { ComboListBox clb = new ComboListBox(); handler.m_comboList = clb; clb.SelectedIndexChanged += new EventHandler( handler.HandleComboSelChange); clb.SameItemSelected += new EventHandler( handler.HandleComboSelSame); // Since we may initialize with TsStrings, need to set WSF. handler.m_comboList.WritingSystemFactory = caches.MainCache.LanguageWritingSystemFactoryAccessor; } else { // REVIEW: Do we need to handle wsf for word POS combo? } handler.m_caches = caches; handler.m_hvoSelObject = hvoSelObject; handler.m_hvoSbWord = hvoSbWord; handler.m_hvoMorph = hvoMorph; handler.m_rgvsli = rgvsli; handler.m_rootb = rootb; handler.m_wsVern = sandbox.RawWordformWs; handler.m_wsAnal = caches.MainCache.DefaultAnalWs; handler.m_wsUser = caches.MainCache.DefaultUserWs; handler.m_sandbox = sandbox; handler.m_fUnderConstruction = true; handler.SetupCombo(); if (handler.m_comboList != null) handler.m_comboList.StyleSheet = sandbox.StyleSheet; handler.m_fUnderConstruction = false; return handler; }
internal IhMorphForm(SandboxBase sandbox) : base(sandbox) { }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_sandbox = null; // Client gave it to us, so has to deal with it. m_caches = null; // Client gave it to us, so has to deal with it. Marshal.ReleaseComObject(m_PulldownArrowPic); m_PulldownArrowPic = null; Marshal.ReleaseComObject(m_tsf); m_tsf = null; m_tssMissingEntry = null; // Same as m_tssMissingMorphs, so just null it. m_tssMissingWordPos = null; // Same as m_tssMissingMorphPos, so just null it. Marshal.ReleaseComObject(m_tssMissingMorphs); m_tssMissingMorphs = null; Marshal.ReleaseComObject(m_tssEmptyAnalysis); m_tssEmptyAnalysis = null; Marshal.ReleaseComObject(m_tssEmptyVern); m_tssEmptyVern = null; Marshal.ReleaseComObject(m_tssMissingMorphGloss); m_tssMissingMorphGloss = null; Marshal.ReleaseComObject(m_tssMissingMorphPos); m_tssMissingMorphPos = null; base.Dispose(disposing); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. if (m_comboList != null && (m_comboList is IDisposable) && (m_comboList as Control).Parent == null) (m_comboList as IDisposable).Dispose(); else if (m_comboList is ComboListBox) { // It typically has a parent, the special form used to display it, so will not // get disposed by the above, but we do want to dispose it. (m_comboList as IDisposable).Dispose(); } if (m_items != null) m_items.Clear(); // I've seen it contain ints or MorphItems. } // Dispose unmanaged resources here, whether disposing is true or false. m_rgvsli = null; m_caches = null; m_sandbox = null; m_rootb = null; m_items = null; m_comboList = null; m_isDisposed = true; }
internal InterlinComboHandler(SandboxBase sandbox) : this() { m_sandbox = sandbox; m_caches = sandbox.Caches; m_wsVern = m_sandbox.RawWordformWs; m_wsAnal = m_caches.MainCache.DefaultAnalWs; m_wsUser = m_caches.MainCache.DefaultUserWs; m_hvoSbWord = kSbWord; m_rootb = sandbox.RootBox; }
// only for testing internal void SetSandboxForTesting(SandboxBase sandbox) { m_sandbox = sandbox; m_caches = sandbox.Caches; m_wsVern = m_caches.MainCache.DefaultVernWs; }
private SandboxBase.InterlinComboHandler GetComboHandler(SandboxBase sandbox, int flid, int morphIndex) { // first select the proper pull down icon. int tagIcon = 0; switch (flid) { default: break; case InterlinLineChoices.kflidLexEntries: tagIcon = SandboxBase.ktagMorphEntryIcon; break; case InterlinLineChoices.kflidWordGloss: tagIcon = SandboxBase.ktagWordGlossIcon; break; case InterlinLineChoices.kflidWordPos: tagIcon = SandboxBase.ktagWordPosIcon; break; } return SandboxBase.InterlinComboHandler.MakeCombo(null, tagIcon, sandbox, morphIndex) as SandboxBase.InterlinComboHandler; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****************** Missing Dispose() call for " + GetType().Name + " ******************"); // Must not be run more than once. if (m_isDisposed) return; if (disposing) { // Dispose managed resources here. if (m_combo != null) { m_combo.SelectedIndexChanged -= new EventHandler(m_combo_SelectedIndexChanged); FwComboBox combo = m_combo as FwComboBox; if (combo != null && combo.Parent == null) combo.Dispose(); else { ComboListBox clb = (m_combo as ComboListBox); if (clb != null) clb.Dispose(); } } } // Dispose unmanaged resources here, whether disposing is true or false. m_cache = null; m_owner = null; m_isDisposed = true; }
int m_cchPrevMorphemes; // Total length of morphemes before m_imorph. public MorphemeBreaker(CachePair caches, string input, int hvoSbWord, int wsVern, SandboxBase sandbox) { m_caches = caches; m_sda = caches.DataAccess; m_cda = (IVwCacheDa)m_sda; m_input = input; m_hvoSbWord = hvoSbWord; m_cOldMorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); ITsStrFactory m_tsf = TsStrFactoryClass.Create(); m_wsVern = wsVern; m_types = new MoMorphTypeCollection(m_caches.MainCache); m_sandbox = sandbox; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; // m_sda COM object block removed due to crash in Finializer thread LT-6124 if (disposing) { // Dispose managed resources here. if (m_sda != null && m_hasBeenAdded) { m_sda.RemoveNotification(this); m_hasBeenAdded = false; } } // Dispose unmanaged resources here, whether disposing is true or false. m_sda = null; m_sandbox = null; m_isDisposed = true; }
public SandboxVc(CachePair caches, InterlinLineChoices choices, bool fIconsForAnalysisChoices, SandboxBase sandbox) { m_caches = caches; m_choices = choices; m_sandbox = sandbox; m_fIconsForAnalysisChoices = fIconsForAnalysisChoices; m_wsAnalysis = caches.MainCache.LangProject.DefaultAnalysisWritingSystem; m_wsUi = caches.MainCache.LanguageWritingSystemFactoryAccessor.UserWs; m_tssMissingMorphs = m_tsf.MakeString(ITextStrings.ksStars, m_sandbox.RawWordformWs); m_tssEmptyAnalysis = m_tsf.MakeString("", m_wsAnalysis); m_tssEmptyVern = m_tsf.MakeString("", m_sandbox.RawWordformWs); m_tssMissingEntry = m_tssMissingMorphs; // It's tempting to re-use m_tssMissingMorphs, but the analysis and vernacular default // fonts may have different sizes, requiring differnt line heights to align things well. m_tssMissingMorphGloss = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingMorphPos = m_tsf.MakeString(ITextStrings.ksStars, m_wsAnalysis); m_tssMissingWordPos = m_tssMissingMorphPos; m_PulldownArrowPic = (stdole.IPicture)OLECvt.ToOLE_IPictureDisp(ResourceHelper.InterlinPopupArrow); m_dxmpArrowPicWidth = ConvertPictureWidthToMillipoints(m_PulldownArrowPic); IWritingSystem wsObj = caches.MainCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_sandbox.RawWordformWs); if (wsObj != null) m_fRtl = wsObj.RightToLeft; }
public void ComboHandler_CreateCoreMorphItemBasedOnSandboxCurrentState_DeletedSense_DoesNotThrow() { // Make an entry with a morph and a sense with no MSA. var entry = Cache.ServiceLocator.GetInstance<ILexEntryFactory>().Create(); var morph = Cache.ServiceLocator.GetInstance<IMoStemAllomorphFactory>().Create(); entry.LexemeFormOA = morph; morph.Form.SetVernacularDefaultWritingSystem("kick"); morph.MorphTypeRA = Cache.ServiceLocator.GetInstance<IMoMorphTypeRepository>().GetObject(MoMorphTypeTags.kguidMorphRoot); // Set up first sense var sense = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); entry.SensesOS.Add(sense); sense.Gloss.SetAnalysisDefaultWritingSystem("silly"); // Make an analysis from that MSA. var wf = Cache.ServiceLocator.GetInstance<IWfiWordformFactory>().Create(); wf.Form.SetVernacularDefaultWritingSystem("kick"); var wa = Cache.ServiceLocator.GetInstance<IWfiAnalysisFactory>().Create(); wf.AnalysesOC.Add(wa); var mb = Cache.ServiceLocator.GetInstance<IWfiMorphBundleFactory>().Create(); wa.MorphBundlesOS.Add(mb); mb.SenseRA = sense; mb.MorphRA = morph; // Set up second sense var sense2 = Cache.ServiceLocator.GetInstance<ILexSenseFactory>().Create(); entry.SensesOS.Add(sense2); sense2.Gloss.SetAnalysisDefaultWritingSystem("problem"); // Make a sandbox and sut InterlinLineChoices lineChoices = InterlinLineChoices.DefaultChoices(Cache.LangProject, Cache.DefaultVernWs, Cache.DefaultAnalWs, InterlinLineChoices.InterlinMode.Analyze); using(var sandbox = new SandboxBase(Cache, null, null, lineChoices, wa.Hvo)) { var mockList = new MockComboHandler(); sandbox.m_ComboHandler = mockList; // Merge the first sense into the second (invalidating analysis and sandbox cache) using(var handler = GetComboHandler(sandbox, InterlinLineChoices.kflidLexEntries, 0)) { // wipe out the sense that the morph bundle was based on. sense2.MergeObject(sense, true); Assert.AreEqual(entry.SensesOS[0], sense2); Assert.DoesNotThrow(()=> { // ReSharper disable once UnusedVariable - Assignment is SUT var i = handler.IndexOfCurrentItem; }); } } }
public GetRealAnalysisMethod(SandboxBase owner, CachePair caches, int hvoSbWord, int hvoWordform, int hvoWfiAnalysis, int hvoWordGloss, InterlinLineChoices choices, ITsString tssForm, bool fWantOnlyWfiAnalysis) { m_sandbox = owner; m_caches = caches; m_hvoSbWord = hvoSbWord; m_hvoWordform = hvoWordform; m_hvoWfiAnalysis = hvoWfiAnalysis; m_hvoWordGloss = hvoWordGloss; m_sda = m_caches.DataAccess; m_sdaMain = m_caches.MainCache.MainCacheAccessor; m_cmorphs = m_sda.get_VecSize(m_hvoSbWord, ktagSbWordMorphs); m_choices = choices; m_tssForm = tssForm; m_fWantOnlyWfiAnalysis = fWantOnlyWfiAnalysis; }