/// Create one, typically from the Sandbox, using an existing combo box or list. The caller is responsible /// to display it; the Show method should not be called, especially if comboList is actually not a combo box. /// </summary> /// <param name="cache"></param> /// <param name="hvoSrc"></param> /// <param name="?"></param> /// <param name="comboList"></param> public ChooseAnalysisHandler(LcmCache cache, int hvoSrc, int hvoAnalysis, IComboList comboList) { m_combo = comboList; m_cache = cache; m_hvoSrc = hvoSrc; m_hvoAnalysis = hvoAnalysis; m_combo.SelectedIndexChanged += new EventHandler(m_combo_SelectedIndexChanged); m_combo.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor; }
/// Create one, typically from the Sandbox, using an existing combo box or list. The caller is responsible /// to display it; the Show method should not be called, especially if comboList is actually not a combo box. /// </summary> /// <param name="cache"></param> /// <param name="hvoSrc"></param> /// <param name="?"></param> /// <param name="comboList"></param> public ChooseAnalysisHandler(FdoCache cache, int hvoSrc, int hvoAnalysis, IComboList comboList) { m_combo = comboList; m_cache = cache; m_hvoSrc = hvoSrc; m_hvoAnalysis = hvoAnalysis; m_combo.SelectedIndexChanged += new EventHandler(m_combo_SelectedIndexChanged); m_combo.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor; }
// If the handler is managing a combo box and it is visible hide it. // Likewise if it is a combo list. internal void HideCombo() { CheckDisposed(); if (m_sandbox.ParentForm == Form.ActiveForm) m_sandbox.Focus(); ComboListBox clb = m_comboList as ComboListBox; if (clb != null) { if (clb.IsDisposed) { // This can happen if the user tries hard enough. See FWR-3577. // It seems to get reconstructed okay if we just clear it. m_comboList = null; } else { clb.HideForm(); } } }
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; }
internal void SetComboListForTesting(IComboList list) { m_comboList = list; }
/// <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; }