From 501970dec557654229d22bb40f5e2881c343afa1 Mon Sep 17 00:00:00 2001 From: Konstantina Chremmou Date: Mon, 10 Feb 2020 15:45:16 +0000 Subject: [PATCH] Name explicitly the control to be focused on page load. No need to search through all the controls of the page. Signed-off-by: Konstantina Chremmou --- XenAdmin/Core/HelpersGUI.cs | 39 ------------------- .../NewNetworkWizard_Pages/NetWBondDetails.cs | 6 --- .../NewNetworkWizard_Pages/NetWChinDetails.cs | 2 +- .../NewNetworkWizard_Pages/NetWDetails.cs | 2 +- .../NewNetworkWizard_Pages/NetWName.cs | 2 +- .../NewSRWizard_Pages/Frontends/LVMoISCSI.cs | 2 +- .../NewSRWizard_Pages/Frontends/NFS_ISO.cs | 2 +- .../NewSRWizard_Pages/NewSrWizardNamePage.cs | 2 +- 8 files changed, 6 insertions(+), 51 deletions(-) diff --git a/XenAdmin/Core/HelpersGUI.cs b/XenAdmin/Core/HelpersGUI.cs index 79e397ec8..1fff8f345 100644 --- a/XenAdmin/Core/HelpersGUI.cs +++ b/XenAdmin/Core/HelpersGUI.cs @@ -158,45 +158,6 @@ namespace XenAdmin.Core f.Activate(); } - public static bool FocusFirstControl(Control.ControlCollection cc) - { - bool found = false; - - List controls = new List(); - foreach (Control control in cc) - controls.Add(control); - controls.Sort((c1, c2) => c1.TabIndex.CompareTo(c2.TabIndex)); - if (controls.Count > 0) - { - foreach (Control control in controls) - { - if (control.HasChildren) - { - found = FocusFirstControl(control.Controls); - } - - if (!found) - { - if (control is Label) - continue; - - if (control is TextBox && (control as TextBox).ReadOnly) - continue; - - if (control.CanSelect) - { - found = control.Focus(); - } - } - - if (found) - break; - } - } - - return found; - } - public static Dictionary CheckHostIQNsDiffer() { Dictionary hosts = new Dictionary(); diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs index 626118d47..b48f2e0bd 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWBondDetails.cs @@ -32,7 +32,6 @@ using System; using System.Collections.Generic; using XenAdmin.Controls; -using XenAdmin.Core; using XenAPI; @@ -56,11 +55,6 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages return Details.Valid; } - protected override void PageLoadedCore(PageLoadedDirection direction) - { - HelpersGUI.FocusFirstControl(Controls); - } - protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) { if (direction == PageLoadedDirection.Forward) diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs index 550d95aa3..a197f1cd4 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWChinDetails.cs @@ -66,7 +66,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + comboInterfaces.Focus(); } public override void PopulatePage() diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs index 6c653b4f9..6c3ff5c40 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWDetails.cs @@ -68,7 +68,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + comboBoxNICList.Focus(); } public override void PopulatePage() diff --git a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs index 2e1c8c3d1..3d9edbf4d 100644 --- a/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs +++ b/XenAdmin/Wizards/NewNetworkWizard_Pages/NetWName.cs @@ -61,7 +61,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { - HelpersGUI.FocusFirstControl(Controls); + txtName.Focus(); } protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs index cef0ce681..3b089297b 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/LVMoISCSI.cs @@ -122,7 +122,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends HelpersGUI.PerformIQNCheck(); if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + textBoxIscsiHost.Focus(); } protected override void PageLeaveCore(PageLoadedDirection direction, ref bool cancel) diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs index 0f5be15f6..748cd9b56 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/Frontends/NFS_ISO.cs @@ -109,7 +109,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages.Frontends protected override void PageLoadedCore(PageLoadedDirection direction) { if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + NfsServerPathComboBox.Focus(); } #endregion diff --git a/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs b/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs index 09c7e96ac..bf5d7cf57 100644 --- a/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs +++ b/XenAdmin/Wizards/NewSRWizard_Pages/NewSrWizardNamePage.cs @@ -74,7 +74,7 @@ namespace XenAdmin.Wizards.NewSRWizard_Pages protected override void PageLoadedCore(PageLoadedDirection direction) { if (direction == PageLoadedDirection.Forward) - HelpersGUI.FocusFirstControl(Controls); + textBoxName.Focus(); } public override void PopulatePage()