Controls: Add UnitTextBox
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using Elwig.Controls;
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Models;
|
||||
using System;
|
||||
@ -105,6 +106,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void ValidateInput(Control input, bool valid) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
Valid[input] = valid;
|
||||
}
|
||||
|
||||
@ -205,6 +207,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetOriginalValue(Control input, object? value) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
OriginalValues[input] = value is bool b ? b.ToString() : value;
|
||||
if (InputHasChanged(input)) {
|
||||
ControlUtils.SetInputChanged(input);
|
||||
@ -214,15 +217,18 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetOriginalValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
SetOriginalValue(input, ControlUtils.GetInputValue(input));
|
||||
}
|
||||
|
||||
protected void UnsetOriginalValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
OriginalValues.Remove(input);
|
||||
ControlUtils.ClearInputState(input);
|
||||
}
|
||||
|
||||
protected void SetDefaultValue(Control input, object? value) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
DefaultValues[input] = value is bool b ? b.ToString() : value;
|
||||
if (!InputHasChanged(input)) {
|
||||
if (InputIsNotDefault(input)) {
|
||||
@ -234,10 +240,12 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected void SetDefaultValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
SetDefaultValue(input, ControlUtils.GetInputValue(input));
|
||||
}
|
||||
|
||||
protected void UnsetDefaultValue(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
DefaultValues.Remove(input);
|
||||
if (!InputHasChanged(input)) {
|
||||
ControlUtils.ClearInputState(input);
|
||||
@ -261,10 +269,12 @@ namespace Elwig.Windows {
|
||||
protected bool IsValid => Valid.All(kv => kv.Value);
|
||||
|
||||
protected bool GetInputValid(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
return Valid[input];
|
||||
}
|
||||
|
||||
protected bool InputHasChanged(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
if (!OriginalValues.ContainsKey(input)) {
|
||||
return false;
|
||||
} else if (input is TextBox tb) {
|
||||
@ -283,6 +293,7 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected bool InputIsNotDefault(Control input) {
|
||||
if (input is UnitTextBox utbx) input = utbx.TextBox;
|
||||
if (!DefaultValues.ContainsKey(input)) {
|
||||
return false;
|
||||
} else if (input is TextBox tb) {
|
||||
@ -458,15 +469,15 @@ namespace Elwig.Windows {
|
||||
UpdateComboBox((Control)sender);
|
||||
}
|
||||
|
||||
protected void IntegerInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void IntegerInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckInteger);
|
||||
}
|
||||
|
||||
protected void DecimalInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void DecimalInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckDecimal);
|
||||
}
|
||||
|
||||
protected void PartialDateInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void PartialDateInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckPartialDate);
|
||||
}
|
||||
|
||||
@ -474,7 +485,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckPartialDate);
|
||||
}
|
||||
|
||||
protected void DateInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void DateInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckDate);
|
||||
}
|
||||
|
||||
@ -482,7 +493,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckDate);
|
||||
}
|
||||
|
||||
protected void TimeInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void TimeInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckTime);
|
||||
}
|
||||
|
||||
@ -490,7 +501,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckTime);
|
||||
}
|
||||
|
||||
protected void PlzInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void PlzInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
var plz = (TextBox)sender;
|
||||
InputTextChanged(plz, Validator.CheckPlz);
|
||||
if ("PLZ".Equals(plz.Tag))
|
||||
@ -504,7 +515,7 @@ namespace Elwig.Windows {
|
||||
UpdatePlz(plz, GetPlzOrtInput(plz));
|
||||
}
|
||||
|
||||
protected void EmailAddressInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void EmailAddressInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
@ -512,7 +523,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckEmailAddress);
|
||||
}
|
||||
|
||||
protected void PhoneNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void PhoneNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
@ -520,7 +531,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckPhoneNumber);
|
||||
}
|
||||
|
||||
protected void IbanInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void IbanInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckIban);
|
||||
}
|
||||
|
||||
@ -528,7 +539,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckIban);
|
||||
}
|
||||
|
||||
protected void BicInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void BicInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckBic);
|
||||
}
|
||||
|
||||
@ -536,7 +547,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckBic);
|
||||
}
|
||||
|
||||
protected void UstIdNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void UstIdNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckUstIdNr);
|
||||
}
|
||||
|
||||
@ -544,7 +555,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckUstIdNr);
|
||||
}
|
||||
|
||||
protected void LfbisNrInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void LfbisNrInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
@ -552,7 +563,7 @@ namespace Elwig.Windows {
|
||||
InputLostFocus((TextBox)sender, Validator.CheckLfbisNr);
|
||||
}
|
||||
|
||||
protected void UpperCaseInput_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
protected void UpperCaseInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||
InputTextChanged((TextBox)sender, Validator.CheckUpperCase);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user