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;
|
||||
|
||||
XenAdmin.Core.Clip.UnregisterClipboardViewer();
|
||||
|
||||
pluginManager.PluginsChanged -= pluginManager_PluginsChanged;
|
||||
pluginManager.Dispose();
|
||||
UnRegisterEvents();
|
||||
|
||||
OtherConfigAndTagsWatcher.DeregisterEventHandlers();
|
||||
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))
|
||||
if (disposing)
|
||||
{
|
||||
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)
|
||||
licenseTimer.Dispose();
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ namespace XenAdmin
|
||||
SRCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<SR>);
|
||||
FolderCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<Folder>);
|
||||
TaskCollectionChangedWithInvoke = Program.ProgramInvokeHandler(MeddlingActionManager.TaskCollectionChanged);
|
||||
ConnectionsManager.History.CollectionChanged += History_CollectionChanged;
|
||||
|
||||
RegisterEvents();
|
||||
|
||||
CommandLineArgType = argType;
|
||||
CommandLineParam = args;
|
||||
@ -224,16 +225,10 @@ namespace XenAdmin
|
||||
contextMenuBuilder = new ContextMenuBuilder(pluginManager, this);
|
||||
((WinformsXenAdminConfigProvider) XenAdminConfigManager.Provider).PluginManager = pluginManager;
|
||||
|
||||
eventsPage.GoToXenObjectRequested += eventsPage_GoToXenObjectRequested;
|
||||
SearchPage.SearchChanged += SearchPanel_SearchChanged;
|
||||
Alert.RegisterAlertCollectionChanged(XenCenterAlerts_CollectionChanged);
|
||||
Updates.RegisterCollectionChanged(Updates_CollectionChanged);
|
||||
|
||||
FormFontFixer.Fix(this);
|
||||
|
||||
Folders.InitFolders();
|
||||
DockerContainers.InitDockerContainers();
|
||||
OtherConfigAndTagsWatcher.InitEventHandlers();
|
||||
|
||||
// Fix colour of text on gradient panels
|
||||
TitleLabel.ForeColor = Program.TitleBarForeColor;
|
||||
@ -243,7 +238,6 @@ namespace XenAdmin
|
||||
|
||||
SelectionManager.BindTo(MainMenuBar.Items, this);
|
||||
SelectionManager.BindTo(ToolStrip.Items, this);
|
||||
Properties.Settings.Default.SettingChanging += Default_SettingChanging;
|
||||
|
||||
licenseTimer = new LicenseTimer(licenseManagerLauncher);
|
||||
GeneralPage.LicenseLauncher = licenseManagerLauncher;
|
||||
@ -254,6 +248,32 @@ namespace XenAdmin
|
||||
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)
|
||||
{
|
||||
if (e == null)
|
||||
|
@ -69,7 +69,7 @@ namespace XenAdmin
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitEventHandlers()
|
||||
public static void RegisterEventHandlers()
|
||||
{
|
||||
PoolCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<Pool>);
|
||||
VMCollectionChangedWithInvoke = InvokeHelper.InvokeHandler(CollectionChanged<VM>);
|
||||
|
Loading…
Reference in New Issue
Block a user