Formatting

This commit is contained in:
Marco 2025-07-29 11:10:54 +02:00
commit a466efbb27
3 changed files with 22 additions and 21 deletions

View file

@ -15,7 +15,10 @@ using Microsoft.Extensions.Logging;
namespace MaddoShared namespace MaddoShared
{ {
[SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")] [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility")]
public class ImageCreationStuff(ILogger<ImageCreationStuff> logger, PicSettings picSettings, ImageCreatorSharp imageCreatorService) public class ImageCreationStuff(
ILogger<ImageCreationStuff> logger,
PicSettings picSettings,
ImageCreatorSharp imageCreatorService)
{ {
public class Options public class Options
{ {
@ -59,19 +62,19 @@ namespace MaddoShared
// int threads = options.MaxThreads == 0 ? Environment.ProcessorCount * 2 : options.MaxThreads; // int threads = options.MaxThreads == 0 ? Environment.ProcessorCount * 2 : options.MaxThreads;
int threads = options.MaxThreads; int threads = options.MaxThreads;
Bitmap logoBmp = null; Bitmap logoBmp = null;
// Load Logo // Load Logo
if (picSettings.LogoAggiungi & File.Exists(picSettings.LogoNomeFile)) if (picSettings.LogoAggiungi & File.Exists(picSettings.LogoNomeFile))
{ {
logoBmp = new Bitmap(picSettings.LogoNomeFile); logoBmp = new Bitmap(picSettings.LogoNomeFile);
} }
Func<FileData, Task> processFile = async fileData => Func<FileData, Task> processFile = async fileData =>
{ {
using var logoCopy = logoBmp.Clone(new Rectangle(0, 0, logoBmp.Width, logoBmp.Height), using var logoCopy = logoBmp.Clone(new Rectangle(0, 0, logoBmp.Width, logoBmp.Height),
logoBmp.PixelFormat); logoBmp.PixelFormat);
var imgState = new ImageState var imgState = new ImageState
{ {
WorkFile = fileData.File, WorkFile = fileData.File,
@ -79,10 +82,10 @@ namespace MaddoShared
}; };
await imageCreatorService.CreaImmagineThread(imgState, logoCopy); await imageCreatorService.CreaImmagineThread(imgState, logoCopy);
// using var imgCreator = new ImageCreatorSharp(fileData.File, fileData.Directory, picSettings); // using var imgCreator = new ImageCreatorSharp(fileData.File, fileData.Directory, picSettings);
// await imgCreator.CreaImmagineThread(fileData.File.Name, logoCopy); // await imgCreator.CreaImmagineThread(fileData.File.Name, logoCopy);
results.Add(fileData.File.Name); results.Add(fileData.File.Name);
try try
@ -118,7 +121,7 @@ namespace MaddoShared
maxDegreeOfParallelism: threads, maxDegreeOfParallelism: threads,
false, false,
cancellationToken); cancellationToken);
chunk.Clear(); chunk.Clear();
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: false, compacting: false); GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, blocking: false, compacting: false);
} }
@ -132,7 +135,6 @@ namespace MaddoShared
{ {
logger.LogError(e, "Error in disposing the logo"); logger.LogError(e, "Error in disposing the logo");
} }
} }
private List<FileData> GetFilesToProcess(Options options) private List<FileData> GetFilesToProcess(Options options)
@ -171,7 +173,7 @@ namespace MaddoShared
destFolderInfo.EnsureDirectoryExists(); destFolderInfo.EnsureDirectoryExists();
return new FileData(fInfo, new DirectoryInfo(new FileInfo(newFilePath).DirectoryName)); return new FileData(fInfo, new DirectoryInfo(new FileInfo(newFilePath).DirectoryName));
// var destDir = new FileInfo(newFilePath).Directory!; // var destDir = new FileInfo(newFilePath).Directory!;
// destDir.Create(); // Ensure exists // destDir.Create(); // Ensure exists
// //

View file

@ -14,16 +14,16 @@ namespace ImageCatalog_2
{ {
public class DataModel : ViewModelBase public class DataModel : ViewModelBase
{ {
public ICommand TestCommand { get; } public ICommand TestCommand { get; }
public ICommand AsyncTestCommand { get; } public ICommand AsyncTestCommand { get; }
public ICommand AsyncCancelOperationCommand { get; } public ICommand AsyncCancelOperationCommand { get; }
public ICommand ProcessImagesCommand { get; } public ICommand ProcessImagesCommand { get; }
private readonly ITestService _service; private readonly ITestService _service;
private readonly ILogger<DataModel> _logger; private readonly ILogger<DataModel> _logger;
public DataModel(ITestService testService, ILogger<DataModel> logger) public DataModel(ITestService testService, ILogger<DataModel> logger)
{ {
_service = testService; _service = testService;
@ -32,7 +32,7 @@ namespace ImageCatalog_2
TestCommand = new RelayCommand(Test); TestCommand = new RelayCommand(Test);
AsyncTestCommand = new AsyncCommand(TestAsync); AsyncTestCommand = new AsyncCommand(TestAsync);
AsyncCancelOperationCommand = new AsyncCommand(CancelOperation); AsyncCancelOperationCommand = new AsyncCommand(CancelOperation);
ProcessImagesCommand = new AsyncCommand(ProcessImages); ProcessImagesCommand = new AsyncCommand(ProcessImages);
} }
@ -61,6 +61,7 @@ namespace ImageCatalog_2
} }
private string _destinationPath; private string _destinationPath;
public string DestinationPath public string DestinationPath
{ {
get => _destinationPath; get => _destinationPath;
@ -82,8 +83,9 @@ namespace ImageCatalog_2
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
private string _verticalText; private string _verticalText;
public string VerticalText public string VerticalText
{ {
get => _verticalText; get => _verticalText;
@ -117,7 +119,7 @@ namespace ImageCatalog_2
NotifyPropertyChanged(); NotifyPropertyChanged();
} }
} }
public bool UiDisabled => !_uiEnabled; public bool UiDisabled => !_uiEnabled;
private string _speedCounter = "-"; private string _speedCounter = "-";
@ -145,7 +147,6 @@ namespace ImageCatalog_2
private async Task ProcessImages() private async Task ProcessImages()
{ {
} }
private async Task CancelOperation() private async Task CancelOperation()
@ -162,6 +163,5 @@ namespace ImageCatalog_2
_logger.LogInformation("Ignora questo errore"); _logger.LogInformation("Ignora questo errore");
} }
} }
} }
} }

View file

@ -113,7 +113,7 @@ public partial class MainForm
SetText(Label10, args.Item1); SetText(Label10, args.Item1);
SetText(lblFotoTotaliNum, args.Item2.ToString()); SetText(lblFotoTotaliNum, args.Item2.ToString());
} }
private bool WaterSelectColor = false; private bool WaterSelectColor = false;
// Private ContaFotoCuori As Integer // Private ContaFotoCuori As Integer
@ -896,8 +896,7 @@ public partial class MainForm
{ {
_logger.LogInformation("Avvio elaborazione..."); _logger.LogInformation("Avvio elaborazione...");
lockUI(); lockUI();
// Dim timeStart As Date
// Dim timeStop As Date
Model.MainToken?.Dispose(); Model.MainToken?.Dispose();
Model.MainToken = new CancellationTokenSource(); Model.MainToken = new CancellationTokenSource();
var token = Model.MainToken.Token; var token = Model.MainToken.Token;