diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs index f0e4812..a6181aa 100644 --- a/Elwig/App.xaml.cs +++ b/Elwig/App.xaml.cs @@ -84,8 +84,8 @@ namespace Elwig { var list = new List(); foreach (var s in Config.Scales) { + var id = s[0]; try { - var id = s[0]; var type = s[1]?.ToLower(); var model = s[2]; var cnx = s[3]; @@ -99,6 +99,7 @@ namespace Elwig { throw new ArgumentException($"Invalid scale type: \"{type}\""); } } catch (Exception e) { + list.Add(new InvalidScale(id)); MessageBox.Show($"Unable to create scale {s[0]}:\n\n{e.Message}", "Scale Error", MessageBoxButton.OK, MessageBoxImage.Error); } } diff --git a/Elwig/Helpers/ClientParameters.cs b/Elwig/Helpers/ClientParameters.cs index 711db1c..3f82795 100644 --- a/Elwig/Helpers/ClientParameters.cs +++ b/Elwig/Helpers/ClientParameters.cs @@ -11,6 +11,9 @@ namespace Elwig.Helpers { public bool IsMatzen => Client == Type.Matzen; public bool IsWinzerkeller => Client == Type.Winzerkeller; + public bool IsWolkersdorf => Client == Type.Winzerkeller && App.ZwstId == "W"; + public bool IsHaugsdorf => Client == Type.Winzerkeller && App.ZwstId == "H"; + public bool IsSitzendorf => Client == Type.Winzerkeller && App.ZwstId == "S"; public string NameToken; public string NameShort; diff --git a/Elwig/Helpers/Weighing/InvalidScale.cs b/Elwig/Helpers/Weighing/InvalidScale.cs new file mode 100644 index 0000000..eea7459 --- /dev/null +++ b/Elwig/Helpers/Weighing/InvalidScale.cs @@ -0,0 +1,44 @@ +using System; +using System.Threading.Tasks; + +namespace Elwig.Helpers.Weighing { + public class InvalidScale : IScale { + + public string Manufacturer => "NONE"; + public string Model => "NONE"; + public string ScaleId { get; private set; } + public int InternalScaleNr => 0; + public bool IsReady => false; + public bool HasFillingClearance => false; + public int? WeightLimit => null; + public string? LogPath => null; + + public InvalidScale(string id) { + ScaleId = id; + } + + public void Dispose() { + GC.SuppressFinalize(this); + } + + public Task Weigh() { + throw new NotImplementedException(); + } + + public Task GetCurrentWeight() { + throw new NotImplementedException(); + } + + public Task Empty() { + throw new NotImplementedException(); + } + + public Task GrantFillingClearance() { + throw new NotImplementedException(); + } + + public Task RevokeFillingClearance() { + throw new NotImplementedException(); + } + } +} diff --git a/Elwig/Windows/AdministrationWindow.cs b/Elwig/Windows/AdministrationWindow.cs index 4a32e64..20ed5fb 100644 --- a/Elwig/Windows/AdministrationWindow.cs +++ b/Elwig/Windows/AdministrationWindow.cs @@ -32,6 +32,7 @@ namespace Elwig.Windows { LockContext = IsEditing; } } + protected bool DoShowWarningWindows = true; protected bool IsClosing { get; private set; } private TextBox[] TextBoxInputs; @@ -363,7 +364,7 @@ namespace Elwig.Windows { } protected bool InputLostFocus(TextBox input, ValidationResult res, string? msg = null) { - if (!res.IsValid && !IsClosing && (IsEditing || IsCreating)) + if (DoShowWarningWindows && !res.IsValid && !IsClosing && (IsEditing || IsCreating)) System.Windows.MessageBox.Show(res.ErrorContent.ToString(), msg ?? res.ErrorContent.ToString(), MessageBoxButton.OK, MessageBoxImage.Warning); return res.IsValid; } diff --git a/Elwig/Windows/DeliveryAdminWindow.xaml b/Elwig/Windows/DeliveryAdminWindow.xaml index dd461d8..de93881 100644 --- a/Elwig/Windows/DeliveryAdminWindow.xaml +++ b/Elwig/Windows/DeliveryAdminWindow.xaml @@ -160,10 +160,10 @@