Refactor thumbnail options to enum and ComboBox UI
Replaced multiple mutually-exclusive boolean properties for thumbnail text options with a single enum (`ThumbnailOption`) in the data model. Updated WinForms UI to use a ComboBox instead of radio buttons for selecting thumbnail mode. Adjusted designer, mapping profile, settings DTO, and settings service for enum support and backward compatibility. Simplified thumbnail generation logic and improved maintainability by ensuring only one mode can be selected at a time.
This commit is contained in:
parent
214e540170
commit
d13ec8abdf
7 changed files with 214 additions and 289 deletions
|
|
@ -75,7 +75,7 @@ namespace ImageCatalog_2.Services
|
|||
try
|
||||
{
|
||||
object value;
|
||||
if (prop.PropertyType == typeof(string))
|
||||
if (prop.PropertyType == typeof(string))
|
||||
{
|
||||
value = fileParams.LeggiParametroString(xmlName);
|
||||
}
|
||||
|
|
@ -83,6 +83,22 @@ namespace ImageCatalog_2.Services
|
|||
{
|
||||
value = fileParams.LeggiParametroBoolean(xmlName);
|
||||
}
|
||||
else if (prop.PropertyType.IsEnum)
|
||||
{
|
||||
// Read enum as string from XML and try to parse to the enum type. Fall back to default.
|
||||
var str = fileParams.LeggiParametroString(xmlName);
|
||||
try
|
||||
{
|
||||
var enumValue = Enum.Parse(prop.PropertyType, str ?? string.Empty, true);
|
||||
value = enumValue;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// try numeric
|
||||
var intVal = fileParams.LeggiParametro<int>(xmlName, (int)(prop.GetValue(loadedDto) ?? 0));
|
||||
value = Enum.ToObject(prop.PropertyType, intVal);
|
||||
}
|
||||
}
|
||||
else if (prop.PropertyType == typeof(int))
|
||||
{
|
||||
value = fileParams.LeggiParametro<int>(xmlName, (int)(prop.GetValue(loadedDto) ?? 0));
|
||||
|
|
@ -117,6 +133,7 @@ namespace ImageCatalog_2.Services
|
|||
}
|
||||
|
||||
return loadedDto;
|
||||
// End of LoadSettingsAsync method
|
||||
});
|
||||
|
||||
// Step 2: Apply DTO values to ViewModel on UI thread
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue