From 738332dca2d95d2a798ebcc0661b677bd790a654 Mon Sep 17 00:00:00 2001 From: Brett Hewitson Date: Sat, 18 Jun 2022 20:28:00 +1000 Subject: [PATCH] Find Setting Changes --- .../ServerSettingsControl.xaml.cs | 8 +++-- .../Windows/FindSettingWindow.xaml.cs | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs index 848d0ade..a6037eda 100644 --- a/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs +++ b/src/ARKServerManager/UserControls/ServerSettingsControl.xaml.cs @@ -4355,10 +4355,10 @@ namespace ServerManagerTool } } - public void SelectControl(Control control) + public bool SelectControl(Control control) { - if (control is null) - return; + if (control is null || control.Visibility != Visibility.Visible) + return false; bool focused = false; Application.Current.Dispatcher.Invoke(() => @@ -4403,6 +4403,8 @@ namespace ServerManagerTool _lastFoundControl = control; }); + + return true; } public void UnselectControl() diff --git a/src/ARKServerManager/Windows/FindSettingWindow.xaml.cs b/src/ARKServerManager/Windows/FindSettingWindow.xaml.cs index 3c15f1e1..2a2a3f02 100644 --- a/src/ARKServerManager/Windows/FindSettingWindow.xaml.cs +++ b/src/ARKServerManager/Windows/FindSettingWindow.xaml.cs @@ -61,8 +61,9 @@ namespace ServerManagerTool _serverSettingsControl.UnselectControl(); + var findSettingString = FindSettingString.Trim(); var foundControls = _settingControls - .Where(s => s.setting.Contains(FindSettingString, StringComparison.OrdinalIgnoreCase)) + .Where(s => s.setting.Contains(findSettingString, StringComparison.OrdinalIgnoreCase)) .Select(s => s.control) .ToArray(); if (foundControls.Length == 0) @@ -72,16 +73,25 @@ namespace ServerManagerTool } var oldIndex = _controlIndex; - var newIndex = oldIndex + 1; - if (newIndex >= foundControls.Length) - { - _controlIndex = -1; - MessageBox.Show(string.Format(_globalizer.GetResourceString("FindSettingWindow_NotFoundErrorLabel"), FindSettingString), _globalizer.GetResourceString("FindSettingWindow_Title"), MessageBoxButton.OK, MessageBoxImage.Information); - return; - } + var newIndex = oldIndex; - _serverSettingsControl.SelectControl(foundControls[newIndex]); - _controlIndex = newIndex; + while (true) + { + newIndex += 1; + if (newIndex >= foundControls.Length) + { + _controlIndex = -1; + MessageBox.Show(string.Format(_globalizer.GetResourceString("FindSettingWindow_NotFoundErrorLabel"), FindSettingString), _globalizer.GetResourceString("FindSettingWindow_Title"), MessageBoxButton.OK, MessageBoxImage.Information); + return; + } + + var selected = _serverSettingsControl.SelectControl(foundControls[newIndex]); + if (selected) + { + _controlIndex = newIndex; + break; + } + } } catch (Exception ex) {