protected override void Dispose(bool disposing)
{
if (disposing && _form != null)
{
if(_infoNotificationDialog != null)
{
_infoNotificationDialog.Dispose();
_infoNotificationDialog = null;
}
if (_errorNotificationDialog != null)
{
_errorNotificationDialog.Dispose();
_errorNotificationDialog = null;
}
_form.VisibleChanged -= FormVisibleChangedEventHandler;
_form.Activated -= FormActivatedEventHandler;
_form.Deactivate -= FormDeactivateEventHandler;
_form.FormClosing -= FormFormClosingEventHandler;
_form.TabbedGroups.PageCloseRequest -= TabbedGroupPageClosePressedEventHandler;
_form.TabbedGroups.PageChanged -= TabbedGroupPageChangedEventHandler;
_form.DockingManager.ContentHiding -= DockingManagerContentHidingEventHandler;
_form.DockingManager.ContentShown -= DockingManagerContentShownEventHandler;
_form.DockingManager.ContentAutoHideOpening -= DockingManagerContentAutoHideOpeningEventHandler;
_form.DockingManager.ContentAutoHideClosed -= DockingManagerContentAutoHideClosedEventHandler;
_form.DockingManager.WindowActivated -= DockingManagerWindowActivatedEventHandler;
_form.DockingManager.WindowDeactivated -= FormDockingManagerWindowDeactivatedEventHandler;
try
{
SaveWindowSettings();
}
catch (Exception e)
{
// if the window settings can't be saved for any reason,
// just log it and move on
Platform.Log(LogLevel.Error, e);
}
// bug #1171: if this window is the active window and there are other windows,
// select the previously active one before destroying this one
if (_desktopWindowActivationOrder.LastElement == this && _desktopWindowActivationOrder.Count > 1)
{
_desktopWindowActivationOrder.SecondLastElement.Activate();
}
// remove this window from the activation order
_desktopWindowActivationOrder.Remove(this);
// now that we've cleaned up the activation,
// we can destroy the form safely without worrying
// about the OS triggering activation events
// this will close the form without firing any events
_form.Dispose();
_form = null;
// notify that we are no longer visible
SetVisibleStatus(false);
}
base.Dispose(disposing);
}