From 5a4ff26f31dc07b3d798ac3db74e3b9587244399 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 11 Jun 2024 12:34:07 +0200 Subject: [PATCH] [#16] DeleteMemberDialog: Highlight invalid/not-checked inputs --- Elwig/Dialogs/DeleteMemberDialog.xaml.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Elwig/Dialogs/DeleteMemberDialog.xaml.cs b/Elwig/Dialogs/DeleteMemberDialog.xaml.cs index cdfb7ca..06494bf 100644 --- a/Elwig/Dialogs/DeleteMemberDialog.xaml.cs +++ b/Elwig/Dialogs/DeleteMemberDialog.xaml.cs @@ -1,4 +1,5 @@ -using System.Linq; +using Elwig.Helpers; +using System.Linq; using System.Windows; using System.Windows.Controls; @@ -31,13 +32,30 @@ namespace Elwig.Dialogs { Update(); } + private static void UpdateCheckBox(CheckBox cb) { + if (cb.IsEnabled && cb.IsChecked != true) { + ControlUtils.SetInputInvalid(cb); + } else { + ControlUtils.ClearInputState(cb); + } + } + private void Update() { var t = NameInput.Text.ToLower(); + var nameValid = NameParts.All(t.Contains); + UpdateCheckBox(AreaComInput); + UpdateCheckBox(DeliveryInput); + UpdateCheckBox(PaymentInput); + if (!nameValid) { + ControlUtils.SetInputInvalid(NameInput); + } else { + ControlUtils.ClearInputState(NameInput); + } ConfirmButton.IsEnabled = (!AreaComInput.IsEnabled || DeleteAreaComs) && (!DeliveryInput.IsEnabled || DeleteDeliveries) && (!PaymentInput.IsEnabled || DeletePaymentData) && - NameParts.All(t.Contains); + nameValid; } private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {