Handle closing of window
This commit is contained in:
@ -2,6 +2,7 @@ using Elwig.Helpers;
|
|||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -30,6 +31,7 @@ namespace Elwig.Windows {
|
|||||||
LockContext = IsEditing;
|
LockContext = IsEditing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
protected bool IsClosing { get; private set; }
|
||||||
|
|
||||||
private TextBox[] TextBoxInputs;
|
private TextBox[] TextBoxInputs;
|
||||||
private TextBox[] PlzInputs;
|
private TextBox[] PlzInputs;
|
||||||
@ -55,6 +57,7 @@ namespace Elwig.Windows {
|
|||||||
RadioButtonInputs = Array.Empty<RadioButton>();
|
RadioButtonInputs = Array.Empty<RadioButton>();
|
||||||
Valid = new();
|
Valid = new();
|
||||||
OriginalValues = new();
|
OriginalValues = new();
|
||||||
|
Closing += OnClosing;
|
||||||
Loaded += OnLoaded;
|
Loaded += OnLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +78,10 @@ namespace Elwig.Windows {
|
|||||||
ValidateRequiredInputs();
|
ValidateRequiredInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnClosing(object? sender, CancelEventArgs evt) {
|
||||||
|
IsClosing = true;
|
||||||
|
}
|
||||||
|
|
||||||
private ComboBox GetPlzOrtInput(TextBox input) {
|
private ComboBox GetPlzOrtInput(TextBox input) {
|
||||||
return PlzOrtInputs[Array.IndexOf(PlzInputs, input)];
|
return PlzOrtInputs[Array.IndexOf(PlzInputs, input)];
|
||||||
}
|
}
|
||||||
@ -244,7 +251,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) {
|
protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) {
|
||||||
if (!res.IsValid)
|
if (!res.IsValid && !IsClosing)
|
||||||
System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||||
return res.IsValid;
|
return res.IsValid;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user