From a61f61d66fe6959a8fb4a294d67990d157584f7e Mon Sep 17 00:00:00 2001 From: Danilo Del Busso Date: Fri, 17 Sep 2021 16:09:58 +0100 Subject: [PATCH] CP-36392: Remove duplicate field in `MultipleDvdIsoList.cs` Also remove `VM` from designer Signed-off-by: Danilo Del Busso --- XenAdmin/ConsoleView/VNCTabView.Designer.cs | 1 - XenAdmin/Controls/MultipleDvdIsoList.cs | 25 +++++++++------------ XenAdmin/TabPages/VMStoragePage.Designer.cs | 1 - 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/XenAdmin/ConsoleView/VNCTabView.Designer.cs b/XenAdmin/ConsoleView/VNCTabView.Designer.cs index 6d723eb91..88e6d596e 100644 --- a/XenAdmin/ConsoleView/VNCTabView.Designer.cs +++ b/XenAdmin/ConsoleView/VNCTabView.Designer.cs @@ -207,7 +207,6 @@ namespace XenAdmin.ConsoleView this.multipleDvdIsoList1.LabelSingleDvdForeColor = System.Drawing.SystemColors.ControlText; this.multipleDvdIsoList1.LinkLabelLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); this.multipleDvdIsoList1.Name = "multipleDvdIsoList1"; - this.multipleDvdIsoList1.VM = null; // // pictureBox1 // diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index 040702964..92188c139 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -51,23 +51,20 @@ namespace XenAdmin.Controls { InitializeComponent(); } - - private VM vm; + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public VM VM { set { DeregisterEvents(); cdChanger1.VM = value; - vm = value; - if (vm != null) - vm.PropertyChanged += vm_PropertyChanged; + if (value != null) + cdChanger1.VM.PropertyChanged += vm_PropertyChanged; refreshDrives(); } - get - { - return cdChanger1.VM; - } + get => cdChanger1.VM; } #region Designer browsable properties @@ -100,17 +97,17 @@ namespace XenAdmin.Controls internal virtual void DeregisterEvents() { - if (vm == null) + if (VM == null) return; // remove VM listeners - vm.PropertyChanged -= vm_PropertyChanged; + VM.PropertyChanged -= vm_PropertyChanged; // remove cache listener - vm.Connection.CachePopulated -= CachePopulatedMethod; + VM.Connection.CachePopulated -= CachePopulatedMethod; // remove VBD listeners - var vbds = vm.Connection.ResolveAll(VM.VBDs); + var vbds = VM.Connection.ResolveAll(VM.VBDs); foreach (var vbd in vbds.Where(vbd => vbd.IsCDROM() || vbd.IsFloppyDrive())) { @@ -178,7 +175,7 @@ namespace XenAdmin.Controls labelSingleDvd.Visible = false; linkLabel1.Visible = false; panel1.Visible = false; - newCDLabel.Visible = vm != null && !vm.is_control_domain; + newCDLabel.Visible = VM != null && !VM.is_control_domain; } else if (comboBoxDrive.Items.Count == 1) diff --git a/XenAdmin/TabPages/VMStoragePage.Designer.cs b/XenAdmin/TabPages/VMStoragePage.Designer.cs index b15a6359d..74cc46cd6 100644 --- a/XenAdmin/TabPages/VMStoragePage.Designer.cs +++ b/XenAdmin/TabPages/VMStoragePage.Designer.cs @@ -348,7 +348,6 @@ namespace XenAdmin.TabPages this.multipleDvdIsoList1.LabelSingleDvdForeColor = System.Drawing.SystemColors.ControlText; this.multipleDvdIsoList1.LinkLabelLinkColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); this.multipleDvdIsoList1.Name = "multipleDvdIsoList1"; - this.multipleDvdIsoList1.VM = null; // // dataGridViewTextBoxColumn1 //