Added scales
This commit is contained in:
@ -5,6 +5,9 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.IO;
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Helpers.Weighing;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace Elwig {
|
||||
public partial class App : Application {
|
||||
@ -12,15 +15,17 @@ namespace Elwig {
|
||||
public static readonly string DataPath = @"C:\ProgramData\Elwig\";
|
||||
public static readonly string ExePath = @"C:\Program Files\Elwig\";
|
||||
public static readonly Config Config = new(DataPath + "config.ini");
|
||||
public static IEnumerable<IScale> Scales { get; private set; }
|
||||
|
||||
public static bool IsPrintingReady => Documents.Html.IsReady && Documents.Pdf.IsReady;
|
||||
public static System.Windows.Threading.Dispatcher MainDispatcher { get; private set; }
|
||||
public static Dispatcher MainDispatcher { get; private set; }
|
||||
|
||||
public App() : base() {
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "Elwig"));
|
||||
Directory.CreateDirectory(DataPath);
|
||||
MainDispatcher = Dispatcher;
|
||||
Scales = Array.Empty<IScale>();
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs evt) {
|
||||
@ -32,6 +37,25 @@ namespace Elwig {
|
||||
}
|
||||
Utils.RunBackground("HTML Initialization", () => Documents.Html.Init(PrintingReadyChanged));
|
||||
Utils.RunBackground("PDF Initialization", () => Documents.Pdf.Init(PrintingReadyChanged));
|
||||
|
||||
var list = new LinkedList<IScale>();
|
||||
foreach (var s in Config.Scales) {
|
||||
try {
|
||||
var scaleNr = int.Parse(s[0]);
|
||||
var type = s[1].ToLower();
|
||||
var model = s[2];
|
||||
var cnx = s[3];
|
||||
var empty = s[4];
|
||||
var filling = s[5];
|
||||
if (type == "systec") {
|
||||
list.AddLast(new SystecScale(scaleNr, model, cnx, empty, filling));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MessageBox.Show($"Unable to create scale {s[0]}:\n\n{e.Message}", "Scale Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
Scales = list;
|
||||
|
||||
base.OnStartup(evt);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user