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 <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2020-02-10 15:45:16 +00:00 committed by Mihaela Stoica
parent 1b35a6898f
commit 501970dec5
8 changed files with 6 additions and 51 deletions

View File

@ -158,45 +158,6 @@ namespace XenAdmin.Core
f.Activate();
}
public static bool FocusFirstControl(Control.ControlCollection cc)
{
bool found = false;
List<Control> controls = new List<Control>();
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<Host, Host> CheckHostIQNsDiffer()
{
Dictionary<Host, string> hosts = new Dictionary<Host, string>();

View File

@ -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)

View File

@ -66,7 +66,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages
protected override void PageLoadedCore(PageLoadedDirection direction)
{
HelpersGUI.FocusFirstControl(Controls);
comboInterfaces.Focus();
}
public override void PopulatePage()

View File

@ -68,7 +68,7 @@ namespace XenAdmin.Wizards.NewNetworkWizard_Pages
protected override void PageLoadedCore(PageLoadedDirection direction)
{
HelpersGUI.FocusFirstControl(Controls);
comboBoxNICList.Focus();
}
public override void PopulatePage()

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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()