Merge pull request #1404 from MihaelaStoica/CP-19607

CP-19607: Make sure that event handlers are unregistered when controls are not visible
This commit is contained in:
Gabor Apati-Nagy 2017-02-01 13:53:14 +00:00 committed by GitHub
commit 01cebc9166
36 changed files with 538 additions and 390 deletions

View File

@ -134,5 +134,20 @@ namespace XenAdmin.Controls.Ballooning
using (var dlg = new ControlDomainMemoryDialog(host))
dlg.ShowDialog(Program.MainWindow);
}
internal void UnregisterHandlers()
{
if (_host == null)
return;
host.PropertyChanged -= host_PropertyChanged;
foreach (var vm in _host.Connection.Cache.VMs)
{
vm.PropertyChanged -= vm_PropertyChanged;
var metrics = vm.Connection.Resolve(vm.metrics);
if (metrics != null)
metrics.PropertyChanged -= vm_metrics_PropertyChanged;
}
}
}
}

View File

@ -29,12 +29,6 @@
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XenAPI;
@ -64,5 +58,11 @@ namespace XenAdmin.Controls.Ballooning
Refresh();
}
}
internal void UnregisterHandlers()
{
memoryRowLabel.UnsubscribeEvents();
hostMemoryControls.UnregisterHandlers();
}
}
}

View File

@ -29,12 +29,8 @@
* SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XenAdmin.Core;
@ -93,7 +89,7 @@ namespace XenAdmin.Controls.Ballooning
}
}
private void UnsubscribeEvents()
internal void UnsubscribeEvents()
{
foreach (IXenObject o in objs)
{

View File

@ -32,9 +32,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using XenAdmin.Dialogs;
using XenAdmin.Wizards;
@ -126,5 +124,17 @@ namespace XenAdmin.Controls.Ballooning
else
Program.MainWindow.ShowPerConnectionWizard(vm0.Connection, new BallooningWizard(vms));
}
internal void UnregisterHandlers()
{
if (vms == null)
return;
foreach (var vm in vms)
vm.PropertyChanged -= vm_PropertyChanged;
foreach (var metrics in vm_metrics.Where(m => m != null))
metrics.PropertyChanged -= vm_metrics_PropertyChanged;
}
}
}

View File

@ -31,10 +31,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XenAPI;
@ -81,5 +77,10 @@ namespace XenAdmin.Controls.Ballooning
panelControls.Top = memoryRowLabel.Bottom;
this.Height = panelControls.Bottom;
}
internal void UnregisterHandlers()
{
vmMemoryControls.UnregisterHandlers();
}
}
}

View File

@ -166,7 +166,7 @@ namespace XenAdmin.Controls
action.RunAsync();
}
protected override void DeregisterEvents()
internal override void DeregisterEvents()
{
// Remove VM listeners
if (vm != null)

View File

@ -273,7 +273,7 @@ namespace XenAdmin.Controls
}
}
protected virtual void DeregisterEvents()
internal virtual void DeregisterEvents()
{
if (connection == null)
return;

View File

@ -36,18 +36,12 @@ using System.Drawing;
using System.Globalization;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml;
using Citrix.XenCenter;
using XenAPI;
using XenAdmin;
using XenAdmin.Core;
using XenAdmin.Actions;
namespace XenAdmin.Controls.CustomDataGraph
{
@ -645,7 +639,7 @@ namespace XenAdmin.Controls.CustomDataGraph
/// <summary>
/// Gui Thread
/// </summary>
private void DeregEvents()
internal void DeregEvents()
{
if (XenObject == null)
return;

View File

@ -131,7 +131,7 @@ namespace XenAdmin.Controls
}
}
private void UnregisterHandlers()
internal void UnregisterHandlers()
{
if (xenObject == null)
return;

View File

@ -100,7 +100,7 @@ namespace XenAdmin.Controls
#endregion
protected virtual void DeregisterEvents()
internal virtual void DeregisterEvents()
{
if (vm == null)
return;
@ -118,6 +118,7 @@ namespace XenAdmin.Controls
{
vbd.PropertyChanged -= vbd_PropertyChanged;
}
cdChanger1.DeregisterEvents();
}
void vm_PropertyChanged(object sender, PropertyChangedEventArgs e)

View File

@ -72,19 +72,7 @@ namespace XenAdmin.Controls.NetworkingTab
// Remove all old property change listeners. They will get added back in the
// population of the DataGridView that follows (see BuildList).
DegregisterEventsOnXmo();
DeregisterEventsOnGridRows();
if (_xenObject is Host || _xenObject is Pool)
{
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<XenAPI.Network>(NetworkCollectionChanged);
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<PIF>(PIFCollectionChanged);
}
else if (_xenObject is VM)
{
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<VIF>(CollectionChanged);
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<VM_guest_metrics>(VM_guest_metrics_BatchCollectionChanged);
}
UnregisterHandlers();
_xenObject = value;
@ -142,6 +130,23 @@ namespace XenAdmin.Controls.NetworkingTab
}
}
internal void UnregisterHandlers()
{
DegregisterEventsOnXmo();
DeregisterEventsOnGridRows();
if (_xenObject is Host || _xenObject is Pool)
{
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<XenAPI.Network>(NetworkCollectionChanged);
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<PIF>(PIFCollectionChanged);
}
else if (_xenObject is VM)
{
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<VIF>(CollectionChanged);
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<VM_guest_metrics>(VM_guest_metrics_BatchCollectionChanged);
}
}
private void AddNetworkColumns()
{
// catch the sorting column and sorting order, so they could be restored after the columns are added to the grid (SCTX-501)
@ -1036,8 +1041,6 @@ namespace XenAdmin.Controls.NetworkingTab
}
e.SortResult = StringUtility.NaturalCompare(e.CellValue1.ToString(), e.CellValue2.ToString());
e.Handled = true;
}
}
}

View File

@ -13,7 +13,7 @@ namespace XenAdmin.Controls
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
ConnectionsManager.XenConnections.CollectionChanged -= CollectionChanged;
UnregisterHandlers();
if (disposing && (components != null))
{

View File

@ -30,14 +30,8 @@
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using XenAdmin;
using XenAdmin.Network;
using XenAdmin.Core;
using XenAPI;
@ -196,6 +190,24 @@ namespace XenAdmin.Controls
Program.Invoke(this, buildList);
}
private void UnregisterHandlers()
{
ConnectionsManager.XenConnections.CollectionChanged -= CollectionChanged;
foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy)
{
Pool pool = Helpers.GetPoolOfOne(xc);
if (pool != null)
pool.PropertyChanged -= PropertyChanged;
foreach (Host host in xc.Cache.Hosts)
host.PropertyChanged -= PropertyChanged;
xc.ConnectionStateChanged -= xc_ConnectionStateChanged;
xc.CachePopulated -= xc_CachePopulated;
xc.Cache.DeregisterCollectionChanged<Host>(CollectionChangedWithInvoke);
}
}
private CustomTreeNode lastSelected;
public bool AllowPoolSelect = true;

View File

@ -17,6 +17,7 @@ namespace XenAdmin.Controls
{
components.Dispose();
}
UnregisterHandlers();
base.Dispose(disposing);
}

View File

@ -99,6 +99,7 @@ namespace XenAdmin.Controls
public SrPicker()
{
InitializeComponent();
SR_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(SR_CollectionChanged);
}
public SRPickerType Usage
@ -329,6 +330,28 @@ namespace XenAdmin.Controls
Program.Invoke(this, refresh);
}
private void UnregisterHandlers()
{
if (connection == null)
return;
var pool = Helpers.GetPoolOfOne(connection);
if (pool != null)
pool.PropertyChanged -= Server_PropertyChanged;
foreach (var sr in connection.Cache.SRs)
{
foreach (var pbd in sr.Connection.ResolveAll(sr.PBDs))
{
if (pbd != null)
pbd.PropertyChanged -= Server_PropertyChanged;
}
sr.PropertyChanged -= Server_PropertyChanged;
}
connection.Cache.DeregisterCollectionChanged<SR>(SR_CollectionChangedWithInvoke);
}
/// <summary>
/// Selects the default SR, if it exists.
/// </summary>

View File

@ -926,11 +926,14 @@ namespace XenAdmin.Dialogs
private void EvacuateHostDialog_FormClosed(object sender, FormClosedEventArgs e)
{
foreach (Host host in connection.Cache.Hosts)
{
host.PropertyChanged -= new PropertyChangedEventHandler(host_PropertyChanged);
}
if (host != null)
host.PropertyChanged -= hostUpdate;
foreach (var h in connection.Cache.Hosts)
h.PropertyChanged -= host_PropertyChanged;
deregisterVMEvents();
if (elevatedSession != null && elevatedSession.uuid != null)
{
// NOTE: This doesnt happen currently, as we always scan once. Here as cheap insurance.

View File

@ -173,6 +173,7 @@
this.CancelButton = this.buttonCancel;
this.Controls.Add(this.tableLayoutPanelBody);
this.Name = "RestoreVMsDialog";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RestoreVMsDialog_FormClosing);
this.tableLayoutPanelBody.ResumeLayout(false);
this.tableLayoutPanelBody.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewVms)).EndInit();

View File

@ -32,11 +32,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using XenAdmin.Network;
using XenAPI;
using XenAdmin.Core;
@ -62,7 +58,7 @@ namespace XenAdmin.Dialogs
this.connection = VMsToRestore[0].Connection;
foreach (VM v in VMsToRestore)
v.PropertyChanged += new PropertyChangedEventHandler(v_PropertyChanged);
v.PropertyChanged += v_PropertyChanged;
BuildList();
}
@ -130,5 +126,11 @@ namespace XenAdmin.Dialogs
{
DialogResult = DialogResult.Cancel;
}
private void RestoreVMsDialog_FormClosing(object sender, FormClosingEventArgs e)
{
foreach (VM v in VMsToRestore)
v.PropertyChanged -= v_PropertyChanged;
}
}
}

View File

@ -194,6 +194,7 @@ namespace XenAdmin
#endregion
TheTabControl.SelectedIndexChanged += TheTabControl_SelectedIndexChanged;
TheTabControl.Deselected += TheTabControl_Deselected;
navigationPane.DragDropCommandActivated += navigationPane_DragDropCommandActivated;
PoolCollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged<Pool>);
@ -1755,6 +1756,16 @@ namespace XenAdmin
Help.HelpManager.Launch("LicenseKeyDialog");
}
private void TheTabControl_Deselected(object sender, TabControlEventArgs e)
{
TabPage t = e.TabPage;
if (t == null)
return;
BaseTabPage tabPage = t.Controls.OfType<BaseTabPage>().FirstOrDefault();
if (tabPage != null)
tabPage.PageHidden();
}
/// <param name="e">
/// If null, then we deduce the method was called by TreeView_AfterSelect
/// and don't focus the VNC console. i.e. we only focus the VNC console if the user
@ -1771,9 +1782,6 @@ namespace XenAdmin
if (!SearchMode)
History.NewHistoryItem(new XenModelObjectHistoryItem(SelectionManager.Selection.FirstAsXenObject, t));
if (t != TabPageBallooning)
BallooningPage.IsHidden();
if (t == TabPageConsole)
{
if (SelectionManager.Selection.FirstIsRealVM)
@ -1973,11 +1981,6 @@ namespace XenAdmin
}
}
if (t == TabPagePeformance)
PerformancePage.ResumeGraph();
else
PerformancePage.PauseGraph();
if (t == TabPageSearch)
SearchPage.PanelShown();
else

View File

@ -166,6 +166,11 @@ namespace XenAdmin.TabPages
pool.Connection.Session.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Session_PropertyChanged);
}
public override void PageHidden()
{
ClearHandles();
}
/// <summary>
/// We keep track of the actions in currently running so we can disable the tab if we are in the middle of configuring AD.
/// </summary>

View File

@ -201,6 +201,22 @@ namespace XenAdmin.TabPages
foreach (VM vm in vms)
UnregisterVMHandlers(vm); // Should duplicate above line, but let's be safe
foreach (Control c in pageContainerPanel.Controls)
{
VMMemoryRow vmRow = c as VMMemoryRow;
if (vmRow != null)
{
vmRow.UnregisterHandlers();
continue;
}
HostMemoryRow hostRow = c as HostMemoryRow;
if (hostRow != null)
{
hostRow.UnregisterHandlers();
}
}
}
private void UnregisterHostHandlers(Host host)
@ -217,7 +233,7 @@ namespace XenAdmin.TabPages
guest_metrics.PropertyChanged -= guest_metrics_PropertyChanged;
}
public void IsHidden()
public override void PageHidden()
{
UnregisterHandlers();
}

View File

@ -78,5 +78,8 @@ namespace XenAdmin.TabPages
get { return deprecationBanner1; }
}
public virtual void PageHidden()
{
}
}
}

View File

@ -292,6 +292,15 @@ namespace XenAdmin.TabPages
}
}
public override void PageHidden()
{
UnregisterHandlers();
var gpuPlacementPolicyPanel = pageContainerPanel.Controls.OfType<GpuPlacementPolicyPanel>().FirstOrDefault();
if (gpuPlacementPolicyPanel != null)
gpuPlacementPolicyPanel.UnregisterHandlers();
}
internal class GpuSettings : IEquatable<GpuSettings>
{

View File

@ -62,42 +62,19 @@ namespace XenAdmin.TabPages
{
Program.AssertOnEventThread();
// Do nothing if value is being set to the same object again
if (value == xenObject)
{
Rebuild();
return;
}
if (xenObject != null)
{
if (xenObject is Pool)
{
pool.PropertyChanged -= pool_PropertyChanged;
foreach (Host slave in pool.Connection.Cache.Hosts)
{
slave.PropertyChanged -= host_PropertyChanged;
}
pool.Connection.Cache.DeregisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
}
}
UnregisterHandlers();
xenObject = value;
pool = null;
if (xenObject != null)
pool = xenObject as Pool;
if (pool != null)
{
if (xenObject is Pool)
{
this.pool = (Pool)xenObject;
pool.PropertyChanged += pool_PropertyChanged;
foreach (Host slave in pool.Connection.Cache.Hosts)
foreach (var host in pool.Connection.Cache.Hosts)
{
slave.PropertyChanged += host_PropertyChanged;
host.PropertyChanged += host_PropertyChanged;
}
pool.Connection.Cache.RegisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
}
}
Rebuild();
}
@ -170,6 +147,23 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
if (pool == null)
return;
pool.PropertyChanged -= pool_PropertyChanged;
foreach (var host in pool.Connection.Cache.Hosts)
{
host.PropertyChanged -= host_PropertyChanged;
}
pool.Connection.Cache.DeregisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
}
public override void PageHidden()
{
UnregisterHandlers();
}
/// <summary>
/// Rebuilds the panel contents. Must be called on the event thread.
/// </summary>

View File

@ -74,14 +74,7 @@ namespace XenAdmin.TabPages
}
set
{
if (host != null)
{
host.Connection.Cache.DeregisterCollectionChanged<PIF>(PIF_CollectionChangedWithInvoke);
foreach (PIF PIF in host.Connection.ResolveAll(host.PIFs))
{
UnregisterPIFEventHandlers(PIF);
}
}
UnregisterHandlers();
host = value;
@ -140,6 +133,24 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
if (host == null)
return;
host.Connection.Cache.DeregisterCollectionChanged<PIF>(PIF_CollectionChangedWithInvoke);
foreach (PIF PIF in host.Connection.ResolveAll(host.PIFs))
{
UnregisterPIFEventHandlers(PIF);
}
}
public override void PageHidden()
{
UnregisterHandlers();
}
private void updateList()
{
PIFRow selected = null;

View File

@ -79,11 +79,10 @@ namespace XenAdmin.TabPages
}
//Management Interfaces
if (_xenObject != null)
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<XenAPI.PIF>(CollectionChanged);
UnregisterHandlers();
_xenObject = value;
if (_xenObject != null)
_xenObject.Connection.Cache.RegisterBatchCollectionChanged<XenAPI.PIF>(CollectionChanged);
_xenObject.Connection.Cache.RegisterBatchCollectionChanged<PIF>(CollectionChanged);
RepopulateManagementInterfaces();
networkList1.XenObject = value;
@ -115,6 +114,19 @@ namespace XenAdmin.TabPages
base.OnVisibleChanged(e);
}
private void UnregisterHandlers()
{
if (_xenObject == null)
return;
_xenObject.Connection.Cache.DeregisterBatchCollectionChanged<PIF>(CollectionChanged);
}
public override void PageHidden()
{
UnregisterHandlers();
networkList1.UnregisterHandlers();
}
#region Management Interfaces

View File

@ -46,7 +46,6 @@ namespace XenAdmin.TabPages
public partial class PerformancePage : BaseTabPage
{
private IXenObject _xenObject;
private bool PanelShowing;
private bool _disposed;
private readonly CollectionChangeEventHandler Message_CollectionChangedWithInvoke;
private readonly ArchiveMaintainer ArchiveMaintainer = new ArchiveMaintainer();
@ -184,8 +183,7 @@ namespace XenAdmin.TabPages
GraphList.LoadGraphs(XenObject);
LoadEvents();
ArchiveMaintainer.XenObject = value;
if (PanelShowing)
ArchiveMaintainer.Start(); // make sure we start twice
ArchiveMaintainer.Start();
}
}
}
@ -277,18 +275,14 @@ namespace XenAdmin.TabPages
XenObject.Connection.Cache.DeregisterCollectionChanged<XenAPI.Message>(Message_CollectionChangedWithInvoke);
}
public void PauseGraph()
public override void PageHidden()
{
PanelShowing = false;
DeregEvents();
if (ArchiveMaintainer != null && XenObject != null)
{
ArchiveMaintainer.Pause();
ArchiveMaintainer.DeregEvents();
}
public void ResumeGraph()
{
PanelShowing = true;
if (ArchiveMaintainer != null && XenObject != null)
ArchiveMaintainer.Start();
}
private void ArchiveMaintainer_ArchivesUpdated(object sender, EventArgs args)

View File

@ -95,20 +95,7 @@ namespace XenAdmin.TabPages
{
set
{
if (connection != null)
{
connection.Cache.DeregisterCollectionChanged<PBD>(PBD_CollectionChangedWithInvoke);
connection.XenObjectsUpdated -= XenObjectUpdated;
foreach (SR sr in connection.Cache.SRs)
{
sr.PropertyChanged -= sr_PropertyChanged;
}
Pool pool = Helpers.GetPoolOfOne(connection);
if(pool != null)
pool.PropertyChanged -= pool_PropertyChanged;
}
UnregisterHandlers();
connection = value;
@ -186,6 +173,29 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
if (connection == null)
return;
connection.Cache.DeregisterCollectionChanged<PBD>(PBD_CollectionChangedWithInvoke);
connection.XenObjectsUpdated -= XenObjectUpdated;
foreach (SR sr in connection.Cache.SRs)
{
sr.PropertyChanged -= sr_PropertyChanged;
}
Pool pool = Helpers.GetPoolOfOne(connection);
if (pool != null)
pool.PropertyChanged -= pool_PropertyChanged;
}
public override void PageHidden()
{
UnregisterHandlers();
}
/// <summary>
/// Finds the ListView row for the given SR, and calls RefreshRow on it.
/// </summary>

View File

@ -78,11 +78,7 @@ namespace XenAdmin.TabPages
}
set
{
if (connection != null)
{
connection.Cache.DeregisterCollectionChanged<PVS_proxy>(PvsProxy_CollectionChangedWithInvoke);
connection.Cache.DeregisterCollectionChanged<VM>(PvsProxy_CollectionChangedWithInvoke);
}
UnregisterHandlers();
connection = value;
@ -124,7 +120,7 @@ namespace XenAdmin.TabPages
var previousSelection = GetSelectedVMs();
UnregisterEventHandlers();
UnregisterVmEventHandlers();
dataGridViewVms.SortCompare += dataGridViewVms_SortCompare;
@ -214,7 +210,7 @@ namespace XenAdmin.TabPages
newRow.Cells.AddRange(vmCell, cacheEnabledCell, pvsSiteCell, statusCell);
UpdateRow(newRow, vm, pvsProxy, showRow);
RegisterEventHandlers(vm, pvsProxy);
RegisterVmEventHandlers(vm, pvsProxy);
return newRow;
}
@ -229,7 +225,7 @@ namespace XenAdmin.TabPages
row.Visible = showRow;
}
private void RegisterEventHandlers(VM vm, PVS_proxy pvsProxy)
private void RegisterVmEventHandlers(VM vm, PVS_proxy pvsProxy)
{
vm.PropertyChanged -= VmPropertyChanged;
vm.PropertyChanged += VmPropertyChanged;
@ -246,7 +242,7 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterEventHandlers()
private void UnregisterVmEventHandlers()
{
dataGridViewVms.SelectionChanged -= VmSelectionChanged;
dataGridViewVms.SortCompare -= dataGridViewVms_SortCompare;
@ -268,6 +264,19 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
if (connection == null)
return;
connection.Cache.DeregisterCollectionChanged<PVS_proxy>(PvsProxy_CollectionChangedWithInvoke);
connection.Cache.DeregisterCollectionChanged<VM>(PvsProxy_CollectionChangedWithInvoke);
}
public override void PageHidden()
{
UnregisterHandlers();
}
void dataGridViewVms_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
e.Handled = false;

View File

@ -120,15 +120,7 @@ namespace XenAdmin.TabPages
{
set
{
if (m_VM != null)
{
m_VM.Connection.Cache.DeregisterBatchCollectionChanged<VM>(VM_BatchCollectionChanged);
m_VM.PropertyChanged -= snapshot_PropertyChanged;
foreach (VM snapshot in m_VM.Connection.ResolveAll<VM>(m_VM.snapshots))
{
snapshot.PropertyChanged -= snapshot_PropertyChanged;
}
}
UnregisterHandlers();
if (value != null)
{
m_VM = value;
@ -269,6 +261,23 @@ namespace XenAdmin.TabPages
m_NeedToUpdate = false;
}
private void UnregisterHandlers()
{
if (m_VM == null)
return;
m_VM.Connection.Cache.DeregisterBatchCollectionChanged<VM>(VM_BatchCollectionChanged);
m_VM.PropertyChanged -= snapshot_PropertyChanged;
foreach (VM snapshot in m_VM.Connection.ResolveAll<VM>(m_VM.snapshots))
{
snapshot.PropertyChanged -= snapshot_PropertyChanged;
}
}
public override void PageHidden()
{
UnregisterHandlers();
}
private void BuildList()
{
if (!this.Visible)

View File

@ -208,6 +208,24 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
ConnectionsManager.History.CollectionChanged -= History_CollectionChanged;
Properties.Settings.Default.PropertyChanged -= Default_PropertyChanged;
if (sr != null)
{
sr.PropertyChanged -= sr_PropertyChanged;
sr.Connection.Cache.DeregisterBatchCollectionChanged<VDI>(VDI_BatchCollectionChanged);
sr.Connection.XenObjectsUpdated -= Connection_XenObjectsUpdated;
}
}
public override void PageHidden()
{
UnregisterHandlers();
}
#region events
void History_CollectionChanged(object sender, CollectionChangeEventArgs e)
{

View File

@ -67,8 +67,6 @@ namespace XenAdmin.TabPages
this.ColumnActive = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnDevicePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.multipleDvdIsoList1 = new XenAdmin.Controls.MultipleDvdIsoList();
this.gradientPanel1 = new XenAdmin.Controls.GradientPanel.GradientPanel();
this.TitleLabel = new System.Windows.Forms.Label();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
@ -79,6 +77,7 @@ namespace XenAdmin.TabPages
this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.pageContainerPanel.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.DeactivateButtonContainer.SuspendLayout();
this.MoveButtonContainer.SuspendLayout();
@ -87,9 +86,13 @@ namespace XenAdmin.TabPages
this.contextMenuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewStorage)).BeginInit();
this.gradientPanel1.SuspendLayout();
this.SuspendLayout();
//
// pageContainerPanel
//
this.pageContainerPanel.Controls.Add(this.tableLayoutPanel1);
resources.ApplyResources(this.pageContainerPanel, "pageContainerPanel");
//
// AddButton
//
resources.ApplyResources(this.AddButton, "AddButton");
@ -352,20 +355,6 @@ namespace XenAdmin.TabPages
this.multipleDvdIsoList1.Name = "multipleDvdIsoList1";
this.multipleDvdIsoList1.VM = null;
//
// gradientPanel1
//
this.gradientPanel1.Controls.Add(this.TitleLabel);
resources.ApplyResources(this.gradientPanel1, "gradientPanel1");
this.gradientPanel1.Name = "gradientPanel1";
this.gradientPanel1.Scheme = XenAdmin.Controls.GradientPanel.GradientPanel.Schemes.Tab;
//
// TitleLabel
//
resources.ApplyResources(this.TitleLabel, "TitleLabel");
this.TitleLabel.AutoEllipsis = true;
this.TitleLabel.ForeColor = System.Drawing.Color.White;
this.TitleLabel.Name = "TitleLabel";
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
@ -441,10 +430,10 @@ namespace XenAdmin.TabPages
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.gradientPanel1);
this.DoubleBuffered = true;
this.Name = "VMStoragePage";
this.Controls.SetChildIndex(this.pageContainerPanel, 0);
this.pageContainerPanel.ResumeLayout(false);
this.flowLayoutPanel1.ResumeLayout(false);
this.DeactivateButtonContainer.ResumeLayout(false);
this.MoveButtonContainer.ResumeLayout(false);
@ -453,8 +442,8 @@ namespace XenAdmin.TabPages
this.contextMenuStrip1.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewStorage)).EndInit();
this.gradientPanel1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
@ -465,11 +454,9 @@ namespace XenAdmin.TabPages
private System.Windows.Forms.Button EditButton;
public System.Windows.Forms.Button DetachButton;
public System.Windows.Forms.Button DeleteButton;
private System.Windows.Forms.Label TitleLabel;
private XenAdmin.Controls.ToolTipContainer DetachButtonContainer;
private XenAdmin.Controls.ToolTipContainer DeleteButtonContainer;
private XenAdmin.Controls.ToolTipContainer DeactivateButtonContainer;
private XenAdmin.Controls.GradientPanel.GradientPanel gradientPanel1;
public System.Windows.Forms.Button DeactivateButton;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private XenAdmin.Controls.MultipleDvdIsoList multipleDvdIsoList1;

View File

@ -48,7 +48,7 @@ using XenAdmin.Commands;
namespace XenAdmin.TabPages
{
internal partial class VMStoragePage : UserControl
internal partial class VMStoragePage : BaseTabPage
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
@ -61,8 +61,7 @@ namespace XenAdmin.TabPages
InitializeComponent();
storageLinkColumn = ColumnSRVolume;
TitleLabel.ForeColor = Program.HeaderGradientForeColor;
TitleLabel.Font = Program.HeaderGradientFont;
Text = Messages.VIRTUAL_DISKS;
dataGridViewStorage.Sort(ColumnDevicePosition, ListSortDirection.Ascending);
}
@ -72,22 +71,8 @@ namespace XenAdmin.TabPages
{
Program.AssertOnEventThread();
// de-register old listener...
if (vm != null)
{
foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
{
vbd.PropertyChanged -= vbd_PropertyChanged;
VDI vdi = vm.Connection.Resolve(vbd.VDI);
if (vdi == null)
continue;
vdi.PropertyChanged -= vdi_PropertyChanged;
}
vm.PropertyChanged -= vm_PropertyChanged;
}
// de-register old listeners...
UnregisterHandlers();
vm = value;
multipleDvdIsoList1.VM = vm;
@ -143,6 +128,32 @@ namespace XenAdmin.TabPages
}
}
private void UnregisterHandlers()
{
if (vm == null)
return;
foreach (VBD vbd in vm.Connection.ResolveAll(vm.VBDs))
{
vbd.PropertyChanged -= vbd_PropertyChanged;
VDI vdi = vm.Connection.Resolve(vbd.VDI);
if (vdi == null)
continue;
vdi.PropertyChanged -= vdi_PropertyChanged;
}
vm.PropertyChanged -= vm_PropertyChanged;
multipleDvdIsoList1.DeregisterEvents();
}
public override void PageHidden()
{
UnregisterHandlers();
}
private void UpdateData()
{
try

View File

@ -117,18 +117,24 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AddButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="AddButton.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 3</value>
<value>2, 2</value>
</data>
<data name="AddButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="AddButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="AddButton.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
@ -147,44 +153,17 @@
<data name="&gt;&gt;AddButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="EditButton.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="EditButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="EditButton.Location" type="System.Drawing.Point, System.Drawing">
<value>507, 3</value>
</data>
<data name="EditButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
</data>
<data name="EditButton.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="EditButton.Text" xml:space="preserve">
<value>P&amp;roperties</value>
</data>
<data name="&gt;&gt;EditButton.Name" xml:space="preserve">
<value>EditButton</value>
</data>
<data name="&gt;&gt;EditButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;EditButton.Parent" xml:space="preserve">
<value>flowLayoutPanel1</value>
</data>
<data name="&gt;&gt;EditButton.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="AttachButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="AttachButton.Location" type="System.Drawing.Point, System.Drawing">
<value>129, 3</value>
<value>102, 2</value>
</data>
<data name="AttachButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="AttachButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="AttachButton.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -217,7 +196,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="DeactivateButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DeactivateButton.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -238,10 +217,13 @@
<value>1</value>
</data>
<data name="DeactivateButtonContainer.Location" type="System.Drawing.Point, System.Drawing">
<value>255, 3</value>
<value>202, 2</value>
</data>
<data name="DeactivateButtonContainer.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="DeactivateButtonContainer.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DeactivateButtonContainer.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -271,7 +253,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="MoveButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="MoveButton.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -292,10 +274,13 @@
<value>1</value>
</data>
<data name="MoveButtonContainer.Location" type="System.Drawing.Point, System.Drawing">
<value>381, 3</value>
<value>302, 2</value>
</data>
<data name="MoveButtonContainer.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="MoveButtonContainer.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="MoveButtonContainer.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
@ -312,6 +297,39 @@
<data name="&gt;&gt;MoveButtonContainer.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="EditButton.Enabled" type="System.Boolean, mscorlib">
<value>False</value>
</data>
<data name="EditButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="EditButton.Location" type="System.Drawing.Point, System.Drawing">
<value>402, 2</value>
</data>
<data name="EditButton.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="EditButton.Size" type="System.Drawing.Size, System.Drawing">
<value>96, 23</value>
</data>
<data name="EditButton.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="EditButton.Text" xml:space="preserve">
<value>P&amp;roperties</value>
</data>
<data name="&gt;&gt;EditButton.Name" xml:space="preserve">
<value>EditButton</value>
</data>
<data name="&gt;&gt;EditButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;EditButton.Parent" xml:space="preserve">
<value>flowLayoutPanel1</value>
</data>
<data name="&gt;&gt;EditButton.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="DeleteButton.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Fill</value>
</data>
@ -325,7 +343,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="DeleteButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DeleteButton.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -346,10 +364,13 @@
<value>1</value>
</data>
<data name="DeleteButtonContainer.Location" type="System.Drawing.Point, System.Drawing">
<value>633, 3</value>
<value>502, 2</value>
</data>
<data name="DeleteButtonContainer.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="DeleteButtonContainer.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DeleteButtonContainer.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
@ -379,7 +400,7 @@
<value>0, 0, 0, 0</value>
</data>
<data name="DetachButton.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DetachButton.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -400,10 +421,13 @@
<value>1</value>
</data>
<data name="DetachButtonContainer.Location" type="System.Drawing.Point, System.Drawing">
<value>759, 3</value>
<value>602, 2</value>
</data>
<data name="DetachButtonContainer.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="DetachButtonContainer.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 29</value>
<value>96, 23</value>
</data>
<data name="DetachButtonContainer.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
@ -424,10 +448,13 @@
<value>Fill</value>
</data>
<data name="flowLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 367</value>
<value>2, 252</value>
</data>
<data name="flowLayoutPanel1.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>2, 2, 2, 2</value>
</data>
<data name="flowLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>995, 92</value>
<value>796, 64</value>
</data>
<data name="flowLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
@ -444,69 +471,6 @@
<data name="&gt;&gt;flowLayoutPanel1.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="toolStripMenuItemAdd.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemAdd.Text" xml:space="preserve">
<value>&amp;Add...</value>
</data>
<data name="toolStripMenuItemAttach.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemAttach.Text" xml:space="preserve">
<value>Attach Dis&amp;k...</value>
</data>
<data name="toolStripMenuItemDeactivate.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemDeactivate.Text" xml:space="preserve">
<value>Dea&amp;ctivate</value>
</data>
<data name="toolStripMenuItemMove.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemMove.Text" xml:space="preserve">
<value>&amp;Move...</value>
</data>
<data name="toolStripMenuItemDelete.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemDelete.Text" xml:space="preserve">
<value>&amp;Delete</value>
</data>
<data name="toolStripMenuItemDetach.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemDetach.Text" xml:space="preserve">
<value>D&amp;etach</value>
</data>
<data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
<value>165, 6</value>
</data>
<data name="toolStripMenuItemProperties.ImageScaling" type="System.Windows.Forms.ToolStripItemImageScaling, System.Windows.Forms">
<value>None</value>
</data>
<data name="toolStripMenuItemProperties.Size" type="System.Drawing.Size, System.Drawing">
<value>168, 26</value>
</data>
<data name="toolStripMenuItemProperties.Text" xml:space="preserve">
<value>P&amp;roperties</value>
</data>
<data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>169, 192</value>
</data>
<data name="&gt;&gt;contextMenuStrip1.Name" xml:space="preserve">
<value>contextMenuStrip1</value>
</data>
<data name="&gt;&gt;contextMenuStrip1.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="tableLayoutPanel1.ColumnCount" type="System.Int32, mscorlib">
<value>1</value>
</data>
<metadata name="ColumnDevicePosition.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
@ -598,16 +562,16 @@
<value>Fill</value>
</data>
<data name="dataGridViewStorage.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 75</value>
<value>2, 50</value>
</data>
<data name="dataGridViewStorage.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 12</value>
<value>2, 2, 2, 10</value>
</data>
<data name="dataGridViewStorage.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>1125, 0</value>
<value>900, 0</value>
</data>
<data name="dataGridViewStorage.Size" type="System.Drawing.Size, System.Drawing">
<value>995, 277</value>
<value>796, 190</value>
</data>
<data name="dataGridViewStorage.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -628,16 +592,16 @@
<value>Top</value>
</data>
<data name="multipleDvdIsoList1.Location" type="System.Drawing.Point, System.Drawing">
<value>15, 15</value>
<value>2, 2</value>
</data>
<data name="multipleDvdIsoList1.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>3, 3, 3, 12</value>
<value>2, 2, 2, 10</value>
</data>
<data name="multipleDvdIsoList1.MaximumSize" type="System.Drawing.Size, System.Drawing">
<value>1125, 45</value>
<value>900, 36</value>
</data>
<data name="multipleDvdIsoList1.Size" type="System.Drawing.Size, System.Drawing">
<value>995, 45</value>
<value>796, 36</value>
</data>
<data name="multipleDvdIsoList1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
@ -658,16 +622,13 @@
<value>Fill</value>
</data>
<data name="tableLayoutPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 46</value>
</data>
<data name="tableLayoutPanel1.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>12, 12, 12, 12</value>
<value>10, 10</value>
</data>
<data name="tableLayoutPanel1.RowCount" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="tableLayoutPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>1025, 474</value>
<value>800, 318</value>
</data>
<data name="tableLayoutPanel1.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@ -679,82 +640,91 @@
<value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.Parent" xml:space="preserve">
<value>$this</value>
<value>pageContainerPanel</value>
</data>
<data name="&gt;&gt;tableLayoutPanel1.ZOrder" xml:space="preserve">
<value>1</value>
<value>0</value>
</data>
<data name="tableLayoutPanel1.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
<value>&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;TableLayoutSettings&gt;&lt;Controls&gt;&lt;Control Name="flowLayoutPanel1" Row="2" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="dataGridViewStorage" Row="1" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;Control Name="multipleDvdIsoList1" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /&gt;&lt;/Controls&gt;&lt;Columns Styles="Percent,100" /&gt;&lt;Rows Styles="AutoSize,0,Percent,75,Percent,25" /&gt;&lt;/TableLayoutSettings&gt;</value>
</data>
<data name="TitleLabel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Bottom, Left, Right</value>
<data name="pageContainerPanel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 78</value>
</data>
<data name="TitleLabel.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 11.25pt</value>
<data name="pageContainerPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>820, 338</value>
</data>
<data name="TitleLabel.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
<data name="&gt;&gt;pageContainerPanel.Name" xml:space="preserve">
<value>pageContainerPanel</value>
</data>
<data name="TitleLabel.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
<data name="&gt;&gt;pageContainerPanel.Type" xml:space="preserve">
<value>System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="TitleLabel.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 0, 4, 0</value>
</data>
<data name="TitleLabel.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>10, 0, 0, 0</value>
</data>
<data name="TitleLabel.Size" type="System.Drawing.Size, System.Drawing">
<value>1004, 46</value>
</data>
<data name="TitleLabel.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="TitleLabel.Text" xml:space="preserve">
<value>Virtual Disks</value>
</data>
<data name="TitleLabel.TextAlign" type="System.Drawing.ContentAlignment, System.Drawing">
<value>MiddleLeft</value>
</data>
<data name="&gt;&gt;TitleLabel.Name" xml:space="preserve">
<value>TitleLabel</value>
</data>
<data name="&gt;&gt;TitleLabel.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;TitleLabel.Parent" xml:space="preserve">
<value>gradientPanel1</value>
</data>
<data name="&gt;&gt;TitleLabel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="gradientPanel1.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
<value>Top</value>
</data>
<data name="gradientPanel1.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>
<data name="gradientPanel1.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="gradientPanel1.Size" type="System.Drawing.Size, System.Drawing">
<value>1025, 46</value>
</data>
<data name="gradientPanel1.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="&gt;&gt;gradientPanel1.Name" xml:space="preserve">
<value>gradientPanel1</value>
</data>
<data name="&gt;&gt;gradientPanel1.Type" xml:space="preserve">
<value>XenAdmin.Controls.GradientPanel.GradientPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
<data name="&gt;&gt;gradientPanel1.Parent" xml:space="preserve">
<data name="&gt;&gt;pageContainerPanel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;gradientPanel1.ZOrder" xml:space="preserve">
<value>2</value>
<data name="&gt;&gt;pageContainerPanel.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="toolStripMenuItemAdd.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemAdd.Text" xml:space="preserve">
<value>&amp;Add...</value>
</data>
<data name="toolStripMenuItemAttach.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemAttach.Text" xml:space="preserve">
<value>Attach Dis&amp;k...</value>
</data>
<data name="toolStripMenuItemDeactivate.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemDeactivate.Text" xml:space="preserve">
<value>Dea&amp;ctivate</value>
</data>
<data name="toolStripMenuItemMove.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemMove.Text" xml:space="preserve">
<value>&amp;Move...</value>
</data>
<data name="toolStripMenuItemDelete.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemDelete.Text" xml:space="preserve">
<value>&amp;Delete</value>
</data>
<data name="toolStripMenuItemDetach.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemDetach.Text" xml:space="preserve">
<value>D&amp;etach</value>
</data>
<data name="toolStripSeparator1.Size" type="System.Drawing.Size, System.Drawing">
<value>140, 6</value>
</data>
<data name="toolStripMenuItemProperties.ImageScaling" type="System.Windows.Forms.ToolStripItemImageScaling, System.Windows.Forms">
<value>None</value>
</data>
<data name="toolStripMenuItemProperties.Size" type="System.Drawing.Size, System.Drawing">
<value>143, 22</value>
</data>
<data name="toolStripMenuItemProperties.Text" xml:space="preserve">
<value>P&amp;roperties</value>
</data>
<data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 164</value>
</data>
<data name="&gt;&gt;contextMenuStrip1.Name" xml:space="preserve">
<value>contextMenuStrip1</value>
</data>
<data name="&gt;&gt;contextMenuStrip1.Type" xml:space="preserve">
<value>System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="dataGridViewTextBoxColumn1.HeaderText" xml:space="preserve">
<value>Name</value>
@ -793,7 +763,7 @@
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>120, 120</value>
<value>96, 96</value>
</data>
<data name="$this.Font" type="System.Drawing.Font, System.Drawing">
<value>Segoe UI, 8.25pt</value>
@ -805,7 +775,7 @@
<value>No</value>
</data>
<data name="$this.Size" type="System.Drawing.Size, System.Drawing">
<value>1025, 520</value>
<value>820, 416</value>
</data>
<data name="&gt;&gt;toolStripMenuItemAdd.Name" xml:space="preserve">
<value>toolStripMenuItemAdd</value>
@ -979,6 +949,6 @@
<value>VMStoragePage</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>XenAdmin.TabPages.BaseTabPage, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</value>
</data>
</root>

View File

@ -15,7 +15,7 @@
{
if (disposing)
{
ConnectionsManager.XenConnections.CollectionChanged -= CollectionChanged;
UnregisterHandlers();
if (components != null)
components.Dispose();

View File

@ -54,6 +54,7 @@ namespace XenAdmin.Wizards.GenericPages
private bool updatingDestinationCombobox;
private bool m_buttonNextEnabled;
protected List<IXenConnection> ignoredConnections = new List<IXenConnection>();
private readonly CollectionChangeEventHandler Host_CollectionChangedWithInvoke;
/// <summary>
/// Combobox item that can executes a command but also be an IEnableableComboBoxItem
@ -80,6 +81,7 @@ namespace XenAdmin.Wizards.GenericPages
{
InitializeComponent();
InitializeText();
Host_CollectionChangedWithInvoke = Program.ProgramInvokeHandler(CollectionChanged);
ConnectionsManager.XenConnections.CollectionChanged += CollectionChanged;
ShowWarning(null);
}
@ -307,7 +309,7 @@ namespace XenAdmin.Wizards.GenericPages
xenConnection.ConnectionStateChanged += xenConnection_ConnectionStateChanged;
xenConnection.CachePopulated -= xenConnection_CachePopulated;
xenConnection.CachePopulated += xenConnection_CachePopulated;
xenConnection.Cache.RegisterCollectionChanged<Host>(Program.ProgramInvokeHandler(CollectionChanged));
xenConnection.Cache.RegisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
}
m_comboBoxConnection.Items.Add(new AddHostExecutingComboBoxItem());
@ -607,5 +609,28 @@ namespace XenAdmin.Wizards.GenericPages
}
#endregion
private void UnregisterHandlers()
{
ConnectionsManager.XenConnections.CollectionChanged -= CollectionChanged;
foreach (var xenConnection in ConnectionsManager.XenConnectionsCopy)
{
var pool = Helpers.GetPool(xenConnection);
if (pool == null)
{
var host = Helpers.GetMaster(xenConnection);
if (host != null)
host.PropertyChanged -= PropertyChanged;
}
else
{
pool.PropertyChanged -= PropertyChanged;
}
xenConnection.ConnectionStateChanged -= xenConnection_ConnectionStateChanged;
xenConnection.CachePopulated -= xenConnection_CachePopulated;
xenConnection.Cache.DeregisterCollectionChanged<Host>(Host_CollectionChangedWithInvoke);
}
}
}
}