diff --git a/WGneu/Utils.cs b/WGneu/Utils.cs index 66982de..b92fb82 100644 --- a/WGneu/Utils.cs +++ b/WGneu/Utils.cs @@ -5,9 +5,22 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Windows; +using System.Windows.Controls; namespace WGneu { class Utils { + public static void SetInputChanged(Control input) { + input.BorderBrush = Brushes.Orange; + } + + public static void SetInputInvalid(Control input) { + input.BorderBrush = Brushes.Red; + } + + public static void ClearInputState(Control input) { + input.ClearValue(Control.BorderBrushProperty); + } + public static IEnumerable FindVisualChilds(DependencyObject depObj) where T : DependencyObject { if (depObj == null) yield return (T)Enumerable.Empty(); diff --git a/WGneu/Validator.cs b/WGneu/Validator.cs index 491fc3e..cd64180 100644 --- a/WGneu/Validator.cs +++ b/WGneu/Validator.cs @@ -32,18 +32,6 @@ namespace WGneu { { "423", Array.Empty() }, }; - public static void SetInputChanged(Control input) { - input.BorderBrush = System.Windows.Media.Brushes.Orange; - } - - public static void SetInputInvalid(Control input) { - input.BorderBrush = System.Windows.Media.Brushes.Red; - } - - public static void ClearInputStatus(Control input) { - input.ClearValue(Control.BorderBrushProperty); - } - public static ValidationResult CheckNumericInput(TextBox input, bool optional) { return CheckNumericInput(input, optional, -1); } diff --git a/WGneu/Windows/MemberListWindow.xaml.cs b/WGneu/Windows/MemberListWindow.xaml.cs index 46c2410..2252d15 100644 --- a/WGneu/Windows/MemberListWindow.xaml.cs +++ b/WGneu/Windows/MemberListWindow.xaml.cs @@ -82,13 +82,13 @@ namespace WGneu.Windows { private void ClearInputStates() { foreach (var tb in Utils.FindVisualChilds(this)) - if (tb.Name != "SearchInput") Validator.ClearInputStatus(tb); + if (tb.Name != "SearchInput") Utils.ClearInputState(tb); foreach (var cb in Utils.FindVisualChilds(this)) - Validator.ClearInputStatus(cb); + Utils.ClearInputState(cb); foreach (var cb in Utils.FindVisualChilds(this)) - Validator.ClearInputStatus(cb); + Utils.ClearInputState(cb); foreach (var rb in Utils.FindVisualChilds(this)) - Validator.ClearInputStatus(rb); + Utils.ClearInputState(rb); } private void RefreshInputs() { @@ -439,12 +439,12 @@ namespace WGneu.Windows { Valid[input] = res.IsValid; if (res.IsValid) { if (InputHasChanged(input)) { - Validator.SetInputChanged(input); + Utils.SetInputChanged(input); } else { - Validator.ClearInputStatus(input); + Utils.ClearInputState(input); } } else { - Validator.SetInputInvalid(input); + Utils.SetInputInvalid(input); } UpdateButtons(); } @@ -458,9 +458,9 @@ namespace WGneu.Windows { private void CheckBox_Changed(object sender, RoutedEventArgs e) { var input = (CheckBox)sender; if (InputHasChanged(input)) { - Validator.SetInputChanged(input); + Utils.SetInputChanged(input); } else { - Validator.ClearInputStatus(input); + Utils.ClearInputState(input); } UpdateButtons(); } @@ -468,9 +468,9 @@ namespace WGneu.Windows { private void RadioButton_Changed(object sender, RoutedEventArgs e) { var input = (RadioButton)sender; if (InputHasChanged(input)) { - Validator.SetInputChanged(input); + Utils.SetInputChanged(input); } else { - Validator.ClearInputStatus(input); + Utils.ClearInputState(input); } UpdateButtons(); } @@ -478,9 +478,9 @@ namespace WGneu.Windows { private void TextBox_TextChanged(object sender, RoutedEventArgs e) { var input = (TextBox)sender; if (InputHasChanged(input)) { - Validator.SetInputChanged(input); + Utils.SetInputChanged(input); } else { - Validator.ClearInputStatus(input); + Utils.ClearInputState(input); } UpdateButtons(); } @@ -489,9 +489,9 @@ namespace WGneu.Windows { var input = (ComboBox)sender; if (InputHasChanged(input)) { // TODO not working - Validator.SetInputChanged(input); + Utils.SetInputChanged(input); } else { - Validator.ClearInputStatus(input); + Utils.ClearInputState(input); } UpdateButtons(); }