From 3be1d02a11345824887146495342f90103881c7c Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 18 Oct 2023 00:11:55 +0100 Subject: [PATCH 1/6] Minor code smells. Signed-off-by: Konstantina Chremmou --- XenAdmin/Controls/MultipleDvdIsoList.cs | 87 ++++++++++--------- .../Actions/VBD/VbdCreateAndPlugAction.cs | 8 +- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index 5783240024..b923627245 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -44,7 +44,7 @@ namespace XenAdmin.Controls { public partial class MultipleDvdIsoList : UserControl { - bool inRefresh = false; + private bool _inRefresh; public MultipleDvdIsoList() { @@ -61,7 +61,7 @@ public VM VM cdChanger1.VM = value; if (value != null) cdChanger1.VM.PropertyChanged += vm_PropertyChanged; - refreshDrives(); + RefreshDrives(); } get => cdChanger1.VM; } @@ -72,24 +72,24 @@ public VM VM [Category("Appearance")] public Color LabelSingleDvdForeColor { - get { return labelSingleDvd.ForeColor; } - set { labelSingleDvd.ForeColor = value; } + get => labelSingleDvd.ForeColor; + set => labelSingleDvd.ForeColor = value; } [Browsable(true)] [Category("Appearance")] public Color LabelNewCdForeColor { - get { return newCDLabel.ForeColor; } - set { newCDLabel.ForeColor = value; } + get => newCDLabel.ForeColor; + set => newCDLabel.ForeColor = value; } [Browsable(true)] [Category("Appearance")] public Color LinkLabelLinkColor { - get { return linkLabel1.LinkColor; } - set { linkLabel1.LinkColor = value; } + get => linkLabel1.LinkColor; + set => linkLabel1.LinkColor = value; } #endregion @@ -115,24 +115,25 @@ internal virtual void DeregisterEvents() cdChanger1.DeregisterEvents(); } - void vm_PropertyChanged(object sender, PropertyChangedEventArgs e) + private void vm_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "VBDs") - refreshDrives(); + RefreshDrives(); } - private void refreshDrives() + private void RefreshDrives() { VbdCombiItem prevSelection = comboBoxDrive.SelectedItem as VbdCombiItem; - inRefresh = true; + _inRefresh = true; foreach (object o in comboBoxDrive.Items) { - VbdCombiItem v = o as VbdCombiItem; - v.vbd.PropertyChanged -= new PropertyChangedEventHandler(vbd_PropertyChanged); + if (o is VbdCombiItem v) + v.Vbd.PropertyChanged -= vbd_PropertyChanged; } comboBoxDrive.Items.Clear(); + if (VM != null && !VM.is_control_domain) { List vbds = VM.Connection.ResolveAll(VM.VBDs); @@ -142,31 +143,32 @@ private void refreshDrives() VM.Connection.CachePopulated += CachePopulatedMethod; return; } + vbds.RemoveAll(vbd => !vbd.IsCDROM() && !vbd.IsFloppyDrive()); vbds.Sort(); + int dvdCount = 0; int floppyCount = 0; + foreach (VBD vbd in vbds) { - vbd.PropertyChanged +=new PropertyChangedEventHandler(vbd_PropertyChanged); + vbd.PropertyChanged += vbd_PropertyChanged; + VbdCombiItem item; + if (vbd.IsCDROM()) { dvdCount++; - VbdCombiItem i = new VbdCombiItem(); - i.name = string.Format(Messages.DVD_DRIVE_LABEL_NUMBERED, dvdCount); - i.vbd = vbd; - comboBoxDrive.Items.Add(i); + item = new VbdCombiItem(string.Format(Messages.DVD_DRIVE_LABEL_NUMBERED, dvdCount), vbd); } else { floppyCount++; - VbdCombiItem i = new VbdCombiItem(); - i.name = string.Format(Messages.FLOPPY_DRIVE_LABEL_NUMBERED, floppyCount); - i.vbd = vbd; - comboBoxDrive.Items.Add(i); - } + item = new VbdCombiItem(string.Format(Messages.FLOPPY_DRIVE_LABEL_NUMBERED, floppyCount), vbd); + } + comboBoxDrive.Items.Add(item); } } + if (comboBoxDrive.Items.Count == 0) { comboBoxDrive.Visible = false; @@ -197,54 +199,59 @@ private void refreshDrives() newCDLabel.Visible = false; linkLabel1.Visible = true; } - inRefresh = false; + + _inRefresh = false; + // Restore prev selection or select the top item by default if (prevSelection != null) { foreach (object o in comboBoxDrive.Items) { - VbdCombiItem v = o as VbdCombiItem; - if (v.vbd.uuid == prevSelection.vbd.uuid) + if (o is VbdCombiItem v && v.Vbd.uuid == prevSelection.Vbd.uuid) { comboBoxDrive.SelectedItem = o; return; } } } - if (comboBoxDrive.Items.Count == 0) - comboBoxDrive.SelectedItem = null; - else - comboBoxDrive.SelectedItem = comboBoxDrive.Items[0]; + + comboBoxDrive.SelectedItem = comboBoxDrive.Items.Count == 0 ? null : comboBoxDrive.Items[0]; } - void vbd_PropertyChanged(object sender, PropertyChangedEventArgs e) + private void vbd_PropertyChanged(object sender, PropertyChangedEventArgs e) { - refreshDrives(); + RefreshDrives(); } private void CachePopulatedMethod(IXenConnection conn) { VM.Connection.CachePopulated -= CachePopulatedMethod; - refreshDrives(); + RefreshDrives(); } - internal class VbdCombiItem + private class VbdCombiItem { - public string name; - public VBD vbd; + public string Name { get; } + public VBD Vbd { get; } + + public VbdCombiItem(string name, VBD vbd) + { + Name = name; + Vbd = vbd; + } public override string ToString() { - return name; + return Name; } } private void comboBoxDrive_SelectedIndexChanged(object sender, EventArgs e) { - if (inRefresh) + if (_inRefresh) return; - cdChanger1.Drive = (comboBoxDrive.SelectedItem as VbdCombiItem)?.vbd; + cdChanger1.Drive = (comboBoxDrive.SelectedItem as VbdCombiItem)?.Vbd; } diff --git a/XenModel/Actions/VBD/VbdCreateAndPlugAction.cs b/XenModel/Actions/VBD/VbdCreateAndPlugAction.cs index a54320365c..7d33de9542 100644 --- a/XenModel/Actions/VBD/VbdCreateAndPlugAction.cs +++ b/XenModel/Actions/VBD/VbdCreateAndPlugAction.cs @@ -62,7 +62,7 @@ public VbdCreateAndPlugAction(VM vm, VBD vbd, string vdiName, bool suppress) protected override void Run() { - string vbdServerRef = VBD.create(Session, vbd); + string vbdRef = VBD.create(Session, vbd); if (!VM.IsHVM() && vbd.empty) { @@ -71,12 +71,12 @@ protected override void Run() } // Then if we can plug the vbd in, do so... - if (vbdServerRef != null && - VBD.get_allowed_operations(Session, vbdServerRef).Contains(vbd_operations.plug)) + if (vbdRef != null && + VBD.get_allowed_operations(Session, vbdRef).Contains(vbd_operations.plug)) { log.DebugFormat("Attempting to hot plug VBD {0}.", vbd.uuid); - RelatedTask = VBD.async_plug(Session, vbdServerRef); + RelatedTask = VBD.async_plug(Session, vbdRef); PollToCompletion(); Description = Messages.ATTACHDISKWIZARD_ATTACHED; } From fcd9b195f6d00146d7e21d3d221791f3442bfcf1 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 18 Oct 2023 00:51:02 +0100 Subject: [PATCH 2/6] Minor layout tweaks (margins, padding, alignment). Signed-off-by: Konstantina Chremmou --- .../Controls/ComboBoxes/ISODropDownBox.cs | 2 + .../Controls/MultipleDvdIsoList.Designer.cs | 33 +-- XenAdmin/Controls/MultipleDvdIsoList.cs | 15 +- XenAdmin/Controls/MultipleDvdIsoList.resx | 218 +++++++----------- 4 files changed, 98 insertions(+), 170 deletions(-) diff --git a/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs b/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs index d7d1f202b5..45e85dc16e 100644 --- a/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs +++ b/XenAdmin/Controls/ComboBoxes/ISODropDownBox.cs @@ -232,6 +232,8 @@ private void AddSR(ToStringWrapper srWrapper) } } + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public IXenConnection connection { set diff --git a/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs b/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs index 8c0f39680c..048d614f53 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs @@ -36,11 +36,9 @@ private void InitializeComponent() this.newCDLabel = new System.Windows.Forms.Label(); this.comboBoxDrive = new System.Windows.Forms.ComboBox(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.panel1 = new System.Windows.Forms.Panel(); this.cdChanger1 = new XenAdmin.Controls.CDChanger(); - this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.linkLabelEject = new System.Windows.Forms.LinkLabel(); this.tableLayoutPanel1.SuspendLayout(); - this.panel1.SuspendLayout(); this.SuspendLayout(); // // labelSingleDvd @@ -51,6 +49,7 @@ private void InitializeComponent() // newCDLabel // resources.ApplyResources(this.newCDLabel, "newCDLabel"); + this.tableLayoutPanel1.SetColumnSpan(this.newCDLabel, 4); this.newCDLabel.Cursor = System.Windows.Forms.Cursors.Hand; this.newCDLabel.ForeColor = System.Drawing.SystemColors.HotTrack; this.newCDLabel.Name = "newCDLabel"; @@ -69,20 +68,13 @@ private void InitializeComponent() resources.ApplyResources(this.tableLayoutPanel1, "tableLayoutPanel1"); this.tableLayoutPanel1.Controls.Add(this.labelSingleDvd, 0, 0); this.tableLayoutPanel1.Controls.Add(this.comboBoxDrive, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.newCDLabel, 2, 1); - this.tableLayoutPanel1.Controls.Add(this.panel1, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.cdChanger1, 2, 0); + this.tableLayoutPanel1.Controls.Add(this.linkLabelEject, 3, 0); + this.tableLayoutPanel1.Controls.Add(this.newCDLabel, 0, 1); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; // - // panel1 - // - resources.ApplyResources(this.panel1, "panel1"); - this.panel1.Controls.Add(this.cdChanger1); - this.panel1.Controls.Add(this.linkLabel1); - this.panel1.Name = "panel1"; - // // cdChanger1 // - this.cdChanger1.connection = null; resources.ApplyResources(this.cdChanger1, "cdChanger1"); this.cdChanger1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.cdChanger1.DropDownHeight = 500; @@ -90,12 +82,12 @@ private void InitializeComponent() this.cdChanger1.FormattingEnabled = true; this.cdChanger1.Name = "cdChanger1"; // - // linkLabel1 + // linkLabelEject // - resources.ApplyResources(this.linkLabel1, "linkLabel1"); - this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.TabStop = true; - this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + resources.ApplyResources(this.linkLabelEject, "linkLabelEject"); + this.linkLabelEject.Name = "linkLabelEject"; + this.linkLabelEject.TabStop = true; + this.linkLabelEject.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabelEject_LinkClicked); // // MultipleDvdIsoList // @@ -105,8 +97,6 @@ private void InitializeComponent() this.Name = "MultipleDvdIsoList"; this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); this.ResumeLayout(false); } @@ -118,7 +108,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox comboBoxDrive; private System.Windows.Forms.Label newCDLabel; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.LinkLabel linkLabelEject; } } diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index b923627245..9a8f22bfc3 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -88,8 +88,8 @@ public Color LabelNewCdForeColor [Category("Appearance")] public Color LinkLabelLinkColor { - get => linkLabel1.LinkColor; - set => linkLabel1.LinkColor = value; + get => linkLabelEject.LinkColor; + set => linkLabelEject.LinkColor = value; } #endregion @@ -174,8 +174,7 @@ private void RefreshDrives() comboBoxDrive.Visible = false; cdChanger1.Visible = false; labelSingleDvd.Visible = false; - linkLabel1.Visible = false; - panel1.Visible = false; + linkLabelEject.Visible = false; newCDLabel.Visible = VM != null && !VM.is_control_domain; } @@ -187,17 +186,15 @@ private void RefreshDrives() labelSingleDvd.Visible = true; tableLayoutPanel1.ColumnStyles[0].Width = labelSingleDvd.Width; newCDLabel.Visible = false; - panel1.Visible = true; - linkLabel1.Visible = true; + linkLabelEject.Visible = true; } else { comboBoxDrive.Visible = true; cdChanger1.Visible = true; labelSingleDvd.Visible = false; - panel1.Visible = true; newCDLabel.Visible = false; - linkLabel1.Visible = true; + linkLabelEject.Visible = true; } _inRefresh = false; @@ -279,7 +276,7 @@ private void CreateDriveAction_ShowUserInstruction(string message) }); } - private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void linkLabelEject_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (cdChanger1.Drive != null) cdChanger1.ChangeCD(null); diff --git a/XenAdmin/Controls/MultipleDvdIsoList.resx b/XenAdmin/Controls/MultipleDvdIsoList.resx index c0590c8d7f..38965f8799 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.resx +++ b/XenAdmin/Controls/MultipleDvdIsoList.resx @@ -117,39 +117,30 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Left + True - - - Fill - NoControl - 3, 8 - - - 3, 8, 3, 5 - - - 100, 23 + 3, 7 - 61, 15 + 61, 13 - 1 + 0 DVD Dr&ive: - - TopRight - labelSingleDvd @@ -162,65 +153,23 @@ 0 + + Left, Right + True - - Fill - - - Microsoft Sans Serif, 8.25pt, style=Bold, Underline - - - NoControl - - - 173, 30 - - - 0, 2, 2, 0 - - - 942, 47 - - - 3 - - - Click here to create a DVD drive - - - MiddleLeft - - - False - - - newCDLabel - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel1 - - - 2 + + 4 - 70, 4 - - - 3, 4, 3, 3 - - - 120, 0 + 70, 3 100, 21 - 2 + 1 False @@ -237,17 +186,8 @@ 1 - - 4 - - - True - - - GrowAndShrink - - - Fill + + Left, Right False @@ -256,93 +196,57 @@ 15 - 0, 5 + 176, 3 - 907, 21 + 456, 21 - 0 + 2 cdChanger1 - XenAdmin.Controls.CDChanger, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.CDChanger, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - panel1 + tableLayoutPanel1 - 0 + 2 - - True + + Left - - Right + + True - + NoControl - - 907, 5 + + 638, 7 - - 3, 3, 3, 3 + + 31, 13 - - 3, 5, 3, 3 - - - 37, 21 - - - 1 + + 3 - + Eject - - linkLabel1 + + linkLabelEject - + System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - panel1 - - - 1 - - - Fill - - - 173, 0 - - - 0, 0, 0, 0 - - - 0, 5, 0, 5 - - - 944, 28 - - - 40 - - - panel1 - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + tableLayoutPanel1 - + 3 @@ -355,10 +259,10 @@ 2 - 1117, 77 + 672, 77 - 40 + 0 tableLayoutPanel1 @@ -373,7 +277,43 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSingleDvd" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxDrive" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="newCDLabel" Row="1" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="panel1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSingleDvd" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxDrive" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="cdChanger1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="linkLabelEject" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="newCDLabel" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + + + Microsoft Sans Serif, 8.25pt, style=Bold, Underline + + + NoControl + + + 3, 45 + + + 666, 13 + + + 4 + + + Click here to create a DVD drive + + + TopCenter + + + False + + + newCDLabel + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel1 + + + 4 True @@ -382,7 +322,7 @@ 96, 96 - 1117, 77 + 672, 77 MultipleDvdIsoList From 85347aa95c9ad3e17264e86aec15fbb2fa933f6e Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 1 Nov 2023 00:27:46 +0000 Subject: [PATCH 3/6] CP-43651: Ask for confirmation when the user clicks to create a DVD drive. Signed-off-by: Konstantina Chremmou --- XenAdmin/Controls/MultipleDvdIsoList.cs | 23 ++++++++++++++++------- XenModel/Messages.Designer.cs | 20 ++++++++++++++++++++ XenModel/Messages.resx | 8 ++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index 9a8f22bfc3..621023d36d 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -251,17 +251,26 @@ private void comboBoxDrive_SelectedIndexChanged(object sender, EventArgs e) cdChanger1.Drive = (comboBoxDrive.SelectedItem as VbdCombiItem)?.Vbd; } - private void newCDLabel_Click(object sender, EventArgs e) { - if (VM != null) - { - var createDriveAction = new CreateCdDriveAction(VM); - createDriveAction.ShowUserInstruction += CreateDriveAction_ShowUserInstruction; + if (VM == null) + return; - using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) - dlg.ShowDialog(this); + if (VM.IsHVM()) + { + using (var dialog = new WarningDialog( + string.Format(Messages.NEW_DVD_DRIVE_CREATE_CONFIRMATION, VM.Name()), + new ThreeButtonDialog.TBDButton(Messages.NEW_DVD_DRIVE_CREATE_YES_BUTTON, DialogResult.Yes, ThreeButtonDialog.ButtonType.ACCEPT, true), + ThreeButtonDialog.ButtonNo)) + if (dialog.ShowDialog(Program.MainWindow) != DialogResult.Yes) + return; } + + var createDriveAction = new CreateCdDriveAction(VM); + createDriveAction.ShowUserInstruction += CreateDriveAction_ShowUserInstruction; + + using (var dlg = new ActionProgressDialog(createDriveAction, ProgressBarStyle.Marquee)) + dlg.ShowDialog(this); } private void CreateDriveAction_ShowUserInstruction(string message) diff --git a/XenModel/Messages.Designer.cs b/XenModel/Messages.Designer.cs index bf9759448b..54493ad622 100755 --- a/XenModel/Messages.Designer.cs +++ b/XenModel/Messages.Designer.cs @@ -26209,6 +26209,17 @@ public static string NEVER { } } + /// + /// Looks up a localized string similar to Are you sure you want to create a new DVD drive on VM '{0}'? + /// + ///This action will create a new Virtual Block Device (VBD) that cannot be hot-unplugged.. + /// + public static string NEW_DVD_DRIVE_CREATE_CONFIRMATION { + get { + return ResourceManager.GetString("NEW_DVD_DRIVE_CREATE_CONFIRMATION", resourceCulture); + } + } + /// /// Looks up a localized string similar to Creating new DVD drive on VM {0}. /// @@ -26218,6 +26229,15 @@ public static string NEW_DVD_DRIVE_CREATE_TITLE { } } + /// + /// Looks up a localized string similar to &Yes, Create. + /// + public static string NEW_DVD_DRIVE_CREATE_YES_BUTTON { + get { + return ResourceManager.GetString("NEW_DVD_DRIVE_CREATE_YES_BUTTON", resourceCulture); + } + } + /// /// Looks up a localized string similar to Creating new DVD drive. /// diff --git a/XenModel/Messages.resx b/XenModel/Messages.resx index c0ca9f5923..3e9565a6cd 100755 --- a/XenModel/Messages.resx +++ b/XenModel/Messages.resx @@ -9101,9 +9101,17 @@ You should only proceed if you have verified that these settings are correct. Never + + Are you sure you want to create a new DVD drive on VM '{0}'? + +This action will create a new Virtual Block Device (VBD) that cannot be hot-unplugged. + Creating new DVD drive on VM {0} + + &Yes, Create + Creating new DVD drive From 6f1daff1fc7a5027df45cf91584cf2b20b3fba0d Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 1 Nov 2023 00:47:51 +0000 Subject: [PATCH 4/6] Compacted logic that toggles control visibility. Signed-off-by: Konstantina Chremmou --- XenAdmin/Controls/MultipleDvdIsoList.cs | 33 ++++++------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/XenAdmin/Controls/MultipleDvdIsoList.cs b/XenAdmin/Controls/MultipleDvdIsoList.cs index 621023d36d..0376a4ae37 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.cs @@ -169,33 +169,14 @@ private void RefreshDrives() } } - if (comboBoxDrive.Items.Count == 0) - { - comboBoxDrive.Visible = false; - cdChanger1.Visible = false; - labelSingleDvd.Visible = false; - linkLabelEject.Visible = false; - newCDLabel.Visible = VM != null && !VM.is_control_domain; - - } - else if (comboBoxDrive.Items.Count == 1) - { - comboBoxDrive.Visible = false; - cdChanger1.Visible = true; + labelSingleDvd.Visible = comboBoxDrive.Items.Count == 1; + if (labelSingleDvd.Visible) labelSingleDvd.Text = comboBoxDrive.Items[0].ToString(); - labelSingleDvd.Visible = true; - tableLayoutPanel1.ColumnStyles[0].Width = labelSingleDvd.Width; - newCDLabel.Visible = false; - linkLabelEject.Visible = true; - } - else - { - comboBoxDrive.Visible = true; - cdChanger1.Visible = true; - labelSingleDvd.Visible = false; - newCDLabel.Visible = false; - linkLabelEject.Visible = true; - } + + comboBoxDrive.Visible = comboBoxDrive.Items.Count > 1; + cdChanger1.Visible = comboBoxDrive.Items.Count > 0; + linkLabelEject.Visible = comboBoxDrive.Items.Count > 0; + newCDLabel.Visible = comboBoxDrive.Items.Count == 0 && VM != null && !VM.is_control_domain; _inRefresh = false; From e28aa63aa5b42678045a7e6541a4075738130888 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 1 Nov 2023 01:17:52 +0000 Subject: [PATCH 5/6] The user could not create DVD from the Console TabPage while the same operation was possible from the VmStorage TabPage. Signed-off-by: Konstantina Chremmou --- XenAdmin/ConsoleView/VNCTabView.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/XenAdmin/ConsoleView/VNCTabView.cs b/XenAdmin/ConsoleView/VNCTabView.cs index bb3314f8c6..7a3e97b611 100644 --- a/XenAdmin/ConsoleView/VNCTabView.cs +++ b/XenAdmin/ConsoleView/VNCTabView.cs @@ -1291,10 +1291,12 @@ internal void VMPowerOff() { toggleConsoleButton.Enabled = false; - VBD cddrive = source.FindVMCDROM(); - bool allowEject = cddrive != null ? cddrive.allowed_operations.Contains(vbd_operations.eject) : false; - bool allowInsert = cddrive != null ? cddrive.allowed_operations.Contains(vbd_operations.insert) : false; - multipleDvdIsoList1.Enabled = (source.power_state == vm_power_state.Halted) && (allowEject || allowInsert); + VBD cdDrive = source.FindVMCDROM(); + + multipleDvdIsoList1.Enabled = cdDrive == null || + source.power_state == vm_power_state.Halted && + (cdDrive.allowed_operations.Contains(vbd_operations.eject) || + cdDrive.allowed_operations.Contains(vbd_operations.insert)); sendCAD.Enabled = false; } From 22e1973023b0166db1581d8dc1bde35aed3682f3 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Tue, 14 Nov 2023 17:00:02 +0000 Subject: [PATCH 6/6] Corrected positioning of DVD ISO list control. Signed-off-by: Konstantina Chremmou --- XenAdmin/ConsoleView/VNCTabView.Designer.cs | 22 +-- XenAdmin/ConsoleView/VNCTabView.resx | 136 ++++++++---------- .../Controls/MultipleDvdIsoList.Designer.cs | 1 + XenAdmin/Controls/MultipleDvdIsoList.resx | 23 ++- 4 files changed, 93 insertions(+), 89 deletions(-) diff --git a/XenAdmin/ConsoleView/VNCTabView.Designer.cs b/XenAdmin/ConsoleView/VNCTabView.Designer.cs index 88e6d596ed..848fb7298f 100644 --- a/XenAdmin/ConsoleView/VNCTabView.Designer.cs +++ b/XenAdmin/ConsoleView/VNCTabView.Designer.cs @@ -57,6 +57,7 @@ private void InitializeComponent() this.fullscreenButton = new System.Windows.Forms.Button(); this.dockButton = new System.Windows.Forms.Button(); this.tip = new System.Windows.Forms.ToolTip(this.components); + this.toggleConsoleButton = new System.Windows.Forms.Button(); this.LifeCycleMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); this.powerStateLabel = new System.Windows.Forms.Label(); this.dedicatedGpuWarning = new System.Windows.Forms.Label(); @@ -64,7 +65,6 @@ private void InitializeComponent() this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.HostLabel = new System.Windows.Forms.Label(); this.buttonSSH = new System.Windows.Forms.Button(); - this.toggleConsoleButton = new System.Windows.Forms.Button(); this.multipleDvdIsoList1 = new XenAdmin.Controls.MultipleDvdIsoList(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.tableLayoutPanel1.SuspendLayout(); @@ -136,6 +136,14 @@ private void InitializeComponent() // this.tip.ShowAlways = true; // + // toggleConsoleButton + // + resources.ApplyResources(this.toggleConsoleButton, "toggleConsoleButton"); + this.toggleConsoleButton.Name = "toggleConsoleButton"; + this.tip.SetToolTip(this.toggleConsoleButton, resources.GetString("toggleConsoleButton.ToolTip")); + this.toggleConsoleButton.UseVisualStyleBackColor = true; + this.toggleConsoleButton.Click += new System.EventHandler(this.toggleConsoleButton_Click); + // // LifeCycleMenuStrip // this.LifeCycleMenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); @@ -180,8 +188,8 @@ private void InitializeComponent() // // HostLabel // - this.HostLabel.AutoEllipsis = true; resources.ApplyResources(this.HostLabel, "HostLabel"); + this.HostLabel.AutoEllipsis = true; this.HostLabel.ForeColor = System.Drawing.Color.White; this.HostLabel.Name = "HostLabel"; // @@ -192,14 +200,6 @@ private void InitializeComponent() this.buttonSSH.UseVisualStyleBackColor = true; this.buttonSSH.Click += new System.EventHandler(this.buttonSSH_Click); // - // toggleConsoleButton - // - resources.ApplyResources(this.toggleConsoleButton, "toggleConsoleButton"); - this.toggleConsoleButton.Name = "toggleConsoleButton"; - this.tip.SetToolTip(this.toggleConsoleButton, resources.GetString("toggleConsoleButton.ToolTip")); - this.toggleConsoleButton.UseVisualStyleBackColor = true; - this.toggleConsoleButton.Click += new System.EventHandler(this.toggleConsoleButton_Click); - // // multipleDvdIsoList1 // resources.ApplyResources(this.multipleDvdIsoList1, "multipleDvdIsoList1"); @@ -254,7 +254,6 @@ private void InitializeComponent() private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.ContextMenuStrip LifeCycleMenuStrip; private System.Windows.Forms.PictureBox pictureBox1; - private XenAdmin.Controls.GradientPanel.GradientPanel gradientPanel1; private System.Windows.Forms.Label HostLabel; private System.Windows.Forms.Button toggleConsoleButton; private XenAdmin.Controls.MultipleDvdIsoList multipleDvdIsoList1; @@ -263,5 +262,6 @@ private void InitializeComponent() private System.Windows.Forms.Button buttonSSH; private System.Windows.Forms.PictureBox pictureBoxGeneralInformationMessage; private System.Windows.Forms.Label labelGeneralInformationMessage; + private Controls.GradientPanel.HorizontalGradientPanel gradientPanel1; } } diff --git a/XenAdmin/ConsoleView/VNCTabView.resx b/XenAdmin/ConsoleView/VNCTabView.resx index 09cd837d7a..4e22ae94c4 100644 --- a/XenAdmin/ConsoleView/VNCTabView.resx +++ b/XenAdmin/ConsoleView/VNCTabView.resx @@ -199,7 +199,7 @@ NoControl - 223, 4 + 223, 2 0, 0, 3, 0 @@ -208,7 +208,7 @@ 0, 30 - 200, 26 + 205, 30 5 @@ -429,6 +429,42 @@ 17, 17 + + Left + + + False + + + NoControl + + + 525, 6 + + + 175, 24 + + + 3 + + + Looking for guest console... + + + Remote access is not enabled on this guest + + + toggleConsoleButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tableLayoutPanel2 + + + 2 + 81, 17 @@ -513,12 +549,12 @@ 5 + + Left + True - - Fill - Segoe UI, 11.25pt @@ -526,20 +562,17 @@ NoControl - 3, 0 + 3, 8 8, 0, 0, 0 - 8, 37 + 8, 20 0 - - MiddleLeft - HostLabel @@ -553,7 +586,7 @@ 0 - Top, Right + Left True @@ -565,13 +598,10 @@ NoControl - 399, 6 - - - 3, 6, 6, 6 + 397, 7 - 114, 23 + 122, 23 2 @@ -591,56 +621,20 @@ 1 - - Top, Right + + Left, Right - - False - - - NoControl - - - 522, 6 - - - 3, 6, 6, 6 - - - 175, 24 - - - 3 - - - Looking for guest console... - - - Remote access is not enabled on this guest - - - toggleConsoleButton - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tableLayoutPanel2 - - - 2 + + True - - Fill + + GrowAndShrink - 47, 3 - - - 3, 3, 12, 3 + 47, 5 - 337, 31 + 344, 27 1 @@ -649,7 +643,7 @@ multipleDvdIsoList1 - XenAdmin.Controls.MultipleDvdIsoList, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.MultipleDvdIsoList, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null tableLayoutPanel2 @@ -657,26 +651,20 @@ 3 + + Left + None - - Fill - NoControl - 15, 1 - - - 1, 1, 1, 1 + 17, 6 - 28, 35 - - - CenterImage + 24, 24 8 @@ -730,7 +718,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="HostLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonSSH" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="toggleConsoleButton" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="multipleDvdIsoList1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pictureBox1" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="Percent,100,Absolute,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="HostLabel" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="buttonSSH" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="toggleConsoleButton" Row="0" RowSpan="1" Column="5" ColumnSpan="1" /><Control Name="multipleDvdIsoList1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="pictureBox1" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0,AutoSize,0" /><Rows Styles="Percent,100,Absolute,37" /></TableLayoutSettings> Top @@ -748,7 +736,7 @@ gradientPanel1 - XenAdmin.Controls.GradientPanel.GradientPanel, XenCenterMain, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + XenAdmin.Controls.GradientPanel.HorizontalGradientPanel, [XenCenter], Version=0.0.0.0, Culture=neutral, PublicKeyToken=null $this diff --git a/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs b/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs index 048d614f53..fbdb877e96 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs +++ b/XenAdmin/Controls/MultipleDvdIsoList.Designer.cs @@ -98,6 +98,7 @@ private void InitializeComponent() this.tableLayoutPanel1.ResumeLayout(false); this.tableLayoutPanel1.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } diff --git a/XenAdmin/Controls/MultipleDvdIsoList.resx b/XenAdmin/Controls/MultipleDvdIsoList.resx index 38965f8799..455c813df9 100644 --- a/XenAdmin/Controls/MultipleDvdIsoList.resx +++ b/XenAdmin/Controls/MultipleDvdIsoList.resx @@ -159,6 +159,12 @@ True + + True + + + GrowAndShrink + 4 @@ -259,7 +265,7 @@ 2 - 672, 77 + 672, 64 0 @@ -277,7 +283,7 @@ 0 - <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSingleDvd" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxDrive" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="cdChanger1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="linkLabelEject" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="newCDLabel" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,Percent,100" /></TableLayoutSettings> + <?xml version="1.0" encoding="utf-16"?><TableLayoutSettings><Controls><Control Name="labelSingleDvd" Row="0" RowSpan="1" Column="0" ColumnSpan="1" /><Control Name="comboBoxDrive" Row="0" RowSpan="1" Column="1" ColumnSpan="1" /><Control Name="cdChanger1" Row="0" RowSpan="1" Column="2" ColumnSpan="1" /><Control Name="linkLabelEject" Row="0" RowSpan="1" Column="3" ColumnSpan="1" /><Control Name="newCDLabel" Row="1" RowSpan="1" Column="0" ColumnSpan="4" /></Controls><Columns Styles="AutoSize,0,AutoSize,0,Percent,100,AutoSize,0" /><Rows Styles="AutoSize,0,AutoSize,0" /></TableLayoutSettings> Microsoft Sans Serif, 8.25pt, style=Bold, Underline @@ -286,7 +292,10 @@ NoControl - 3, 45 + 3, 39 + + + 3, 12, 3, 12 666, 13 @@ -321,8 +330,14 @@ 96, 96 + + True + + + GrowAndShrink + - 672, 77 + 672, 64 MultipleDvdIsoList