Elwig: Fix most compiler warnings
Test / Run tests (push) Successful in 2m29s

This commit is contained in:
lorenz.stechauner committed 2026-11-24 19:37:13 +01:00
1 parent 9e110a467a
commit 2cc58f8df6
24 files changed
+112 -125

No files matched your search

+15 -20
View File
@@ -24,8 +24,7 @@ using System.Windows.Threading;
namespace Elwig {
public partial class App : Application {
public static App CurrentApp;
public static int NumWindows => CurrentApp.Windows.Count;
public static new App Current => (App)Application.Current;
public static bool ForceShutdown { get; set; } = false;
private readonly DispatcherTimer _autoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
@@ -42,8 +41,8 @@ namespace Elwig {
public static Version Version { get; private set; } = new();
public static int BranchNum { get; private set; }
public static string ZwstId { get; private set; }
public static string BranchName { get; private set; }
public static string ZwstId { get; private set; } = "?";
public static string BranchName { get; private set; } = "Unbekannt";
public static int? BranchPlz { get; private set; }
public static string? BranchLocation { get; private set; }
public static string? BranchAddress { get; private set; }
@@ -54,9 +53,8 @@ namespace Elwig {
public static IList<IScale> Scales { get; private set; } = [];
public static IList<ICommandScale> CommandScales => [.. Scales.Where(s => s is ICommandScale).Cast<ICommandScale>()];
public static IList<IEventScale> EventScales => [.. Scales.Where(s => s is IEventScale).Cast<IEventScale>()];
public static ClientParameters Client { get; set; }
public static ClientParameters Client { get; set; } = new();
public static Dispatcher MainDispatcher { get; private set; }
private DateTime LastChanged;
private static DateTime CurrentLastWrite => File.GetLastWriteTime(Config.DatabaseFile);
private readonly DispatcherTimer ContextTimer = new() { Interval = TimeSpan.FromSeconds(2) };
@@ -66,9 +64,7 @@ namespace Elwig {
Directory.CreateDirectory(TempPath);
Directory.CreateDirectory(DataPath);
Directory.CreateDirectory(MailsPath);
MainDispatcher = Dispatcher;
Scales = [];
CurrentApp = this;
Utils.OverrideCulture();
var args = Environment.GetCommandLineArgs();
@@ -86,7 +82,7 @@ namespace Elwig {
}
private static void OnContextChanged() {
MainDispatcher.BeginInvoke(HintContextChange);
Current.Dispatcher.BeginInvoke(HintContextChange);
}
protected override async void OnStartup(StartupEventArgs evt) {
@@ -259,21 +255,20 @@ namespace Elwig {
}
public static void HintContextChange() {
if (CurrentApp == null) return;
var ch = CurrentLastWrite;
if (ch > CurrentApp.LastChanged)
CurrentApp.LastChanged = ch;
MainDispatcher.Invoke(() => {
foreach (Window w in CurrentApp.Windows) {
if (ch > Current.LastChanged)
Current.LastChanged = ch;
Current.Dispatcher.Invoke(() => {
foreach (Window w in Current.Windows) {
if (w is not ContextWindow c) continue;
MainDispatcher.Invoke(c.HintContextChange);
MainDispatcher.BeginInvoke(c.TryContextReload);
Current.Dispatcher.Invoke(c.HintContextChange);
Current.Dispatcher.BeginInvoke(c.TryContextReload);
}
});
}
private void OnAutoUpdateTimer(object? sender, EventArgs? evt) {
foreach (Window w in CurrentApp.Windows) {
foreach (Window w in Current.Windows) {
if (w is UpdateDialog) return;
}
if (Utils.HasInternetConnectivity()) {
@@ -330,7 +325,7 @@ namespace Elwig {
}
public static void UpdateScales() {
foreach (Window w in CurrentApp.Windows) {
foreach (Window w in Current.Windows) {
if (w is DeliveryAdminWindow t && t.ViewModel.IsReceipt) {
t.UpdateScales();
}
@@ -342,7 +337,7 @@ namespace Elwig {
try {
var latest = await Utils.GetLatestInstallerUrl(Config.UpdateUrl);
if (new Version(latest.Version) > Version) {
await MainDispatcher.BeginInvoke(() => {
await Current.Dispatcher.BeginInvoke(() => {
var d = new UpdateDialog(latest.Version, latest.Url, latest.Size);
if (d.ShowDialog() == true) {
ShutdownNow();
@@ -370,7 +365,7 @@ namespace Elwig {
}
private static T FocusWindow<T>(Func<T> constructor, Predicate<T>? selector = null) where T : Window {
foreach (Window w in CurrentApp.Windows) {
foreach (Window w in Current.Windows) {
if (w is T t && (selector == null || selector(t))) {
if (t.WindowState == WindowState.Minimized)
t.WindowState = WindowState.Normal;