public BulkPosEditorBase() { m_pOSPopupTreeManager = null; m_tree = new TreeCombo(); m_tree.TreeLoad += new EventHandler(m_tree_TreeLoad); // Handle AfterSelect event in m_tree_TreeLoad() through m_pOSPopupTreeManager }
/// <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_tree != null) { m_tree.Load -= new EventHandler(m_tree_TreeLoad); m_tree.Dispose(); } if (m_pOSPopupTreeManager != null) { m_pOSPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_pOSPopupTreeManager_AfterSelect); m_pOSPopupTreeManager.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_selectedLabel = null; m_tree = null; m_pOSPopupTreeManager = null; m_mediator = null; m_cache = null; m_isDisposed = true; }
private void m_tree_TreeLoad(object sender, EventArgs e) { if (m_pOSPopupTreeManager == null) { m_pOSPopupTreeManager = new POSPopupTreeManager(m_tree, m_cache, List, m_cache.LangProject.DefaultAnalysisWritingSystem, false, m_mediator, (Form)m_mediator.PropertyTable.GetValue("window")); m_pOSPopupTreeManager.AfterSelect += new TreeViewEventHandler(m_pOSPopupTreeManager_AfterSelect); } m_pOSPopupTreeManager.LoadPopupTree(0); }
/// <summary> /// Constructor. /// </summary> /// <param name="obj">CmObject that is being displayed.</param> /// <param name="flid">The field identifier for the attribute we are displaying.</param> /// // cache, obj, flid, node, persistenceProvider, stringTbl public AtomicReferencePOSSlice(FdoCache cache, ICmObject obj, int flid, IPersistenceProvider persistenceProvider, Mediator mediator) : base(new UserControl(), cache, obj, flid) { IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator); IWritingSystem defAnalWs = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem; m_tree = new TreeCombo(); m_tree.WritingSystemFactory = cache.WritingSystemFactory; m_tree.WritingSystemCode = defAnalWs.Handle; m_tree.Font = new System.Drawing.Font(defAnalWs.DefaultFontName, 10); m_tree.StyleSheet = stylesheet; if (!Application.RenderWithVisualStyles) { m_tree.HasBorder = false; } // 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 = 200; Control.Controls.Add(m_tree); if (m_pOSPopupTreeManager == null) { ICmPossibilityList list; int ws; if (obj is IReversalIndexEntry) { var rie = obj as IReversalIndexEntry; list = rie.ReversalIndex.PartsOfSpeechOA; ws = m_cache.ServiceLocator.WritingSystemManager.GetWsFromStr(rie.ReversalIndex.WritingSystem); } else { list = m_cache.LanguageProject.PartsOfSpeechOA; ws = m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle; } m_tree.WritingSystemCode = ws; m_pOSPopupTreeManager = new POSPopupTreeManager(m_tree, m_cache, list, ws, false, mediator, (Form)mediator.PropertyTable.GetValue("window")); m_pOSPopupTreeManager.AfterSelect += m_pOSPopupTreeManager_AfterSelect; } try { m_handlingMessage = true; m_pOSPopupTreeManager.LoadPopupTree(POS == null ? 0 : POS.Hvo); } finally { m_handlingMessage = false; } 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. }
private void m_tree_TreeLoad(object sender, EventArgs e) { if (m_pOSPopupTreeManager == null) { m_pOSPopupTreeManager = new POSPopupTreeManager(m_tree, m_cache, List, m_cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem.Handle, false, m_mediator, PropTable, PropTable.GetValue <Form>("window")); m_pOSPopupTreeManager.AfterSelect += m_pOSPopupTreeManager_AfterSelect; } m_pOSPopupTreeManager.LoadPopupTree(0); }
/// <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; } // 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_sda.RemoveNotification(this); } if (m_tree != null && m_tree.Parent == null) { m_tree.Dispose(); } if (m_pOSPopupTreeManager != null) { m_pOSPopupTreeManager.AfterSelect -= new TreeViewEventHandler(m_pOSPopupTreeManager_AfterSelect); m_pOSPopupTreeManager.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_sda = null; m_cache = null; m_tree = null; m_pOSPopupTreeManager = null; m_persistProvider = null; m_pos = null; base.Dispose(disposing); }