private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (windowDictionary != null) { foreach (Control ctrl in windowDictionary.Values) { ctrl.Disposed -= ControlDisposed; XtraWindowForm form = (XtraWindowForm)windowDictionary[ctrl]; if (form != null) { form.WindowFormClosing -= WindowFormClosing; form.WindowFormClosed -= WindowFormClosed; form.WindowFormActivated -= WindowFormActivated; } } windowDictionary.Clear(); } } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
/// <summary> /// Creates a form if it does not already exist and adds the given control. /// </summary> /// <param name="control"></param> /// <returns></returns> protected Form GetOrCreateForm(Control control) { XtraWindowForm form; if (windowDictionary.ContainsKey(control)) { form = (XtraWindowForm)windowDictionary[control]; } else { form = new XtraWindowForm(); windowDictionary.Add(control, form); form.Controls.Add(control); CalculateSize(control, form); control.Dock = DockStyle.Fill; control.Disposed += ControlDisposed; WireUpForm(form); } return(form); }
/// <summary> /// Creates a form if it does not already exist and adds the given control. /// </summary> /// <param name="control"></param> /// <returns></returns> protected Form GetOrCreateForm(Control control) { XtraWindowForm form; if (windowDictionary.ContainsKey(control)) { form = (XtraWindowForm)windowDictionary[control]; } else { form = new XtraWindowForm(); windowDictionary.Add(control, form); // reversed the order of these following two lines for issue 11166 CalculateSize(control, form); form.Controls.Add(control); control.Dock = DockStyle.Fill; control.Disposed += ControlDisposed; WireUpForm(form); } return(form); }
/// <summary> /// Creates a form if it does not already exist and adds the given control. /// </summary> /// <param name="control"></param> /// <returns></returns> protected Form GetOrCreateForm(Control control) { XtraWindowForm form = null; if (windows.ContainsKey(control)) { form = windows[control] as XtraWindowForm; } else { form = new XtraWindowForm(); windows.Add(control, form); form.Controls.Add(control); CalculateSize(control, form); control.Dock = DockStyle.Fill; control.Disposed += ControlDisposed; control.Show(); WireUpForm(form); } return(form); }
private void WireUpForm(XtraWindowForm form) { form.WindowFormClosing += WindowFormClosing; form.WindowFormClosed += WindowFormClosed; form.WindowFormActivated += WindowFormActivated; }