From d73389d7915933f7762778f5f175ec01bb11534a Mon Sep 17 00:00:00 2001 From: MaddoScientisto Date: Wed, 4 Feb 2026 21:12:27 +0100 Subject: [PATCH] Update library and fixes --- MaddoShared.Tests/ImageCreatorSharpTests.cs | 2 +- MaddoShared.Tests/MaddoShared.Tests.csproj | 20 ++++++++++++++++---- MaddoShared/MaddoShared.csproj | 10 +++++----- imagecatalog/DataModel.cs | 1 + imagecatalog/ImageCatalog 2.csproj | 6 +++--- imagecatalog/MainForm.cs | 13 +++++++++++++ imagecatalog/Services/SettingsService.cs | 12 +++++++++++- 7 files changed, 50 insertions(+), 14 deletions(-) diff --git a/MaddoShared.Tests/ImageCreatorSharpTests.cs b/MaddoShared.Tests/ImageCreatorSharpTests.cs index 442e013..d053452 100644 --- a/MaddoShared.Tests/ImageCreatorSharpTests.cs +++ b/MaddoShared.Tests/ImageCreatorSharpTests.cs @@ -225,7 +225,7 @@ namespace MaddoShared.Tests miAdjust.Invoke(svc, parameters); var updatedSize = (SizeF)parameters[3]; - imageState.DimensioneStandardMiniatura.Should().BeLessOrEqualTo(30); + imageState.DimensioneStandardMiniatura.Should().BeLessThanOrEqualTo(30); (updatedSize.Width <= 50 || imageState.DimensioneStandardMiniatura <= 5).Should().BeTrue(); } } diff --git a/MaddoShared.Tests/MaddoShared.Tests.csproj b/MaddoShared.Tests/MaddoShared.Tests.csproj index d425a15..5ab4340 100644 --- a/MaddoShared.Tests/MaddoShared.Tests.csproj +++ b/MaddoShared.Tests/MaddoShared.Tests.csproj @@ -9,14 +9,26 @@ - - - - + + + + + + + + + + + + + + + + diff --git a/MaddoShared/MaddoShared.csproj b/MaddoShared/MaddoShared.csproj index 4a37e7c..4753af8 100644 --- a/MaddoShared/MaddoShared.csproj +++ b/MaddoShared/MaddoShared.csproj @@ -14,12 +14,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + - + @@ -27,6 +27,6 @@ all - + \ No newline at end of file diff --git a/imagecatalog/DataModel.cs b/imagecatalog/DataModel.cs index b64cbdd..95fefb9 100644 --- a/imagecatalog/DataModel.cs +++ b/imagecatalog/DataModel.cs @@ -148,6 +148,7 @@ namespace ImageCatalog_2 { _uiEnabled = value; NotifyPropertyChanged(); + NotifyPropertyChanged(nameof(UiDisabled)); } } diff --git a/imagecatalog/ImageCatalog 2.csproj b/imagecatalog/ImageCatalog 2.csproj index 16182e5..6473071 100644 --- a/imagecatalog/ImageCatalog 2.csproj +++ b/imagecatalog/ImageCatalog 2.csproj @@ -39,9 +39,9 @@ - - - + + + all diff --git a/imagecatalog/MainForm.cs b/imagecatalog/MainForm.cs index d39e92d..6bc9c2c 100644 --- a/imagecatalog/MainForm.cs +++ b/imagecatalog/MainForm.cs @@ -132,6 +132,16 @@ public partial class MainForm ComboBox5.SelectedItem = Model.LogoVerticalPosition; } + private void RefreshComboBoxSelections() + { + // Update ComboBox selections to reflect loaded Model values + ComboBox1.SelectedItem = Model.VerticalPosition; + ComboBox2.SelectedItem = Model.HorizontalAlignment; + ComboBox3.SelectedItem = Model.FontName; + ComboBox4.SelectedItem = Model.LogoHorizontalPosition; + ComboBox5.SelectedItem = Model.LogoVerticalPosition; + } + private void Form1_Load(object sender, EventArgs e) { @@ -281,6 +291,9 @@ public partial class MainForm await Model.LoadSettingsFromFileAsync(openDialog.FileName); + // Refresh ComboBox selections to reflect loaded settings + RefreshComboBoxSelections(); + // Update logo preview if logo file exists if (File.Exists(Model.LogoFile)) { diff --git a/imagecatalog/Services/SettingsService.cs b/imagecatalog/Services/SettingsService.cs index f8854bc..fbf747f 100644 --- a/imagecatalog/Services/SettingsService.cs +++ b/imagecatalog/Services/SettingsService.cs @@ -58,6 +58,15 @@ namespace ImageCatalog_2.Services if (prop.PropertyType == typeof(string)) { value = _parametriSetup.LeggiParametroString(prop.Name); + // Don't update if empty string and current value is not empty + if (string.IsNullOrEmpty((string)value)) + { + var currentValue = prop.GetValue(settings) as string; + if (!string.IsNullOrEmpty(currentValue)) + { + continue; // Skip if no value in settings but there's a default + } + } } else if (prop.PropertyType == typeof(bool)) { @@ -78,9 +87,10 @@ namespace ImageCatalog_2.Services prop.SetValue(settings, value); } - catch + catch (Exception ex) { // Skip properties that can't be loaded + System.Diagnostics.Debug.WriteLine($"Failed to load property {prop.Name}: {ex.Message}"); } } });