From b9c5678ad54a40a3a8ba70f0ccff39e16168fd3e Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Wed, 1 Nov 2023 00:47:51 +0000 Subject: [PATCH] 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 621023d36..0376a4ae3 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;