mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
Tidy up event registration and deregistration on the MainWindow.
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
56fdf0402e
commit
f05b512ca4
21
XenAdmin/MainWindow.Designer.cs
generated
21
XenAdmin/MainWindow.Designer.cs
generated
@ -15,24 +15,17 @@ namespace XenAdmin
|
|||||||
{
|
{
|
||||||
Program.Exiting = true;
|
Program.Exiting = true;
|
||||||
|
|
||||||
XenAdmin.Core.Clip.UnregisterClipboardViewer();
|
|
||||||
|
|
||||||
pluginManager.PluginsChanged -= pluginManager_PluginsChanged;
|
pluginManager.PluginsChanged -= pluginManager_PluginsChanged;
|
||||||
pluginManager.Dispose();
|
UnRegisterEvents();
|
||||||
|
|
||||||
OtherConfigAndTagsWatcher.DeregisterEventHandlers();
|
if (disposing)
|
||||||
ConnectionsManager.History.CollectionChanged -= History_CollectionChanged;
|
|
||||||
XenAdmin.Alerts.Alert.DeregisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
|
|
||||||
XenAdmin.Core.Updates.DeregisterCollectionChanged(Updates_CollectionChanged);
|
|
||||||
ConnectionsManager.XenConnections.CollectionChanged -= XenConnection_CollectionChanged;
|
|
||||||
Properties.Settings.Default.SettingChanging -= new System.Configuration.SettingChangingEventHandler(Default_SettingChanging);
|
|
||||||
SearchPage.SearchChanged -= SearchPanel_SearchChanged;
|
|
||||||
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
{
|
||||||
components.Dispose();
|
if (components != null)
|
||||||
|
components.Dispose();
|
||||||
|
|
||||||
log.Debug("MainWindow disoposing license timer");
|
pluginManager.Dispose();
|
||||||
|
|
||||||
|
log.Debug("MainWindow disposing of license timer");
|
||||||
if (licenseTimer != null)
|
if (licenseTimer != null)
|
||||||
licenseTimer.Dispose();
|
licenseTimer.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,8 @@ namespace XenAdmin
|
|||||||
SRCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<SR>);
|
SRCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<SR>);
|
||||||
FolderCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<Folder>);
|
FolderCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<Folder>);
|
||||||
TaskCollectionChangedWithInvoke = Program.ProgramInvokeHandler(MeddlingActionManager.TaskCollectionChanged);
|
TaskCollectionChangedWithInvoke = Program.ProgramInvokeHandler(MeddlingActionManager.TaskCollectionChanged);
|
||||||
ConnectionsManager.History.CollectionChanged += History_CollectionChanged;
|
|
||||||
|
RegisterEvents();
|
||||||
|
|
||||||
CommandLineArgType = argType;
|
CommandLineArgType = argType;
|
||||||
CommandLineParam = args;
|
CommandLineParam = args;
|
||||||
@ -224,16 +225,10 @@ namespace XenAdmin
|
|||||||
contextMenuBuilder = new ContextMenuBuilder(pluginManager, this);
|
contextMenuBuilder = new ContextMenuBuilder(pluginManager, this);
|
||||||
((WinformsXenAdminConfigProvider) XenAdminConfigManager.Provider).PluginManager = pluginManager;
|
((WinformsXenAdminConfigProvider) XenAdminConfigManager.Provider).PluginManager = pluginManager;
|
||||||
|
|
||||||
eventsPage.GoToXenObjectRequested += eventsPage_GoToXenObjectRequested;
|
|
||||||
SearchPage.SearchChanged += SearchPanel_SearchChanged;
|
|
||||||
Alert.RegisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
|
|
||||||
Updates.RegisterCollectionChanged(Updates_CollectionChanged);
|
|
||||||
|
|
||||||
FormFontFixer.Fix(this);
|
FormFontFixer.Fix(this);
|
||||||
|
|
||||||
Folders.InitFolders();
|
Folders.InitFolders();
|
||||||
DockerContainers.InitDockerContainers();
|
DockerContainers.InitDockerContainers();
|
||||||
OtherConfigAndTagsWatcher.InitEventHandlers();
|
|
||||||
|
|
||||||
// Fix colour of text on gradient panels
|
// Fix colour of text on gradient panels
|
||||||
TitleLabel.ForeColor = Program.TitleBarForeColor;
|
TitleLabel.ForeColor = Program.TitleBarForeColor;
|
||||||
@ -243,7 +238,6 @@ namespace XenAdmin
|
|||||||
|
|
||||||
SelectionManager.BindTo(MainMenuBar.Items, this);
|
SelectionManager.BindTo(MainMenuBar.Items, this);
|
||||||
SelectionManager.BindTo(ToolStrip.Items, this);
|
SelectionManager.BindTo(ToolStrip.Items, this);
|
||||||
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
|
|
||||||
|
|
||||||
licenseTimer = new LicenseTimer(licenseManagerLauncher);
|
licenseTimer = new LicenseTimer(licenseManagerLauncher);
|
||||||
GeneralPage.LicenseLauncher = licenseManagerLauncher;
|
GeneralPage.LicenseLauncher = licenseManagerLauncher;
|
||||||
@ -254,6 +248,32 @@ namespace XenAdmin
|
|||||||
statusLabelAlerts.Visible = statusLabelUpdates.Visible = statusLabelErrors.Visible = false;
|
statusLabelAlerts.Visible = statusLabelUpdates.Visible = statusLabelErrors.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterEvents()
|
||||||
|
{
|
||||||
|
//ClipboardViewer is registered in OnHandleCreated
|
||||||
|
OtherConfigAndTagsWatcher.RegisterEventHandlers();
|
||||||
|
Alert.RegisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
|
||||||
|
Updates.RegisterCollectionChanged(Updates_CollectionChanged);
|
||||||
|
ConnectionsManager.History.CollectionChanged += History_CollectionChanged;
|
||||||
|
//ConnectionsManager.XenConnections.CollectionChanged is registered in OnShown
|
||||||
|
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
|
||||||
|
eventsPage.GoToXenObjectRequested += eventsPage_GoToXenObjectRequested;
|
||||||
|
SearchPage.SearchChanged += SearchPanel_SearchChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UnRegisterEvents()
|
||||||
|
{
|
||||||
|
Clip.UnregisterClipboardViewer();
|
||||||
|
OtherConfigAndTagsWatcher.DeregisterEventHandlers();
|
||||||
|
Alert.DeregisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
|
||||||
|
Updates.DeregisterCollectionChanged(Updates_CollectionChanged);
|
||||||
|
ConnectionsManager.History.CollectionChanged -= History_CollectionChanged;
|
||||||
|
ConnectionsManager.XenConnections.CollectionChanged -= XenConnection_CollectionChanged;
|
||||||
|
Properties.Settings.Default.SettingChanging -= Default_SettingChanging;
|
||||||
|
eventsPage.GoToXenObjectRequested -= eventsPage_GoToXenObjectRequested;
|
||||||
|
SearchPage.SearchChanged -= SearchPanel_SearchChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void Default_SettingChanging(object sender, SettingChangingEventArgs e)
|
private void Default_SettingChanging(object sender, SettingChangingEventArgs e)
|
||||||
{
|
{
|
||||||
if (e == null)
|
if (e == null)
|
||||||
|
@ -69,7 +69,7 @@ namespace XenAdmin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InitEventHandlers()
|
public static void RegisterEventHandlers()
|
||||||
{
|
{
|
||||||
PoolCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<Pool>);
|
PoolCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<Pool>);
|
||||||
VMCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<VM>);
|
VMCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<VM>);
|
||||||
|
Loading…
Reference in New Issue
Block a user