Add WPF UI alongside WinForms; improve cancellation logic

Introduced MainWindow.xaml and code-behind for a modern WPF interface with tabbed settings. Enabled WPF in project file. Refactored startup to launch WPF or WinForms UI based on availability. Registered WPF MainWindow in DI. Improved DataModel cancellation to be synchronous and log exceptions. Minor logging and comment updates. App now supports both WPF and WinForms frontends.
This commit is contained in:
MaddoScientisto 2026-02-15 11:14:19 +01:00
commit 10cc574acb
5 changed files with 484 additions and 10 deletions

View file

@ -1132,13 +1132,26 @@ namespace ImageCatalog_2
{
try
{
await MainToken?.CancelAsync();
var tokenSource = MainToken;
if (tokenSource is not null)
{
// Cancel synchronously and return to caller. Some CTSource implementations
// may provide async helpers but cancelling is immediate.
try
{
tokenSource.Cancel();
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Exception while cancelling token");
}
}
UiEnabled = true;
}
catch (Exception e)
{
_logger.LogError(e.Message, "Error canceling the token");
_logger.LogError(e, "Error canceling the token");
_logger.LogInformation("Ignora questo errore");
}
}