/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (IsDisposed) { return; } if (disposing) { if (components != null) { components.Dispose(); } foreach (RecordClerk clerk in m_recordClerks.Values) { // Take it out of the Mediator and Dispose it. m_propertyTable.RemoveProperty("RecordClerk-" + clerk.Id); clerk.Dispose(); } m_recordClerks.Clear(); m_configurationNodes.Clear(); } base.Dispose(disposing); m_wordform = null; m_cache = null; m_propertyTable.RemoveProperty("IgnoreStatusPanel"); m_mediator = null; m_propertyTable = null; m_configurationNode = null; m_currentBrowseView = null; m_specialSda = null; }
public void SetAndAccessMultiStrings() { ITsStrFactory tsf = TsStrFactoryClass.Create(); int kflid = XMLViewsDataCache.ktagEditColumnBase; int hvoRoot = 10578; int wsEng = Cache.WritingSystemFactory.GetWsFromStr("en"); XMLViewsDataCache xmlCache = new XMLViewsDataCache(Cache.MainCacheAccessor as ISilDataAccessManaged, true, new Dictionary <int, int>()); Notifiee recorder = new Notifiee(); xmlCache.AddNotification(recorder); Assert.AreEqual(0, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng).Length); Assert.AreEqual(0, recorder.Changes.Count); ITsString test1 = tsf.MakeString("test1", wsEng); xmlCache.CacheMultiString(hvoRoot, kflid, wsEng, test1); Assert.AreEqual(0, recorder.Changes.Count); Assert.AreEqual(test1, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng)); ITsString test2 = tsf.MakeString("blah", wsEng); xmlCache.SetMultiStringAlt(hvoRoot, kflid, wsEng, test2); Assert.AreEqual(test2, xmlCache.get_MultiStringAlt(hvoRoot, kflid, wsEng)); recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, kflid, wsEng, 0, 0) }, "expected PropChanged from setting string"); xmlCache.RemoveNotification(recorder); // Enhance JohnT: a better test would verify that it doesn't intefere with other multistrings, // and that it can store stuff independently for different HVOs, tags, and WSs. }
private void tvSource_AfterSelect(object sender, TreeViewEventArgs e) { using (new WaitCursor(this, true)) { // Swap out the browse view. if (m_currentBrowseView != null) { // Get rid of old one. m_currentBrowseView.Hide(); m_pnlConcBrowseHolder.Controls.Remove(m_currentBrowseView); m_currentBrowseView.Dispose(); m_currentBrowseView = null; } XmlNode configurationNode; RecordClerk clerk; var selObj = (IAnalysis)tvSource.SelectedNode.Tag; switch (selObj.ClassID) { default: throw new InvalidOperationException("Class not recognized."); case WfiWordformTags.kClassId: configurationNode = m_configurationNodes[WfiWordformTags.kClassId]; clerk = m_recordClerks[WfiWordformTags.kClassId]; break; case WfiAnalysisTags.kClassId: configurationNode = m_configurationNodes[WfiAnalysisTags.kClassId]; clerk = m_recordClerks[WfiAnalysisTags.kClassId]; break; case WfiGlossTags.kClassId: configurationNode = m_configurationNodes[WfiGlossTags.kClassId]; clerk = m_recordClerks[WfiGlossTags.kClassId]; break; } clerk.OwningObject = selObj; m_currentBrowseView = new RecordBrowseView(); m_currentBrowseView.Init(m_mediator, m_propertyTable, configurationNode); // Ensure that the list gets updated whenever it's reloaded. See LT-8661. var sPropName = clerk.Id + "_AlwaysRecomputeVirtualOnReloadList"; m_propertyTable.SetProperty(sPropName, true, false); m_propertyTable.SetPropertyPersistence(sPropName, false); m_currentBrowseView.Dock = DockStyle.Fill; m_pnlConcBrowseHolder.Controls.Add(m_currentBrowseView); m_currentBrowseView.CheckBoxChanged += m_currentBrowseView_CheckBoxChanged; m_currentBrowseView.BrowseViewer.SelectionChanged += BrowseViewer_SelectionChanged; m_currentBrowseView.BrowseViewer.FilterChanged += BrowseViewer_FilterChanged; SetRecordStatus(); m_specialSda = m_currentBrowseView.BrowseViewer.SpecialCache; var specialMdc = m_specialSda.MetaDataCache; int[] concordanceItems; switch (selObj.ClassID) { default: throw new InvalidOperationException("Class not recognized."); case WfiWordformTags.kClassId: m_currentSourceFakeFlid = specialMdc.GetFieldId2(WfiWordformTags.kClassId, "ExactOccurrences", false); concordanceItems = m_specialSda.VecProp(selObj.Hvo, m_currentSourceFakeFlid); break; case WfiAnalysisTags.kClassId: m_currentSourceFakeFlid = specialMdc.GetFieldId2(WfiAnalysisTags.kClassId, "ExactOccurrences", false); concordanceItems = m_specialSda.VecProp(selObj.Hvo, m_currentSourceFakeFlid); break; case WfiGlossTags.kClassId: m_currentSourceFakeFlid = specialMdc.GetFieldId2(WfiGlossTags.kClassId, "ExactOccurrences", false); concordanceItems = m_specialSda.VecProp(selObj.Hvo, m_currentSourceFakeFlid); break; } // (Re)set selected state in cache, so default behavior of checked is used. foreach (var concId in concordanceItems) { m_specialSda.SetInt(concId, XMLViewsDataCache.ktagItemSelected, 1); } // Set the initial value for the filtering status. var sFilterMsg = m_propertyTable.GetStringProperty("DialogFilterStatus", String.Empty); if (sFilterMsg != null) { sFilterMsg = sFilterMsg.Trim(); } SetFilterStatus(!String.IsNullOrEmpty(sFilterMsg)); CheckAssignBtnEnabling(); } }