Controls: Rewrite UnitTextBox as extension of TextBox instead of UserControl

This commit is contained in:
2024-04-28 20:07:09 +02:00
parent 21fe5bc094
commit c4d68d11bc
16 changed files with 150 additions and 123 deletions

View File

@ -94,7 +94,7 @@ namespace Elwig.Windows {
WeightModifierInput.Text = "";
DataInput.Text = v.Data;
}
WeightModifierInput.TextBox.IsReadOnly = false;
WeightModifierInput.IsReadOnly = false;
ConsiderModifiersInput.IsEnabled = !locked;
ConsiderPenaltiesInput.IsEnabled = !locked;
ConsiderPenaltyInput.IsEnabled = !locked;
@ -126,7 +126,7 @@ namespace Elwig.Windows {
TransferDateInput.Text = "";
TransferDateInput.IsReadOnly = true;
WeightModifierInput.Text = "";
WeightModifierInput.TextBox.IsReadOnly = true;
WeightModifierInput.IsReadOnly = true;
ConsiderModifiersInput.IsChecked = false;
ConsiderModifiersInput.IsEnabled = false;
ConsiderPenaltiesInput.IsChecked = false;
@ -554,18 +554,18 @@ namespace Elwig.Windows {
}
private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
var res = Validator.CheckDecimal(WeightModifierInput.TextBox, false, 3, 2, true);
var res = Validator.CheckDecimal(WeightModifierInput, false, 3, 2, true);
if (BillingData == null) {
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
ControlUtils.ClearInputState(WeightModifierInput);
return;
}
var val = WeightModifierInput.Text.Length > 0 && res.IsValid ? double.Parse(WeightModifierInput.Text) : 0;
WeightModifierChanged = (val != Math.Round(BillingData.NetWeightModifier * 100.0, 8) && val != Math.Round(BillingData.GrossWeightModifier * 100.0, 8)) ||
(val == 0 && (BillingData.NetWeightModifier != 0 || BillingData.GrossWeightModifier != 0));
if (WeightModifierChanged) {
ControlUtils.SetInputChanged(WeightModifierInput.TextBox);
ControlUtils.SetInputChanged(WeightModifierInput);
} else {
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
ControlUtils.ClearInputState(WeightModifierInput);
}
UpdateSaveButton();
}