/// <summary> /// Constructor. /// </summary> /// <param name="cache">FDO cache.</param> /// <param name="obj">CmObject that is being displayed.</param> /// <param name="flid">The field identifier for the attribute we are displaying.</param> public MSAReferenceComboBoxSlice(FdoCache cache, ICmObject obj, int flid, IPersistenceProvider persistenceProvider, Mediator mediator) : base(new UserControl(), cache, obj, flid) { m_mediator = mediator; m_persistProvider = persistenceProvider; m_tree = new TreeCombo(); m_tree.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor; m_tree.Font = new System.Drawing.Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10); if (!Application.RenderWithVisualStyles) m_tree.HasBorder = false; //Set the stylesheet and writing system information so that the font size for the IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator); m_tree.WritingSystemCode = cache.LangProject.DefaultAnalysisWritingSystem; m_tree.StyleSheet = stylesheet; // We embed the tree combo in a layer of UserControl, so it can have a fixed width // while the parent window control is, as usual, docked 'fill' to work with the splitter. m_tree.Dock = DockStyle.Left; m_tree.Width = 240; m_tree.DropDown += new EventHandler(m_tree_DropDown); Control.Controls.Add(m_tree); m_tree.SizeChanged += new EventHandler(m_tree_SizeChanged); if (m_MSAPopupTreeManager == null) { ICmPossibilityList list = m_cache.LangProject.PartsOfSpeechOA; int ws = m_cache.LangProject.DefaultAnalysisWritingSystem; m_tree.WritingSystemCode = ws; m_MSAPopupTreeManager = new MSAPopupTreeManager(m_tree, m_cache, list, ws, true, mediator, (Form)mediator.PropertyTable.GetValue("window")); m_MSAPopupTreeManager.AfterSelect += new TreeViewEventHandler(m_MSAPopupTreeManager_AfterSelect); m_MSAPopupTreeManager.Sense = m_obj as ILexSense; m_MSAPopupTreeManager.PersistenceProvider = m_persistProvider; } try { m_handlingMessage = true; m_MSAPopupTreeManager.MakeTargetMenuItem(); //m_MSAPopupTreeManager.LoadPopupTree(0); } finally { m_handlingMessage = false; } if (m_cache != null) { m_sda = m_cache.MainCacheAccessor; m_sda.AddNotification(this); } m_treeBaseWidth = m_tree.Width; Control.Height = m_tree.PreferredHeight; // m_tree has sensible PreferredHeight once the text is set, UserControl does not. //we need to set the Height after m_tree.Text has a value set to it. }
protected override void Dispose(bool disposing) { // Must not be run more than once. if (IsDisposed) return; // m_sda COM object block removed due to crash in Finializer thread LT-6124 if (disposing) { if (SplitCont != null && !SplitCont.IsDisposed && SplitCont.Panel2 != null && !SplitCont.Panel2.IsDisposed) { SplitCont.Panel2.SizeChanged -= new EventHandler(SplitContPanel2_SizeChanged); } // Dispose managed resources here. if (m_sda != null) m_sda.RemoveNotification(this); if (m_tree != null && m_tree.Parent == null) m_tree.Dispose(); if (m_MSAPopupTreeManager != null) { m_MSAPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_MSAPopupTreeManager_AfterSelect); m_MSAPopupTreeManager.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_sda = null; m_tree = null; m_MSAPopupTreeManager = null; m_persistProvider = null; base.Dispose(disposing); }