Clean up
This commit is contained in:
parent
5d21d3f8ef
commit
1cd71c54fc
5 changed files with 964 additions and 886 deletions
|
|
@ -100,6 +100,20 @@ namespace ImageCatalog_2
|
|||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool UiDisabled => !_uiEnabled;
|
||||
|
||||
private string _speedCounter = "-";
|
||||
|
||||
public string SpeedCounter
|
||||
{
|
||||
get => _speedCounter;
|
||||
set
|
||||
{
|
||||
_speedCounter = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void Test(object parameter)
|
||||
{
|
||||
|
|
|
|||
876
imagecatalog/MainForm.Designer.cs
generated
876
imagecatalog/MainForm.Designer.cs
generated
File diff suppressed because it is too large
Load diff
|
|
@ -19,26 +19,25 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
namespace ImageCatalog;
|
||||
|
||||
public delegate void XyThreadAdd(string Info);
|
||||
|
||||
public partial class MainForm
|
||||
{
|
||||
private readonly DataModel Model;
|
||||
|
||||
|
||||
private readonly ILogger<MainForm> _logger;
|
||||
|
||||
private readonly ImageCreationStuff _imageCreationService;
|
||||
|
||||
private readonly ParametriSetup _parametriSetup;
|
||||
private readonly PicSettings _picSettings;
|
||||
|
||||
public MainForm(DataModel model, ImageCreationStuff imageCreationStuff, PicSettings picSettings, ParametriSetup parametriSetup, ILogger<MainForm> logger)
|
||||
|
||||
public MainForm(DataModel model, ImageCreationStuff imageCreationStuff, PicSettings picSettings,
|
||||
ParametriSetup parametriSetup, ILogger<MainForm> logger)
|
||||
{
|
||||
Model = model;
|
||||
_imageCreationService = imageCreationStuff;
|
||||
_parametriSetup = parametriSetup;
|
||||
_picSettings = picSettings;
|
||||
|
||||
|
||||
_logger = logger;
|
||||
|
||||
_logger.LogDebug("Start");
|
||||
|
|
@ -97,7 +96,7 @@ public partial class MainForm
|
|||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
SetProgressCallback d = new SetProgressCallback(SetProgress);
|
||||
var d = new SetProgressCallback(SetProgress);
|
||||
this.Invoke(d, new object[] { target, amount, maximum });
|
||||
}
|
||||
else
|
||||
|
|
@ -121,7 +120,7 @@ public partial class MainForm
|
|||
|
||||
// Private ContaFotoCuori As Integer
|
||||
// Private TaskCuori() As PicInfo
|
||||
|
||||
|
||||
private int ContaImmaginiThread;
|
||||
private int maxThreads = 15;
|
||||
private int minThreads = 5;
|
||||
|
|
@ -206,11 +205,8 @@ public partial class MainForm
|
|||
bindingSource1.DataSource = Model;
|
||||
Application.EnableVisualStyles();
|
||||
SetDefaults();
|
||||
// /* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
// AllocConsole();
|
||||
// /* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
|
||||
_logger.LogInformation("Programma Avviato");
|
||||
//Console.WriteLine("Programma avviato");
|
||||
}
|
||||
|
||||
private void FixPaths()
|
||||
|
|
@ -261,17 +257,17 @@ public partial class MainForm
|
|||
{
|
||||
long timediffH, timediffS;
|
||||
long timediffM;
|
||||
|
||||
|
||||
TimeSpan timeDiff = timeStop - timeStart;
|
||||
|
||||
timediffM = (int)timeDiff.TotalMinutes;
|
||||
timediffS = (int)timeDiff.TotalSeconds;
|
||||
timediffH = (int)timeDiff.TotalHours;
|
||||
|
||||
|
||||
// timediffM = DateAndTime.DateDiff(DateInterval.Minute, timeStart, timeStop);
|
||||
// timediffS = DateAndTime.DateDiff(DateInterval.Second, timeStart, timeStop);
|
||||
// timediffH = DateAndTime.DateDiff(DateInterval.Hour, timeStart, timeStop);
|
||||
|
||||
|
||||
double fotoSec = numFoto / (double)timediffS;
|
||||
double fotoMin = numFoto / (double)timediffM;
|
||||
double fotoOra = numFoto / (double)timediffH;
|
||||
|
|
@ -286,7 +282,7 @@ public partial class MainForm
|
|||
var dialog = new FolderBrowserDialog();
|
||||
dialog.InitialDirectory = startingFolder;
|
||||
if (dialog.ShowDialog() != DialogResult.OK) return string.Empty;
|
||||
|
||||
|
||||
var directoryScelta = FixPath(dialog.SelectedPath); // dialog.FileName;
|
||||
|
||||
return directoryScelta;
|
||||
|
|
@ -319,7 +315,7 @@ public partial class MainForm
|
|||
SaveFileDlg.FilterIndex = 0;
|
||||
SaveFileDlg.RestoreDirectory = true;
|
||||
if (DialogResult.OK != SaveFileDlg.ShowDialog()) return;
|
||||
|
||||
|
||||
var ilNome = SaveFileDlg.FileName;
|
||||
_parametriSetup.NomeFileSetup = ilNome;
|
||||
_parametriSetup.AggiornaParametro("DirSorgente", Model.SourcePath);
|
||||
|
|
@ -478,7 +474,7 @@ public partial class MainForm
|
|||
if (PictureBox1.Image.Height >= PictureBox1.Image.Width)
|
||||
{
|
||||
PictureBox1.Height = 160;
|
||||
PictureBox1.Width =
|
||||
PictureBox1.Width =
|
||||
(int)(160 * PictureBox1.Image.Width / (double)PictureBox1.Image.Height);
|
||||
}
|
||||
else
|
||||
|
|
@ -699,7 +695,7 @@ public partial class MainForm
|
|||
|
||||
return numerazioneType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CopyDirectoryFile(string SourcePath, string DestPath, bool OverWrite = false)
|
||||
{
|
||||
|
|
@ -774,8 +770,6 @@ public partial class MainForm
|
|||
{
|
||||
_logger.LogError(exception.Message);
|
||||
_logger.LogInformation("Ignora questo errore");
|
||||
// Console.WriteLine(exception);
|
||||
// Console.WriteLine("Ignora questo errore");
|
||||
}
|
||||
|
||||
unlockUI();
|
||||
|
|
@ -911,20 +905,20 @@ public partial class MainForm
|
|||
_mainToken?.Dispose();
|
||||
_mainToken = new CancellationTokenSource();
|
||||
var token = _mainToken.Token;
|
||||
|
||||
|
||||
// timeStart = TimeOfDay
|
||||
FixPaths();
|
||||
Label10.Text = "Elaborazione in corso...";
|
||||
lblFotoTotaliNum.Text = "0";
|
||||
Label18.Text = "0";
|
||||
Label43.Text = "-s";
|
||||
Model.SpeedCounter = "-s";
|
||||
SetPicSettings(Model.SourcePath, Model.DestinationPath);
|
||||
ProgressBar1.Minimum = 0;
|
||||
ProgressBar1.Step = 1;
|
||||
ProgressBar1.Value = 0;
|
||||
|
||||
// Await CreaCatalogoParallel()
|
||||
|
||||
|
||||
var imageCreationOptions = new ImageCreationStuff.Options
|
||||
{
|
||||
AggiornaSottodirectory = chkAggiornaSottodirectory.Checked,
|
||||
|
|
@ -950,14 +944,14 @@ public partial class MainForm
|
|||
timer1.Interval = 1000 * 60;
|
||||
timer1.Enabled = true;
|
||||
|
||||
string time = await _imageCreationService.CreaCatalogoParallel(imageCreationOptions, _results, UiUpdateEvent, token);
|
||||
Label43.Text = time;
|
||||
string time =
|
||||
await _imageCreationService.CreaCatalogoParallel(imageCreationOptions, _results, UiUpdateEvent, token);
|
||||
Model.SpeedCounter = time;
|
||||
timer1.Enabled = false;
|
||||
}
|
||||
catch (OperationCanceledException operationCanceledException)
|
||||
{
|
||||
_logger.LogInformation("Operazione Cancellata");
|
||||
//Console.WriteLine("Operazione cancellata");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
@ -979,7 +973,8 @@ public partial class MainForm
|
|||
_previousAmount = _currentAmount;
|
||||
_currentAmount = _results.Count;
|
||||
int diff = _currentAmount - _previousAmount;
|
||||
SetText(Label43, $"{diff} f/m");
|
||||
Model.SpeedCounter = $"{diff} f/m";
|
||||
//SetText(Label43, $"{diff} f/m");
|
||||
}
|
||||
|
||||
private void UpdateCounter(string text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue