fix possible IndexOutOfRangeException

This commit is contained in:
Jonas Sourlier 2023-03-06 17:03:01 +01:00
parent 3ca514e653
commit 298e8f34f4
4 changed files with 24 additions and 12 deletions

View file

@ -74,10 +74,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter
Grid.Background = Brushes.Gray; Grid.Background = Brushes.Gray;
Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() =>
{ {
var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; if (WirelessNetworksStackPanel.Children.Count > 0)
if (btn != null)
{ {
btn.SetFocus(); var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton;
if (btn != null)
{
btn.SetFocus();
}
} }
})); }));
}; };

View file

@ -79,10 +79,13 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
Button.Background = Brushes.LightGray; Button.Background = Brushes.LightGray;
Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() =>
{ {
var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; if (WirelessNetworksStackPanel.Children.Count > 0)
if (btn != null)
{ {
btn.SetFocus(); var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton;
if (btn != null)
{
btn.SetFocus();
}
} }
})); }));
}; };

View file

@ -74,10 +74,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.ActionCenter
Grid.Background = Brushes.Gray; Grid.Background = Brushes.Gray;
Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() =>
{ {
var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; if (WirelessNetworksStackPanel.Children.Count > 0)
if (btn != null)
{ {
btn.SetFocus(); var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton;
if (btn != null)
{
btn.SetFocus();
}
} }
})); }));
}; };

View file

@ -79,10 +79,13 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
Button.Background = Brushes.LightGray; Button.Background = Brushes.LightGray;
Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() => Task.Delay(100).ContinueWith((task) => Dispatcher.Invoke(() =>
{ {
var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton; if (WirelessNetworksStackPanel.Children.Count > 0)
if (btn != null)
{ {
btn.SetFocus(); var btn = WirelessNetworksStackPanel.Children[0] as NetworkButton;
if (btn != null)
{
btn.SetFocus();
}
} }
})); }));
}; };