37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Elwig.Helpers;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace Elwig.Dialogs {
|
|
public partial class TareCorrectionDialog : Window {
|
|
|
|
public int ActualTare { get; private set; }
|
|
public int TargetTare { get; private set; }
|
|
|
|
public TareCorrectionDialog(int actualTare, int? targetTare = null) {
|
|
InitializeComponent();
|
|
ActualTare = actualTare;
|
|
TargetTare = targetTare ?? actualTare;
|
|
ActualTareInput.Text = ActualTare.ToString();
|
|
TargetTareInput.Text = TargetTare.ToString();
|
|
TargetTareInput.SelectAll();
|
|
}
|
|
|
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
|
DialogResult = true;
|
|
TargetTare = int.Parse(TargetTareInput.Text);
|
|
Close();
|
|
}
|
|
|
|
private void UpdateButtons() {
|
|
ConfirmButton.IsEnabled = TargetTareInput.Text.Length > 0;
|
|
}
|
|
|
|
private void TareInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
|
if (sender is not TextBox b) return;
|
|
Validator.CheckInteger(b, true, 4);
|
|
UpdateButtons();
|
|
}
|
|
}
|
|
}
|