modernized picsettings
This commit is contained in:
parent
4ceb46d65c
commit
63aac7f911
5 changed files with 243 additions and 915 deletions
|
|
@ -13,7 +13,7 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
namespace MaddoShared
|
||||
{
|
||||
public class ImageCreationStuff(ILogger<ImageCreationStuff> logger)
|
||||
public class ImageCreationStuff(ILogger<ImageCreationStuff> logger, PicSettings picSettings)
|
||||
{
|
||||
public class Options
|
||||
{
|
||||
|
|
@ -62,9 +62,9 @@ namespace MaddoShared
|
|||
|
||||
Bitmap logoBmp = null;
|
||||
// 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 =>
|
||||
|
|
@ -72,7 +72,7 @@ namespace MaddoShared
|
|||
using var logoCopy = logoBmp.Clone(new Rectangle(0, 0, logoBmp.Width, logoBmp.Height),
|
||||
logoBmp.PixelFormat);
|
||||
|
||||
using var imgCreator = new ImageCreatorSharp(fileData.File, fileData.Directory);
|
||||
using var imgCreator = new ImageCreatorSharp(fileData.File, fileData.Directory, picSettings);
|
||||
await imgCreator.CreaImmagineThread(fileData.File.Name, logoCopy);
|
||||
|
||||
results.Add(fileData.File.Name);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,8 @@ public class ImageCreatorSharp : IDisposable
|
|||
private Orientations _orientation;
|
||||
private DateTime? _creationDate;
|
||||
|
||||
private readonly PicSettings _picSettings;
|
||||
|
||||
public ImageCreatorSharp()
|
||||
{
|
||||
}
|
||||
|
|
@ -77,8 +79,9 @@ public class ImageCreatorSharp : IDisposable
|
|||
this.DestDir = destDir;
|
||||
}
|
||||
|
||||
public ImageCreatorSharp(FileInfo file, DirectoryInfo destination)
|
||||
public ImageCreatorSharp(FileInfo file, DirectoryInfo destination, PicSettings picSettings)
|
||||
{
|
||||
_picSettings = picSettings;
|
||||
this.WorkFile = file;
|
||||
this.DestDir = destination;
|
||||
}
|
||||
|
|
@ -104,7 +107,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
// Forza jpeg se è selezionata l'opzione
|
||||
System.Drawing.Imaging.ImageFormat thisFormat = g.RawFormat;
|
||||
if (PicSettings.UsaForzaJpg == true)
|
||||
if (_picSettings.UsaForzaJpg == true)
|
||||
thisFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
|
||||
|
||||
prepareThumbnailSize(g);
|
||||
|
|
@ -128,7 +131,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
//GC.Collect();
|
||||
}
|
||||
|
||||
// PicSettings.mainForm.stepProgressBar()
|
||||
// _picSettings.mainForm.stepProgressBar()
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -179,7 +182,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
FotoRuotaADestra = false;
|
||||
FotoRuotaASinistra = false;
|
||||
|
||||
if (PicSettings.UsaRotazioneAutomatica == true)
|
||||
if (_picSettings.UsaRotazioneAutomatica == true)
|
||||
{
|
||||
if (g.PropertyIdList.Length > 0)
|
||||
{
|
||||
|
|
@ -215,24 +218,24 @@ public class ImageCreatorSharp : IDisposable
|
|||
/// ''' <remarks></remarks>
|
||||
private void impostaTestoExtra(Image g)
|
||||
{
|
||||
if (PicSettings.UsaOrarioTestoApplicare | PicSettings.UsaTempoGaraTestoApplicare | PicSettings.UsaOrarioMiniatura | PicSettings.TestoMin | PicSettings.AggTempoGaraMin | PicSettings.AggNumTempMin)
|
||||
if (_picSettings.UsaOrarioTestoApplicare | _picSettings.UsaTempoGaraTestoApplicare | _picSettings.UsaOrarioMiniatura | _picSettings.TestoMin | _picSettings.AggTempoGaraMin | _picSettings.AggNumTempMin)
|
||||
{
|
||||
if (g.PropertyIdList.Length > 0)
|
||||
{
|
||||
//ExifReader DatiExif = new ExifReader((Bitmap)g);
|
||||
dataFoto = _creationDate ?? DateTime.Now; //DatiExif.DateTimeOriginal;
|
||||
testoFirma = PicSettings.TestoFirmaStart;
|
||||
testoFirmaV = PicSettings.TestoFirmaStartV;
|
||||
testoFirma = _picSettings.TestoFirmaStart;
|
||||
testoFirmaV = _picSettings.TestoFirmaStartV;
|
||||
|
||||
if (dataFoto.Year != 1)
|
||||
{
|
||||
testoFirmaPiccola = dataFoto.ToShortTimeString();
|
||||
if (PicSettings.UsaOrarioTestoApplicare == true)
|
||||
if (_picSettings.UsaOrarioTestoApplicare == true)
|
||||
{
|
||||
testoFirma += " " + dataFoto.ToShortDateString() + " " + dataFoto.ToLongTimeString();
|
||||
testoFirmaV += " " + dataFoto.ToShortDateString() + " " + dataFoto.ToLongTimeString();
|
||||
}
|
||||
if (PicSettings.UsaTempoGaraTestoApplicare == true)
|
||||
if (_picSettings.UsaTempoGaraTestoApplicare == true)
|
||||
{
|
||||
|
||||
var diff = dataPartenzaI - dataFoto;
|
||||
|
|
@ -247,8 +250,8 @@ public class ImageCreatorSharp : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
testoFirma = PicSettings.TestoFirmaStart;
|
||||
testoFirmaV = PicSettings.TestoFirmaStartV;
|
||||
testoFirma = _picSettings.TestoFirmaStart;
|
||||
testoFirmaV = _picSettings.TestoFirmaStartV;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -258,11 +261,11 @@ public class ImageCreatorSharp : IDisposable
|
|||
/// ''' <remarks></remarks>
|
||||
private void preparaVariabili()
|
||||
{
|
||||
alphaScelta = System.Convert.ToInt32((255 * (100 - PicSettings.Trasparenza) / (double)100));
|
||||
alphaScelta = System.Convert.ToInt32((255 * (100 - _picSettings.Trasparenza) / (double)100));
|
||||
testoFirma = "";
|
||||
testoFirmaV = "";
|
||||
dataPartenzaI = PicSettings.DataPartenza;
|
||||
testoOrario = PicSettings.TestoOrario;
|
||||
dataPartenzaI = _picSettings.DataPartenza;
|
||||
testoOrario = _picSettings.TestoOrario;
|
||||
if (testoOrario.Length > 0)
|
||||
testoOrario += " ";
|
||||
testoFirmaPiccola = "";
|
||||
|
|
@ -271,11 +274,11 @@ public class ImageCreatorSharp : IDisposable
|
|||
nomeFileSmall = "";
|
||||
nomeFileBig2 = "";
|
||||
nomeFileBig = "";
|
||||
DimensioneStandard = PicSettings.DimStandard;
|
||||
DimensioneStandardMiniatura = PicSettings.DimStandardMiniatura;
|
||||
DimensioneStandard = _picSettings.DimStandard;
|
||||
DimensioneStandardMiniatura = _picSettings.DimStandardMiniatura;
|
||||
// nomeFileSmall = Suffisso & NomeFileChild
|
||||
// nomeFileBig = NomeFileChild
|
||||
nomeFileSmall = PicSettings.Suffisso + WorkFile.Name;
|
||||
nomeFileSmall = _picSettings.Suffisso + WorkFile.Name;
|
||||
nomeFileBig = WorkFile.Name;
|
||||
}
|
||||
|
||||
|
|
@ -283,13 +286,13 @@ public class ImageCreatorSharp : IDisposable
|
|||
{
|
||||
if (g.Width > g.Height)
|
||||
{
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, PicSettings.LarghezzaSmall, "Larghezza");
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, _picSettings.LarghezzaSmall, "Larghezza");
|
||||
Size SizeOrig = new Size(g.Width, g.Height);
|
||||
thumbSizeBig = SizeOrig;
|
||||
}
|
||||
else
|
||||
{
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, PicSettings.AltezzaSmall, "Altezza");
|
||||
thumbSizeSmall = NewthumbSize(g.Width, g.Height, _picSettings.AltezzaSmall, "Altezza");
|
||||
Size SizeOrig = new Size(g.Width, g.Height);
|
||||
thumbSizeBig = SizeOrig;
|
||||
}
|
||||
|
|
@ -297,9 +300,9 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
private void creaMiniature(Image g, Bitmap imgOutputBig, ImageFormat thisFormat)
|
||||
{
|
||||
if (PicSettings.TestoMin)
|
||||
if (_picSettings.TestoMin)
|
||||
testoFirmaPiccola = nomeFileBig;
|
||||
else if (PicSettings.AggNumTempMin)
|
||||
else if (_picSettings.AggNumTempMin)
|
||||
testoFirmaPiccola = nomeFileBig + " ";
|
||||
// Dim yPosFromBottom4 As Single
|
||||
|
||||
|
|
@ -308,13 +311,13 @@ public class ImageCreatorSharp : IDisposable
|
|||
SizeF crSize1 = new SizeF();
|
||||
SizeF crSize2 = new SizeF();
|
||||
|
||||
if (PicSettings.CreaMiniature == true)
|
||||
if (_picSettings.CreaMiniature == true)
|
||||
{
|
||||
if (PicSettings.AggiungiScritteMiniature == false)
|
||||
if (_picSettings.AggiungiScritteMiniature == false)
|
||||
{
|
||||
if (string.Equals(PicSettings.DirectorySorgente, PicSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
nomeFileSmall = nomeFileSmall.Substring(0, nomeFileSmall.Length - 4) + PicSettings.Codice + nomeFileSmall.Substring(nomeFileSmall.Length - 4);
|
||||
if (PicSettings.UsaOrarioMiniatura | PicSettings.TestoMin | PicSettings.AggTempoGaraMin | PicSettings.AggNumTempMin)
|
||||
if (string.Equals(_picSettings.DirectorySorgente, _picSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
nomeFileSmall = nomeFileSmall.Substring(0, nomeFileSmall.Length - 4) + _picSettings.Codice + nomeFileSmall.Substring(nomeFileSmall.Length - 4);
|
||||
if (_picSettings.UsaOrarioMiniatura | _picSettings.TestoMin | _picSettings.AggTempoGaraMin | _picSettings.AggNumTempMin)
|
||||
{
|
||||
if (testoFirmaPiccola.Length > 0)
|
||||
{
|
||||
|
|
@ -327,15 +330,15 @@ public class ImageCreatorSharp : IDisposable
|
|||
int LarghezzaStandard1;
|
||||
// quick fix
|
||||
DimensioneStandardMiniatura = 50;
|
||||
if (PicSettings.Grassetto == true)
|
||||
if (_picSettings.Grassetto == true)
|
||||
{
|
||||
crFont1 = new Font(PicSettings.IlFont, DimensioneStandardMiniatura, FontStyle.Bold);
|
||||
crFont2 = new Font(PicSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
crFont1 = new Font(_picSettings.IlFont, DimensioneStandardMiniatura, FontStyle.Bold);
|
||||
crFont2 = new Font(_picSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
}
|
||||
else
|
||||
{
|
||||
crFont1 = new Font(PicSettings.IlFont, DimensioneStandardMiniatura);
|
||||
crFont2 = new Font(PicSettings.IlFont, DimensioneStandard);
|
||||
crFont1 = new Font(_picSettings.IlFont, DimensioneStandardMiniatura);
|
||||
crFont2 = new Font(_picSettings.IlFont, DimensioneStandard);
|
||||
}
|
||||
|
||||
crSize1 = grPhoto1.MeasureString(testoFirmaPiccola, crFont1);
|
||||
|
|
@ -351,10 +354,10 @@ public class ImageCreatorSharp : IDisposable
|
|||
Conta -= 5;
|
||||
else
|
||||
Conta -= 1;
|
||||
if (PicSettings.Grassetto == true)
|
||||
crFont1 = new Font(PicSettings.IlFont, Conta, FontStyle.Bold);
|
||||
if (_picSettings.Grassetto == true)
|
||||
crFont1 = new Font(_picSettings.IlFont, Conta, FontStyle.Bold);
|
||||
else
|
||||
crFont1 = new Font(PicSettings.IlFont, Conta);
|
||||
crFont1 = new Font(_picSettings.IlFont, Conta);
|
||||
crSize1 = grPhoto1.MeasureString(testoFirmaPiccola, crFont1);
|
||||
if (crSize1.Width < System.Convert.ToSingle(g.Width))
|
||||
{
|
||||
|
|
@ -369,19 +372,19 @@ public class ImageCreatorSharp : IDisposable
|
|||
DimensioneStandardMiniatura = Conta;
|
||||
}
|
||||
|
||||
switch (PicSettings.Posizione.ToUpper())
|
||||
switch (_picSettings.Posizione.ToUpper())
|
||||
{
|
||||
case "ALTO":
|
||||
{
|
||||
yPosFromBottom1 = (PicSettings.Margine);
|
||||
yPosFromBottom4 = (PicSettings.MargVert);
|
||||
yPosFromBottom1 = (_picSettings.Margine);
|
||||
yPosFromBottom4 = (_picSettings.MargVert);
|
||||
break;
|
||||
}
|
||||
|
||||
case "BASSO":
|
||||
{
|
||||
yPosFromBottom1 = System.Convert.ToSingle((g.Height - crSize1.Height - (g.Height * PicSettings.Margine / (double)100)));
|
||||
yPosFromBottom4 = System.Convert.ToSingle((g.Height - crSize1.Height - (g.Height * PicSettings.MargVert / (double)100)));
|
||||
yPosFromBottom1 = System.Convert.ToSingle((g.Height - crSize1.Height - (g.Height * _picSettings.Margine / (double)100)));
|
||||
yPosFromBottom4 = System.Convert.ToSingle((g.Height - crSize1.Height - (g.Height * _picSettings.MargVert / (double)100)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -389,13 +392,13 @@ public class ImageCreatorSharp : IDisposable
|
|||
float xCenterOfImg1 = 0;
|
||||
|
||||
StringFormat StrFormat1 = new StringFormat();
|
||||
switch (PicSettings.Allineamento.ToUpper())
|
||||
switch (_picSettings.Allineamento.ToUpper())
|
||||
{
|
||||
case "SINISTRA":
|
||||
{
|
||||
xCenterOfImg1 = System.Convert.ToSingle((PicSettings.Margine + (LarghezzaStandard1 / (double)2)));
|
||||
xCenterOfImg1 = System.Convert.ToSingle((_picSettings.Margine + (LarghezzaStandard1 / (double)2)));
|
||||
|
||||
if ((LarghezzaStandard1 / (double)2) > (g.Width / (double)2) - PicSettings.Margine)
|
||||
if ((LarghezzaStandard1 / (double)2) > (g.Width / (double)2) - _picSettings.Margine)
|
||||
xCenterOfImg1 = System.Convert.ToSingle((g.Width / (double)2));
|
||||
break;
|
||||
}
|
||||
|
|
@ -408,9 +411,9 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
case "DESTRA":
|
||||
{
|
||||
xCenterOfImg1 = System.Convert.ToSingle((g.Width - PicSettings.Margine - (LarghezzaStandard1 / (double)2)));
|
||||
xCenterOfImg1 = System.Convert.ToSingle((g.Width - _picSettings.Margine - (LarghezzaStandard1 / (double)2)));
|
||||
|
||||
if ((LarghezzaStandard1 / (double)2) > (g.Width / (double)2) - PicSettings.Margine)
|
||||
if ((LarghezzaStandard1 / (double)2) > (g.Width / (double)2) - _picSettings.Margine)
|
||||
xCenterOfImg1 = System.Convert.ToSingle((g.Width / (double)2));
|
||||
break;
|
||||
}
|
||||
|
|
@ -418,22 +421,22 @@ public class ImageCreatorSharp : IDisposable
|
|||
StrFormat1.Alignment = StringAlignment.Center;
|
||||
|
||||
SolidBrush semiTransBrush21 = new SolidBrush(Color.FromArgb(alphaScelta, 0, 0, 0));
|
||||
SolidBrush semiTransBrush1 = new SolidBrush(Color.FromArgb(alphaScelta, PicSettings.FontColoreRGB));
|
||||
SolidBrush semiTransBrush1 = new SolidBrush(Color.FromArgb(alphaScelta, _picSettings.FontColoreRGB));
|
||||
|
||||
// quick fix
|
||||
DimensioneStandardMiniatura = PicSettings.DimMin;
|
||||
DimensioneStandardMiniatura = _picSettings.DimMin;
|
||||
|
||||
if (PicSettings.Grassetto == true)
|
||||
crFont1 = new Font(PicSettings.IlFont, DimensioneStandardMiniatura, FontStyle.Bold);
|
||||
if (_picSettings.Grassetto == true)
|
||||
crFont1 = new Font(_picSettings.IlFont, DimensioneStandardMiniatura, FontStyle.Bold);
|
||||
else
|
||||
crFont1 = new Font(PicSettings.IlFont, DimensioneStandardMiniatura);
|
||||
crFont1 = new Font(_picSettings.IlFont, DimensioneStandardMiniatura);
|
||||
// asdgadfhdfhjgfsjgfjygfdhsdafa
|
||||
if (PicSettings.TestoMin)
|
||||
if (_picSettings.TestoMin)
|
||||
{
|
||||
grPhoto1.DrawString(nomeFileBig, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1), StrFormat1);
|
||||
grPhoto1.DrawString(nomeFileBig, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), StrFormat1);
|
||||
}
|
||||
else if (PicSettings.AggTempoGaraMin & PicSettings.UsaTempoGaraTestoApplicare)
|
||||
else if (_picSettings.AggTempoGaraMin & _picSettings.UsaTempoGaraTestoApplicare)
|
||||
{
|
||||
var diff = dataPartenzaI - dataFoto;
|
||||
var diffA = diff.TotalSeconds * 10000000;
|
||||
|
|
@ -448,7 +451,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
grPhoto1.DrawString(tempstr, crFont1, semiTransBrush21, new PointF(xCenterOfImg1 + 1, yPosFromBottom1 + 1), StrFormat1);
|
||||
grPhoto1.DrawString(tempstr, crFont1, semiTransBrush1, new PointF(xCenterOfImg1, yPosFromBottom1), StrFormat1);
|
||||
}
|
||||
else if (PicSettings.AggNumTempMin)
|
||||
else if (_picSettings.AggNumTempMin)
|
||||
{
|
||||
var diff = dataPartenzaI - dataFoto;
|
||||
var diffA = diff.TotalSeconds * 10000000;
|
||||
|
|
@ -515,10 +518,10 @@ public class ImageCreatorSharp : IDisposable
|
|||
SizeF crSize = new SizeF();
|
||||
int LarghezzaStandard;
|
||||
|
||||
if (PicSettings.Grassetto == true)
|
||||
crFont = new Font(PicSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
if (_picSettings.Grassetto == true)
|
||||
crFont = new Font(_picSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
else
|
||||
crFont = new Font(PicSettings.IlFont, DimensioneStandard);
|
||||
crFont = new Font(_picSettings.IlFont, DimensioneStandard);
|
||||
crSize = grPhoto.MeasureString(testoFirma, crFont);
|
||||
LarghezzaStandard = System.Convert.ToInt32(crSize.Width);
|
||||
|
||||
|
|
@ -531,10 +534,10 @@ public class ImageCreatorSharp : IDisposable
|
|||
Conta -= 5;
|
||||
else
|
||||
Conta -= 1;
|
||||
if (PicSettings.Grassetto == true)
|
||||
crFont = new Font(PicSettings.IlFont, Conta, FontStyle.Bold);
|
||||
if (_picSettings.Grassetto == true)
|
||||
crFont = new Font(_picSettings.IlFont, Conta, FontStyle.Bold);
|
||||
else
|
||||
crFont = new Font(PicSettings.IlFont, Conta);
|
||||
crFont = new Font(_picSettings.IlFont, Conta);
|
||||
crSize = grPhoto.MeasureString(testoFirma, crFont);
|
||||
if (crSize.Width < System.Convert.ToSingle(g.Width))
|
||||
{
|
||||
|
|
@ -550,19 +553,19 @@ public class ImageCreatorSharp : IDisposable
|
|||
}
|
||||
|
||||
|
||||
switch (PicSettings.Posizione.ToUpper())
|
||||
switch (_picSettings.Posizione.ToUpper())
|
||||
{
|
||||
case "ALTO":
|
||||
{
|
||||
yPosFromBottom = (PicSettings.Margine);
|
||||
yPosFromBottom3 = (PicSettings.MargVert);
|
||||
yPosFromBottom = (_picSettings.Margine);
|
||||
yPosFromBottom3 = (_picSettings.MargVert);
|
||||
break;
|
||||
}
|
||||
|
||||
case "BASSO":
|
||||
{
|
||||
yPosFromBottom = System.Convert.ToSingle((g.Height - crSize.Height - (g.Height * PicSettings.Margine / (double)100)));
|
||||
yPosFromBottom3 = System.Convert.ToSingle((g.Height - crSize.Height - (g.Height * PicSettings.MargVert / (double)100)));
|
||||
yPosFromBottom = System.Convert.ToSingle((g.Height - crSize.Height - (g.Height * _picSettings.Margine / (double)100)));
|
||||
yPosFromBottom3 = System.Convert.ToSingle((g.Height - crSize.Height - (g.Height * _picSettings.MargVert / (double)100)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -570,15 +573,15 @@ public class ImageCreatorSharp : IDisposable
|
|||
float xCenterOfImg = 0;
|
||||
float xCenterOfImg3 = 0;
|
||||
StringFormat StrFormat = new StringFormat();
|
||||
switch (PicSettings.Allineamento.ToUpper())
|
||||
switch (_picSettings.Allineamento.ToUpper())
|
||||
{
|
||||
case "SINISTRA":
|
||||
{
|
||||
xCenterOfImg = System.Convert.ToSingle((PicSettings.Margine + (LarghezzaStandard / (double)2)));
|
||||
xCenterOfImg3 = System.Convert.ToSingle((PicSettings.MargVert + (LarghezzaStandard / (double)2)));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - PicSettings.Margine)
|
||||
xCenterOfImg = System.Convert.ToSingle((_picSettings.Margine + (LarghezzaStandard / (double)2)));
|
||||
xCenterOfImg3 = System.Convert.ToSingle((_picSettings.MargVert + (LarghezzaStandard / (double)2)));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - _picSettings.Margine)
|
||||
xCenterOfImg = System.Convert.ToSingle((g.Width / (double)2));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - PicSettings.MargVert)
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - _picSettings.MargVert)
|
||||
xCenterOfImg3 = System.Convert.ToSingle((g.Width / (double)2));
|
||||
break;
|
||||
}
|
||||
|
|
@ -591,11 +594,11 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
case "DESTRA":
|
||||
{
|
||||
xCenterOfImg = System.Convert.ToSingle((g.Width - PicSettings.Margine - (LarghezzaStandard / (double)2)));
|
||||
xCenterOfImg3 = System.Convert.ToSingle((g.Width - PicSettings.MargVert - (LarghezzaStandard / (double)2)));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - PicSettings.Margine)
|
||||
xCenterOfImg = System.Convert.ToSingle((g.Width - _picSettings.Margine - (LarghezzaStandard / (double)2)));
|
||||
xCenterOfImg3 = System.Convert.ToSingle((g.Width - _picSettings.MargVert - (LarghezzaStandard / (double)2)));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - _picSettings.Margine)
|
||||
xCenterOfImg = System.Convert.ToSingle((g.Width / (double)2));
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - PicSettings.MargVert)
|
||||
if ((LarghezzaStandard / (double)2) > (g.Width / (double)2) - _picSettings.MargVert)
|
||||
xCenterOfImg3 = System.Convert.ToSingle((g.Width / (double)2));
|
||||
break;
|
||||
}
|
||||
|
|
@ -604,25 +607,25 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(alphaScelta, 0, 0, 0));
|
||||
// Dim semiTransBrush As SolidBrush = New SolidBrush(Color.FromArgb(AlphaScelta, _FontColoreR, _FontColoreG, _FontColoreB))
|
||||
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(alphaScelta, PicSettings.FontColoreRGB));
|
||||
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(alphaScelta, _picSettings.FontColoreRGB));
|
||||
|
||||
if (FotoRuotaADestra | FotoRuotaASinistra)
|
||||
{
|
||||
if (PicSettings.Grassetto == true)
|
||||
crFont = new Font(PicSettings.IlFont, PicSettings.DimVert, FontStyle.Bold);
|
||||
if (_picSettings.Grassetto == true)
|
||||
crFont = new Font(_picSettings.IlFont, _picSettings.DimVert, FontStyle.Bold);
|
||||
else
|
||||
crFont = new Font(PicSettings.IlFont, PicSettings.DimVert);
|
||||
crFont = new Font(_picSettings.IlFont, _picSettings.DimVert);
|
||||
}
|
||||
else if (PicSettings.Grassetto == true)
|
||||
crFont = new Font(PicSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
else if (_picSettings.Grassetto == true)
|
||||
crFont = new Font(_picSettings.IlFont, DimensioneStandard, FontStyle.Bold);
|
||||
else
|
||||
crFont = new Font(PicSettings.IlFont, DimensioneStandard);
|
||||
crFont = new Font(_picSettings.IlFont, DimensioneStandard);
|
||||
|
||||
|
||||
// qui scrive il testo (nomefilebig)
|
||||
if (PicSettings.TestoNome)
|
||||
if (_picSettings.TestoNome)
|
||||
{
|
||||
if (PicSettings.NomeData & g.PropertyIdList.Length > 0)
|
||||
if (_picSettings.NomeData & g.PropertyIdList.Length > 0)
|
||||
{
|
||||
//ExifReader DatiExif = new ExifReader((Bitmap)g);
|
||||
dataFoto = _creationDate ?? DateTime.Now; //DatiExif.DateTimeOriginal;
|
||||
|
|
@ -637,16 +640,16 @@ public class ImageCreatorSharp : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
if (PicSettings.TestoNome == false)
|
||||
if (_picSettings.TestoNome == false)
|
||||
{
|
||||
if (FotoRuotaADestra | FotoRuotaASinistra)
|
||||
{
|
||||
if (PicSettings.TestoMin == false)
|
||||
if (_picSettings.TestoMin == false)
|
||||
{
|
||||
grPhoto.DrawString(testoFirmaV, crFont, semiTransBrush2, new PointF(xCenterOfImg + 1, yPosFromBottom3 + 1), StrFormat);
|
||||
grPhoto.DrawString(testoFirmaV, crFont, semiTransBrush, new PointF(xCenterOfImg, yPosFromBottom3), StrFormat);
|
||||
}
|
||||
if (PicSettings.TestoMin == true)
|
||||
if (_picSettings.TestoMin == true)
|
||||
{
|
||||
grPhoto.DrawString(testoFirmaV, crFont, semiTransBrush2, new PointF(xCenterOfImg + 1, yPosFromBottom4 + 1), StrFormat);
|
||||
grPhoto.DrawString(testoFirmaV, crFont, semiTransBrush, new PointF(xCenterOfImg, yPosFromBottom4), StrFormat);
|
||||
|
|
@ -659,10 +662,10 @@ public class ImageCreatorSharp : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
if (string.Equals(PicSettings.DirectorySorgente, PicSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(_picSettings.DirectorySorgente, _picSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
nomeFileBig2 = nomeFileBig;
|
||||
nomeFileBig = nomeFileBig.Substring(0, nomeFileBig.Length - 4) + PicSettings.Codice + nomeFileBig.Substring(nomeFileBig.Length - 4);
|
||||
nomeFileBig = nomeFileBig.Substring(0, nomeFileBig.Length - 4) + _picSettings.Codice + nomeFileBig.Substring(nomeFileBig.Length - 4);
|
||||
}
|
||||
//grPhoto.Dispose();
|
||||
|
||||
|
|
@ -675,9 +678,9 @@ public class ImageCreatorSharp : IDisposable
|
|||
private void aggiungiLogo(Bitmap imgOutputBig, Image logo)
|
||||
{
|
||||
// imgOutputBig
|
||||
if (PicSettings.LogoAggiungi == true & File.Exists(PicSettings.LogoNomeFile))
|
||||
if (_picSettings.LogoAggiungi == true & File.Exists(_picSettings.LogoNomeFile))
|
||||
{
|
||||
// using var ImmagineLogo = Image.FromFile(PicSettings.LogoNomeFile);
|
||||
// using var ImmagineLogo = Image.FromFile(_picSettings.LogoNomeFile);
|
||||
|
||||
Color LogoColoreTrasparente = Color.White;
|
||||
|
||||
|
|
@ -696,12 +699,12 @@ public class ImageCreatorSharp : IDisposable
|
|||
imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
|
||||
|
||||
// * The second color manipulation is used to change the opacity by setting the 3rd row and 3rd column to 0.3f
|
||||
float[][] colorMatrixElements = new[] { new float[] { 1.0F, 0.0F, 0.0F, 0.0F, 0.0F }, new float[] { 0.0F, 1.0F, 0.0F, 0.0F, 0.0F }, new float[] { 0.0F, 0.0F, 1.0F, 0.0F, 0.0F }, new float[] { 0.0F, 0.0F, 0.0F, System.Convert.ToSingle(PicSettings.LogoTrasparenza) / 100F, 0.0F }, new float[] { 0.0F, 0.0F, 0.0F, 0.0F, 1.0F } };
|
||||
float[][] colorMatrixElements = new[] { new float[] { 1.0F, 0.0F, 0.0F, 0.0F, 0.0F }, new float[] { 0.0F, 1.0F, 0.0F, 0.0F, 0.0F }, new float[] { 0.0F, 0.0F, 1.0F, 0.0F, 0.0F }, new float[] { 0.0F, 0.0F, 0.0F, System.Convert.ToSingle(_picSettings.LogoTrasparenza) / 100F, 0.0F }, new float[] { 0.0F, 0.0F, 0.0F, 0.0F, 1.0F } };
|
||||
ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);
|
||||
imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
|
||||
int FotoLogoH = PicSettings.LogoAltezza;
|
||||
int FotoLogoW = PicSettings.LogoLarghezza;
|
||||
int FotoLogoH = _picSettings.LogoAltezza;
|
||||
int FotoLogoW = _picSettings.LogoLarghezza;
|
||||
double FattoreAlt = logo.Height / (double)FotoLogoH;
|
||||
double FattoreLarg = logo.Width / (double)FotoLogoW;
|
||||
Size NuovaSize;
|
||||
|
|
@ -713,11 +716,11 @@ public class ImageCreatorSharp : IDisposable
|
|||
int MargineUsato;
|
||||
int MargineL;
|
||||
bool InPercentualeL;
|
||||
if (PicSettings.LogoMargine.EndsWith("%") == true)
|
||||
if (_picSettings.LogoMargine.EndsWith("%") == true)
|
||||
InPercentualeL = true;
|
||||
else
|
||||
InPercentualeL = false;
|
||||
MargineL = System.Convert.ToInt32(PicSettings.LogoMargine);
|
||||
MargineL = System.Convert.ToInt32(_picSettings.LogoMargine);
|
||||
if (InPercentualeL == true)
|
||||
MargineUsato = System.Convert.ToInt32(imgOutputBig.Height * MargineL / (double)100);
|
||||
else
|
||||
|
|
@ -725,7 +728,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
int xPosOfWm = 0;
|
||||
int yPosOfWm = 0;
|
||||
switch (PicSettings.LogoPosizioneH.ToUpper())
|
||||
switch (_picSettings.LogoPosizioneH.ToUpper())
|
||||
{
|
||||
case "SINISTRA":
|
||||
case "NESSUNA":
|
||||
|
|
@ -746,7 +749,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
break;
|
||||
}
|
||||
}
|
||||
switch (PicSettings.LogoPosizioneV.ToUpper())
|
||||
switch (_picSettings.LogoPosizioneV.ToUpper())
|
||||
{
|
||||
case "ALTO":
|
||||
case "NESSUNA":
|
||||
|
|
@ -777,7 +780,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
private void SalvaFoto(Bitmap imgOutputBig, Size thumbSizeBig, string NomeFileBig, string NomeFileSmall, Size thumbSizeSmall, ImageFormat thisFormat)
|
||||
{
|
||||
using var image1Stream = new MemoryStream();
|
||||
if (PicSettings.FotoGrandeDimOrigina == false)
|
||||
if (_picSettings.FotoGrandeDimOrigina == false)
|
||||
{
|
||||
// attenzione non controlla se è png
|
||||
// imgOutputBig.Save(Path.Combine(_DestDir.FullName, "Temp_" & NomeFileBig), thisFormat)
|
||||
|
|
@ -785,7 +788,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
{
|
||||
MakeImageCustomQuality(imgOutputBig, image1Stream);
|
||||
}
|
||||
//SalvaImmagineCustomQuality(imgOutputBig, Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig), PicSettings.jpegQuality);
|
||||
//SalvaImmagineCustomQuality(imgOutputBig, Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig), _picSettings.jpegQuality);
|
||||
else
|
||||
{
|
||||
imgOutputBig.Save(image1Stream, thisFormat);
|
||||
|
|
@ -793,10 +796,10 @@ public class ImageCreatorSharp : IDisposable
|
|||
//imgOutputBig.Save(Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig), thisFormat);
|
||||
image1Stream.Seek(0, SeekOrigin.Begin);
|
||||
using var g2 = Image.FromStream(image1Stream);
|
||||
thumbSizeBig = g2.Width > g2.Height ? NewthumbSize(g2.Width, g2.Height, PicSettings.LarghezzaBig, "Larghezza") : NewthumbSize(g2.Width, g2.Height, PicSettings.AltezzaBig, "Altezza");
|
||||
thumbSizeBig = g2.Width > g2.Height ? NewthumbSize(g2.Width, g2.Height, _picSettings.LarghezzaBig, "Larghezza") : NewthumbSize(g2.Width, g2.Height, _picSettings.AltezzaBig, "Altezza");
|
||||
using Bitmap imgOutputBig2 = new Bitmap(g2, thumbSizeBig.Width, thumbSizeBig.Height);
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig2, Path.Combine(DestDir.FullName, NomeFileBig), PicSettings.JpegQuality);
|
||||
SalvaImmagineCustomQuality(imgOutputBig2, Path.Combine(DestDir.FullName, NomeFileBig), _picSettings.JpegQuality);
|
||||
else
|
||||
imgOutputBig2.Save(Path.Combine(DestDir.FullName, NomeFileBig), thisFormat);
|
||||
|
||||
|
|
@ -809,7 +812,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
{
|
||||
//
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputBig, Path.Combine(DestDir.FullName, NomeFileBig), PicSettings.JpegQuality);
|
||||
SalvaImmagineCustomQuality(imgOutputBig, Path.Combine(DestDir.FullName, NomeFileBig), _picSettings.JpegQuality);
|
||||
else
|
||||
imgOutputBig.Save(Path.Combine(DestDir.FullName, NomeFileBig), thisFormat);
|
||||
|
||||
|
|
@ -817,23 +820,23 @@ public class ImageCreatorSharp : IDisposable
|
|||
}
|
||||
image1Stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
if (PicSettings.CreaMiniature)
|
||||
if (_picSettings.CreaMiniature)
|
||||
{
|
||||
if (PicSettings.AggiungiScritteMiniature)
|
||||
if (_picSettings.AggiungiScritteMiniature)
|
||||
{
|
||||
using System.Drawing.Image g1 = PicSettings.FotoGrandeDimOrigina ? (Image)imgOutputBig.Clone() : Image.FromStream(image1Stream);
|
||||
//if (PicSettings.FotoGrandeDimOrigina == false)
|
||||
using System.Drawing.Image g1 = _picSettings.FotoGrandeDimOrigina ? (Image)imgOutputBig.Clone() : Image.FromStream(image1Stream);
|
||||
//if (_picSettings.FotoGrandeDimOrigina == false)
|
||||
// g1 = Image.FromStream(image1Stream);
|
||||
////g1 = System.Drawing.Image.FromFile(Path.Combine(DestDir.FullName, "Temp_" + NomeFileBig));
|
||||
//else
|
||||
// g1 = (Image)imgOutputBig.Clone();
|
||||
//g1 = System.Drawing.Image.FromFile(Path.Combine(DestDir.FullName, NomeFileBig));
|
||||
using Bitmap imgOutputSmall = new Bitmap(g1, thumbSizeSmall.Width, thumbSizeSmall.Height);
|
||||
if (string.Equals(PicSettings.DirectorySorgente, PicSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
NomeFileSmall = NomeFileSmall.Substring(0, NomeFileSmall.Length - 4) + PicSettings.Codice + NomeFileSmall.Substring(NomeFileSmall.Length - 4);
|
||||
if (string.Equals(_picSettings.DirectorySorgente, _picSettings.DirectoryDestinazione, StringComparison.OrdinalIgnoreCase))
|
||||
NomeFileSmall = NomeFileSmall.Substring(0, NomeFileSmall.Length - 4) + _picSettings.Codice + NomeFileSmall.Substring(NomeFileSmall.Length - 4);
|
||||
//
|
||||
if (thisFormat.Equals(ImageFormat.Jpeg))
|
||||
SalvaImmagineCustomQuality(imgOutputSmall, Path.Combine(DestDir.FullName, NomeFileSmall), PicSettings.JpegQualityMin);
|
||||
SalvaImmagineCustomQuality(imgOutputSmall, Path.Combine(DestDir.FullName, NomeFileSmall), _picSettings.JpegQualityMin);
|
||||
else
|
||||
imgOutputSmall.Save(Path.Combine(_DestDir.FullName, NomeFileSmall), thisFormat);
|
||||
|
||||
|
|
@ -854,7 +857,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
EncoderParameters MyEncoderParameters = new EncoderParameters(1);
|
||||
|
||||
EncoderParameter MyEncoderParameter = new EncoderParameter(MyEncoder, PicSettings.JpegQuality);
|
||||
EncoderParameter MyEncoderParameter = new EncoderParameter(MyEncoder, _picSettings.JpegQuality);
|
||||
MyEncoderParameters.Param[0] = MyEncoderParameter;
|
||||
imageToSave.Save(nomeFileFinale, JgpEncoder, MyEncoderParameters);
|
||||
//imageToSave.Dispose();
|
||||
|
|
@ -867,7 +870,7 @@ public class ImageCreatorSharp : IDisposable
|
|||
|
||||
EncoderParameters MyEncoderParameters = new EncoderParameters(1);
|
||||
|
||||
EncoderParameter MyEncoderParameter = new EncoderParameter(MyEncoder, PicSettings.JpegQuality);
|
||||
EncoderParameter MyEncoderParameter = new EncoderParameter(MyEncoder, _picSettings.JpegQuality);
|
||||
MyEncoderParameters.Param[0] = MyEncoderParameter;
|
||||
destinationStream.Seek(0, SeekOrigin.Begin);
|
||||
imageToSave.Save(destinationStream, JgpEncoder, MyEncoderParameters);
|
||||
|
|
|
|||
|
|
@ -5,63 +5,63 @@ using System.Windows.Forms;
|
|||
|
||||
namespace MaddoShared;
|
||||
|
||||
public static class PicSettings
|
||||
public class PicSettings
|
||||
{
|
||||
public static string DirectorySorgente { get; set; }
|
||||
public static string DirectoryDestinazione { get; set; }
|
||||
public static string TestoFirmaStart { get; set; }
|
||||
public static string TestoFirmaStartV { get; set; }
|
||||
public static DateTime DataPartenza { get; set; }
|
||||
public static string TestoOrario { get; set; }
|
||||
public static int DimStandard { get; set; }
|
||||
public static int DimStandardMiniatura { get; set; }
|
||||
public static bool NomeData { get; set; }
|
||||
public static bool TestoNome { get; set; }
|
||||
public static bool UsaOrarioMiniatura { get; set; }
|
||||
public static bool UsaOrarioTestoApplicare { get; set; }
|
||||
public static bool UsaTempoGaraTestoApplicare { get; set; }
|
||||
public static bool UsaRotazioneAutomatica { get; set; }
|
||||
public static bool UsaForzaJpg { get; set; }
|
||||
public static int LarghezzaSmall { get; set; }
|
||||
public static int AltezzaSmall { get; set; }
|
||||
public static bool CreaMiniature { get; set; }
|
||||
public static bool AggiungiScritteMiniature { get; set; }
|
||||
public static string Suffisso { get; set; }
|
||||
public static string Codice { get; set; }
|
||||
public static int Trasparenza { get; set; }
|
||||
public static string IlFont { get; set; }
|
||||
public static bool Grassetto { get; set; }
|
||||
public static string Posizione { get; set; }
|
||||
public static string Allineamento { get; set; }
|
||||
public static int Margine { get; set; }
|
||||
public static int LogoAltezza { get; set; }
|
||||
public static int LogoLarghezza { get; set; }
|
||||
public static Color FontColoreRGB { get; set; }
|
||||
public static bool LogoAggiungi { get; set; }
|
||||
public static string LogoNomeFile { get; set; }
|
||||
public static string LogoTrasparenza { get; set; }
|
||||
public static string LogoMargine { get; set; }
|
||||
public static string LogoPosizioneH { get; set; }
|
||||
public static string LogoPosizioneV { get; set; }
|
||||
public static bool FotoGrandeDimOrigina { get; set; }
|
||||
public static int AltezzaBig { get; set; }
|
||||
public static int LarghezzaBig { get; set; }
|
||||
public static DirectoryInfo DestDir { get; set; }
|
||||
public static int DimVert { get; set; }
|
||||
public static int MargVert { get; set; }
|
||||
public static bool TestoMin { get; set; }
|
||||
public static int DimMin { get; set; }
|
||||
public static bool SecretDefault { get; set; }
|
||||
public static bool SecretBig { get; set; }
|
||||
public static bool SecretSmall { get; set; }
|
||||
public static string SecretPathSmall { get; set; }
|
||||
public static string SecretPathBig { get; set; }
|
||||
public static bool AggTempoGaraMin { get; set; }
|
||||
public static bool AggNumTempMin { get; set; }
|
||||
public static long JpegQuality { get; set; }
|
||||
public static long JpegQualityMin { get; set; }
|
||||
public string DirectorySorgente { get; set; }
|
||||
public string DirectoryDestinazione { get; set; }
|
||||
public string TestoFirmaStart { get; set; }
|
||||
public string TestoFirmaStartV { get; set; }
|
||||
public DateTime DataPartenza { get; set; }
|
||||
public string TestoOrario { get; set; }
|
||||
public int DimStandard { get; set; }
|
||||
public int DimStandardMiniatura { get; set; }
|
||||
public bool NomeData { get; set; }
|
||||
public bool TestoNome { get; set; }
|
||||
public bool UsaOrarioMiniatura { get; set; }
|
||||
public bool UsaOrarioTestoApplicare { get; set; }
|
||||
public bool UsaTempoGaraTestoApplicare { get; set; }
|
||||
public bool UsaRotazioneAutomatica { get; set; }
|
||||
public bool UsaForzaJpg { get; set; }
|
||||
public int LarghezzaSmall { get; set; }
|
||||
public int AltezzaSmall { get; set; }
|
||||
public bool CreaMiniature { get; set; }
|
||||
public bool AggiungiScritteMiniature { get; set; }
|
||||
public string Suffisso { get; set; }
|
||||
public string Codice { get; set; }
|
||||
public int Trasparenza { get; set; }
|
||||
public string IlFont { get; set; }
|
||||
public bool Grassetto { get; set; }
|
||||
public string Posizione { get; set; }
|
||||
public string Allineamento { get; set; }
|
||||
public int Margine { get; set; }
|
||||
public int LogoAltezza { get; set; }
|
||||
public int LogoLarghezza { get; set; }
|
||||
public Color FontColoreRGB { get; set; }
|
||||
public bool LogoAggiungi { get; set; }
|
||||
public string LogoNomeFile { get; set; }
|
||||
public string LogoTrasparenza { get; set; }
|
||||
public string LogoMargine { get; set; }
|
||||
public string LogoPosizioneH { get; set; }
|
||||
public string LogoPosizioneV { get; set; }
|
||||
public bool FotoGrandeDimOrigina { get; set; }
|
||||
public int AltezzaBig { get; set; }
|
||||
public int LarghezzaBig { get; set; }
|
||||
public DirectoryInfo DestDir { get; set; }
|
||||
public int DimVert { get; set; }
|
||||
public int MargVert { get; set; }
|
||||
public bool TestoMin { get; set; }
|
||||
public int DimMin { get; set; }
|
||||
public bool SecretDefault { get; set; }
|
||||
public bool SecretBig { get; set; }
|
||||
public bool SecretSmall { get; set; }
|
||||
public string SecretPathSmall { get; set; }
|
||||
public string SecretPathBig { get; set; }
|
||||
public bool AggTempoGaraMin { get; set; }
|
||||
public bool AggNumTempMin { get; set; }
|
||||
public long JpegQuality { get; set; }
|
||||
public long JpegQualityMin { get; set; }
|
||||
|
||||
public static bool FotoRuotaADestra { get; set; } = false;
|
||||
public static bool FotoRuotaASinistra { get; set; } = false;
|
||||
public static string TempMinText { get; set; } = string.Empty;
|
||||
public bool FotoRuotaADestra { get; set; } = false;
|
||||
public bool FotoRuotaASinistra { get; set; } = false;
|
||||
public string TempMinText { get; set; } = string.Empty;
|
||||
}
|
||||
|
|
@ -30,12 +30,15 @@ public partial class MainForm
|
|||
private readonly ImageCreationStuff _imageCreationService;
|
||||
|
||||
private readonly ParametriSetup _parametriSetup;
|
||||
private readonly PicSettings _picSettings;
|
||||
|
||||
public MainForm(DataModel model, ImageCreationStuff imageCreationStuff, 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");
|
||||
|
|
@ -254,47 +257,6 @@ public partial class MainForm
|
|||
//Button6.Enabled = true;
|
||||
//btnCreaCatalogoAsync.Enabled = true;
|
||||
}
|
||||
|
||||
private void creaCatalogoThread()
|
||||
{
|
||||
var timeStart = DateTime.Now;
|
||||
MyPool.StopThreadPool();
|
||||
MyPool.StartThreadPool(minThreads, maxThreads);
|
||||
ContaImmaginiThread = 0;
|
||||
|
||||
// creaImmaginiWithThreadMod(txtSorgente.Text, txtDestinazione.Text)
|
||||
CreaimmaginiWithThreadDict(Model.SourcePath, Model.DestinationPath);
|
||||
ThreadPoolWorkItem ThAttivo = null;
|
||||
int i = 0;
|
||||
/* TODO ERROR: Skipped DefineDirectiveTrivia */
|
||||
/* TODO ERROR: Skipped IfDirectiveTrivia */
|
||||
|
||||
while (i != ContaImmaginiThread)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
ThAttivo = MyPool.ExtractWorkItem();
|
||||
if (ThAttivo is object)
|
||||
{
|
||||
i += 1;
|
||||
// stepProgressBar()
|
||||
int threads = MyPool.GetThreadCount();
|
||||
setLabel10Text("File: " + ThAttivo.m_sName + " Threads: " + threads.ToString());
|
||||
|
||||
// setLabel18Text(ContaImmaginiThread.ToString)
|
||||
// setLabel18Text(i.ToString)
|
||||
|
||||
|
||||
// Label10.Text = "File: " & ThAttivo.m_sName
|
||||
// Label18.Text = ContaImmaginiThread.ToString
|
||||
}
|
||||
}
|
||||
|
||||
MyPool.StopThreadPool();
|
||||
var timeStop = DateTime.Now;
|
||||
setLabel10Text("Finito");
|
||||
setLabel43Text(CalcTime(timeStart, timeStop, ContaImmaginiThread));
|
||||
/* TODO ERROR: Skipped EndIfDirectiveTrivia */
|
||||
}
|
||||
|
||||
private string CalcTime(DateTime timeStart, DateTime timeStop, int numFoto)
|
||||
{
|
||||
|
|
@ -325,20 +287,9 @@ public partial class MainForm
|
|||
var dialog = new FolderBrowserDialog();
|
||||
dialog.InitialDirectory = startingFolder;
|
||||
if (dialog.ShowDialog() != DialogResult.OK) return string.Empty;
|
||||
|
||||
// CommonOpenFileDialog dialog = new CommonOpenFileDialog
|
||||
// {
|
||||
// InitialDirectory = startingFolder,
|
||||
// IsFolderPicker = true
|
||||
// };
|
||||
// if (dialog.ShowDialog() != CommonFileDialogResult.Ok) return null;
|
||||
|
||||
var directoryScelta = FixPath(dialog.SelectedPath); // dialog.FileName;
|
||||
|
||||
// if (directoryScelta.EndsWith(@"\") == false)
|
||||
// {
|
||||
// directoryScelta += @"\";
|
||||
// }
|
||||
|
||||
return directoryScelta;
|
||||
}
|
||||
|
||||
|
|
@ -349,33 +300,6 @@ public partial class MainForm
|
|||
{
|
||||
Model.SourcePath = dialogResult;
|
||||
}
|
||||
|
||||
//CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
||||
//dialog.InitialDirectory = txtSorgente.Text;
|
||||
//dialog.IsFolderPicker = true;
|
||||
//if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
//{
|
||||
// string directoryScelta = dialog.FileName;
|
||||
// if (directoryScelta.EndsWith(@"\") == false)
|
||||
// {
|
||||
// directoryScelta += @"\";
|
||||
// }
|
||||
|
||||
// txtSorgente.Text = directoryScelta;
|
||||
//}
|
||||
|
||||
//var DirSearch = new FolderBrowserDialog();
|
||||
//DirSearch.SelectedPath = txtSorgente.Text;
|
||||
//if (DialogResult.OK == DirSearch.ShowDialog())
|
||||
//{
|
||||
// string DirectoryScelta = DirSearch.SelectedPath;
|
||||
// if (DirectoryScelta.EndsWith(@"\") == false)
|
||||
// {
|
||||
// DirectoryScelta += @"\";
|
||||
// }
|
||||
|
||||
// txtSorgente.Text = DirectoryScelta;
|
||||
//}
|
||||
}
|
||||
|
||||
private void Button3_Click(object sender, EventArgs e)
|
||||
|
|
@ -573,124 +497,82 @@ public partial class MainForm
|
|||
}
|
||||
}
|
||||
|
||||
private void setPicSettings(string SourcePath, string DestPath)
|
||||
private void SetPicSettings(string SourcePath, string DestPath)
|
||||
{
|
||||
var SourceDir = new DirectoryInfo(SourcePath);
|
||||
var DestDirStart = new DirectoryInfo(DestPath);
|
||||
DirectoryInfo DestDir = null;
|
||||
PicSettings.DirectorySorgente = SourcePath;
|
||||
PicSettings.DirectoryDestinazione = Model.DestinationPath;
|
||||
_picSettings.DirectorySorgente = SourcePath;
|
||||
_picSettings.DirectoryDestinazione = Model.DestinationPath;
|
||||
|
||||
// PicSettings.DestDir = DestDir
|
||||
// PicSettings.SourceDir = SourceDir
|
||||
// PicSettings.DestDirStart = DestDirStart
|
||||
// _picSettings.DestDir = DestDir
|
||||
// _picSettings.SourceDir = SourceDir
|
||||
// _picSettings.DestDirStart = DestDirStart
|
||||
|
||||
PicSettings.DimStandard = int.Parse(TextBox11.Text);
|
||||
PicSettings.DimStandardMiniatura = int.Parse(TextBox25.Text);
|
||||
PicSettings.UsaOrarioMiniatura = CheckBox12.Checked;
|
||||
PicSettings.UsaOrarioTestoApplicare = CheckBox8.Checked;
|
||||
PicSettings.UsaTempoGaraTestoApplicare = CheckBox7.Checked;
|
||||
PicSettings.UsaRotazioneAutomatica = chkRotazioneAutomatica.Checked;
|
||||
PicSettings.UsaForzaJpg = chkForzaJpg.Checked;
|
||||
_picSettings.DimStandard = int.Parse(TextBox11.Text);
|
||||
_picSettings.DimStandardMiniatura = int.Parse(TextBox25.Text);
|
||||
_picSettings.UsaOrarioMiniatura = CheckBox12.Checked;
|
||||
_picSettings.UsaOrarioTestoApplicare = CheckBox8.Checked;
|
||||
_picSettings.UsaTempoGaraTestoApplicare = CheckBox7.Checked;
|
||||
_picSettings.UsaRotazioneAutomatica = chkRotazioneAutomatica.Checked;
|
||||
_picSettings.UsaForzaJpg = chkForzaJpg.Checked;
|
||||
if (CheckBox17.Checked)
|
||||
{
|
||||
PicSettings.TestoNome = true;
|
||||
_picSettings.TestoNome = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PicSettings.TestoNome = false;
|
||||
_picSettings.TestoNome = false;
|
||||
}
|
||||
|
||||
if (CheckBox16.Checked)
|
||||
{
|
||||
PicSettings.NomeData = true;
|
||||
_picSettings.NomeData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PicSettings.NomeData = false;
|
||||
_picSettings.NomeData = false;
|
||||
}
|
||||
|
||||
PicSettings.TestoFirmaStart = Model.HorizontalText;
|
||||
PicSettings.TestoFirmaStartV = TextBox29.Text;
|
||||
PicSettings.DataPartenza = DateTimePicker1.Value;
|
||||
PicSettings.TestoOrario = TextBox18.Text;
|
||||
PicSettings.AltezzaSmall = int.Parse(TextBox6.Text);
|
||||
PicSettings.LarghezzaSmall = int.Parse(TextBox5.Text);
|
||||
PicSettings.CreaMiniature = CheckBox1.Checked;
|
||||
PicSettings.AggiungiScritteMiniature = RadioButton3.Checked;
|
||||
PicSettings.AggTempoGaraMin = RadioButton5.Checked;
|
||||
PicSettings.AggNumTempMin = RadioButton7.Checked;
|
||||
PicSettings.DimVert = int.Parse(TextBox30.Text);
|
||||
PicSettings.MargVert = int.Parse(TextBox31.Text);
|
||||
_picSettings.TestoFirmaStart = Model.HorizontalText;
|
||||
_picSettings.TestoFirmaStartV = TextBox29.Text;
|
||||
_picSettings.DataPartenza = DateTimePicker1.Value;
|
||||
_picSettings.TestoOrario = TextBox18.Text;
|
||||
_picSettings.AltezzaSmall = int.Parse(TextBox6.Text);
|
||||
_picSettings.LarghezzaSmall = int.Parse(TextBox5.Text);
|
||||
_picSettings.CreaMiniature = CheckBox1.Checked;
|
||||
_picSettings.AggiungiScritteMiniature = RadioButton3.Checked;
|
||||
_picSettings.AggTempoGaraMin = RadioButton5.Checked;
|
||||
_picSettings.AggNumTempMin = RadioButton7.Checked;
|
||||
_picSettings.DimVert = int.Parse(TextBox30.Text);
|
||||
_picSettings.MargVert = int.Parse(TextBox31.Text);
|
||||
|
||||
// PicSettings.NomeFileChild = childFile.Name
|
||||
PicSettings.Suffisso = TextBox3.Text;
|
||||
// PicSettings.Codice = TextBox13.Text
|
||||
// _picSettings.NomeFileChild = childFile.Name
|
||||
_picSettings.Suffisso = TextBox3.Text;
|
||||
// _picSettings.Codice = TextBox13.Text
|
||||
|
||||
PicSettings.Trasparenza = int.Parse(TextBox9.Text);
|
||||
PicSettings.IlFont = ComboBox3.SelectedItem.ToString();
|
||||
PicSettings.Grassetto = CheckBox3.Checked;
|
||||
PicSettings.Posizione = ComboBox1.SelectedItem.ToString();
|
||||
PicSettings.Allineamento = ComboBox2.SelectedItem.ToString();
|
||||
PicSettings.Margine = int.Parse(TextBox12.Text);
|
||||
PicSettings.LogoAltezza = int.Parse(TextBox14.Text);
|
||||
PicSettings.LogoLarghezza = int.Parse(TextBox15.Text);
|
||||
PicSettings.FontColoreRGB = ColorTranslator.FromHtml(TextBox34.Text);
|
||||
PicSettings.LogoAggiungi = CheckBox5.Checked;
|
||||
PicSettings.LogoNomeFile = TextBox10.Text;
|
||||
PicSettings.LogoTrasparenza = TextBox19.Text;
|
||||
PicSettings.LogoMargine = TextBox16.Text;
|
||||
PicSettings.LogoPosizioneH = ComboBox4.Text;
|
||||
PicSettings.LogoPosizioneV = ComboBox5.Text;
|
||||
PicSettings.FotoGrandeDimOrigina = CheckBox15.Checked;
|
||||
PicSettings.AltezzaBig = int.Parse(TextBox27.Text);
|
||||
PicSettings.LarghezzaBig = int.Parse(TextBox28.Text);
|
||||
PicSettings.DimMin = int.Parse(TextBox25.Text);
|
||||
PicSettings.TestoMin = RadioButton6.Checked;
|
||||
PicSettings.JpegQuality = int.Parse(TextBox32.Text);
|
||||
PicSettings.JpegQualityMin = int.Parse(TextBox33.Text);
|
||||
}
|
||||
|
||||
private List<List<FileInfo>> makeFilesList(string SourcePath)
|
||||
{
|
||||
var SourceDir = new DirectoryInfo(SourcePath);
|
||||
DirectoryInfo DestDir = null;
|
||||
int NumFileXDir = int.Parse(txtFilePerCartella.Text);
|
||||
string SuffixDir = txtSuffissoCartelle.Text;
|
||||
int NumCifreDir = int.Parse(txtCifreContatore.Text);
|
||||
bool DividiFile = false;
|
||||
StopAttivo = false;
|
||||
int FileConta = 0;
|
||||
int ContaFileXDir = 0;
|
||||
int ContaDirXDir = 0;
|
||||
string TestoTemp = "";
|
||||
int ContaTemp = 0;
|
||||
var picList = new List<FileInfo>();
|
||||
var dirList = new List<List<FileInfo>>();
|
||||
|
||||
|
||||
// controlla directory principale
|
||||
// Dim childFile As FileInfo
|
||||
// For Each childFile In SourceDir.GetFiles("*.jpg")
|
||||
// picList.Add(childFile)
|
||||
// Next
|
||||
|
||||
// picList = getFiles(SourceDir, SearchOption.AllDirectories)
|
||||
|
||||
// dirList.Add(picList)
|
||||
|
||||
// controlla sottodirectory
|
||||
if (chkAggiornaSottodirectory.Checked == true)
|
||||
{
|
||||
foreach (var subDir in SourceDir.GetDirectories())
|
||||
{
|
||||
var filesList = new List<FileInfo>();
|
||||
filesList = getFiles(subDir);
|
||||
dirList.Add(filesList);
|
||||
}
|
||||
}
|
||||
|
||||
return dirList;
|
||||
_picSettings.Trasparenza = int.Parse(TextBox9.Text);
|
||||
_picSettings.IlFont = ComboBox3.SelectedItem.ToString();
|
||||
_picSettings.Grassetto = CheckBox3.Checked;
|
||||
_picSettings.Posizione = ComboBox1.SelectedItem.ToString();
|
||||
_picSettings.Allineamento = ComboBox2.SelectedItem.ToString();
|
||||
_picSettings.Margine = int.Parse(TextBox12.Text);
|
||||
_picSettings.LogoAltezza = int.Parse(TextBox14.Text);
|
||||
_picSettings.LogoLarghezza = int.Parse(TextBox15.Text);
|
||||
_picSettings.FontColoreRGB = ColorTranslator.FromHtml(TextBox34.Text);
|
||||
_picSettings.LogoAggiungi = CheckBox5.Checked;
|
||||
_picSettings.LogoNomeFile = TextBox10.Text;
|
||||
_picSettings.LogoTrasparenza = TextBox19.Text;
|
||||
_picSettings.LogoMargine = TextBox16.Text;
|
||||
_picSettings.LogoPosizioneH = ComboBox4.Text;
|
||||
_picSettings.LogoPosizioneV = ComboBox5.Text;
|
||||
_picSettings.FotoGrandeDimOrigina = CheckBox15.Checked;
|
||||
_picSettings.AltezzaBig = int.Parse(TextBox27.Text);
|
||||
_picSettings.LarghezzaBig = int.Parse(TextBox28.Text);
|
||||
_picSettings.DimMin = int.Parse(TextBox25.Text);
|
||||
_picSettings.TestoMin = RadioButton6.Checked;
|
||||
_picSettings.JpegQuality = int.Parse(TextBox32.Text);
|
||||
_picSettings.JpegQualityMin = int.Parse(TextBox33.Text);
|
||||
}
|
||||
|
||||
private List<FileInfo> getFiles(DirectoryInfo sourceDir)
|
||||
|
|
@ -701,114 +583,6 @@ public partial class MainForm
|
|||
return picList;
|
||||
}
|
||||
|
||||
private Dictionary<FileInfo, DirectoryInfo> getDirsDict(string SourcePath, string DestPath)
|
||||
{
|
||||
var SourceDir = new DirectoryInfo(SourcePath);
|
||||
var DestDirStart = new DirectoryInfo(DestPath);
|
||||
DirectoryInfo DestDir = null;
|
||||
int NumFileXDir = int.Parse(txtFilePerCartella.Text);
|
||||
string SuffixDir = txtSuffissoCartelle.Text;
|
||||
int NumCifreDir = int.Parse(txtCifreContatore.Text);
|
||||
bool DividiFile = false;
|
||||
StopAttivo = false;
|
||||
int FileConta = 0;
|
||||
int ContaFileXDir = 0;
|
||||
int ContaDirXDir = 0;
|
||||
// Dim TestoTemp As String = ""
|
||||
// Dim ContaTemp As Integer = 0
|
||||
var dirSourceDest = new Dictionary<FileInfo, DirectoryInfo>();
|
||||
if (SourceDir.Exists)
|
||||
{
|
||||
if (chkAggiornaSottodirectory.Checked)
|
||||
{
|
||||
FileConta = SourceDir.GetFiles("*.jpg", SearchOption.AllDirectories).GetLength(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
FileConta = SourceDir.GetFiles("*.jpg", SearchOption.TopDirectoryOnly).GetLength(0);
|
||||
}
|
||||
|
||||
var a = (int.Parse(lblFotoTotaliNum.Text) + FileConta);
|
||||
setLabel17Text(a.ToString());
|
||||
setProgressBarMaximum(a);
|
||||
if (chkAggiornaSottodirectory.Checked)
|
||||
{
|
||||
foreach (DirectoryInfo directory in SourceDir.GetDirectories())
|
||||
{
|
||||
foreach (FileInfo file in directory.GetFiles(".jpg"))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (FileInfo file in SourceDir.GetFiles("*.jpg", SearchOption.AllDirectories))
|
||||
{
|
||||
}
|
||||
|
||||
if (NumFileXDir > 0 & chkCreaSottocartelle.Checked == true & FileConta > NumFileXDir)
|
||||
{
|
||||
DividiFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = DestDirStart;
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
|
||||
DividiFile = false;
|
||||
}
|
||||
|
||||
var filesList = new List<FileInfo>();
|
||||
if (chkAggiornaSottodirectory.Checked)
|
||||
{
|
||||
filesList.AddRange(SourceDir.GetFiles("*.jpg", SearchOption.AllDirectories));
|
||||
filesList.AddRange(SourceDir.GetFiles("*.png", SearchOption.AllDirectories));
|
||||
}
|
||||
else
|
||||
{
|
||||
filesList.AddRange(SourceDir.GetFiles("*.jpg", SearchOption.TopDirectoryOnly));
|
||||
filesList.AddRange(SourceDir.GetFiles("*.png", SearchOption.TopDirectoryOnly));
|
||||
}
|
||||
|
||||
foreach (FileInfo file in filesList)
|
||||
{
|
||||
ContaFileXDir += 1;
|
||||
if (DividiFile == true)
|
||||
{
|
||||
if (ContaFileXDir == ContaDirXDir * NumFileXDir + 1)
|
||||
{
|
||||
ContaDirXDir += 1;
|
||||
string TestoTemp;
|
||||
if (rdbNumProgressiva.Checked == true)
|
||||
{
|
||||
TestoTemp = ContaDirXDir.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
TestoTemp = (ContaDirXDir * NumFileXDir).ToString();
|
||||
}
|
||||
|
||||
for (int ContaTemp = 1, loopTo = NumCifreDir - TestoTemp.Length;
|
||||
ContaTemp <= loopTo;
|
||||
ContaTemp++)
|
||||
TestoTemp = "0" + TestoTemp;
|
||||
DestDir = new DirectoryInfo(Path.Combine(DestDirStart.FullName, SuffixDir, TestoTemp));
|
||||
// DestDir = New DirectoryInfo(DestDirStart.FullName & IIf(Not DestDirStart.FullName.EndsWith("\"), "\", String.Empty).ToString & SuffixDir & TestoTemp)
|
||||
dirSourceDest.Add(file, DestDir);
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dirSourceDest;
|
||||
}
|
||||
|
||||
private void setLabel17Text(string text)
|
||||
{
|
||||
if (lblFotoTotaliNum.InvokeRequired)
|
||||
|
|
@ -895,127 +669,6 @@ public partial class MainForm
|
|||
}
|
||||
}
|
||||
|
||||
private void creaImmaginiWithThreadMod(string SourcePath, string DestPath)
|
||||
{
|
||||
var SourceDir = new DirectoryInfo(SourcePath);
|
||||
var DestDirStart = new DirectoryInfo(DestPath);
|
||||
DirectoryInfo DestDir = null;
|
||||
int NumFileXDir = int.Parse(txtFilePerCartella.Text);
|
||||
string SuffixDir = txtSuffissoCartelle.Text;
|
||||
int NumCifreDir = int.Parse(txtCifreContatore.Text);
|
||||
bool DividiFile = false;
|
||||
StopAttivo = false;
|
||||
int FileConta = 0;
|
||||
int ContaFileXDir = 0;
|
||||
int ContaDirXDir = 0;
|
||||
string TestoTemp = "";
|
||||
int ContaTemp = 0;
|
||||
if (SourceDir.Exists)
|
||||
{
|
||||
FileConta = SourceDir.GetFiles("*.jpg").GetLength(0);
|
||||
// Label17.Text = (CType(Label17.Text, Integer) + FileConta).ToString
|
||||
var a = (int.Parse(lblFotoTotaliNum.Text) + FileConta);
|
||||
setLabel17Text(a.ToString());
|
||||
setProgressBarMaximum(a);
|
||||
if (NumFileXDir > 0 & chkCreaSottocartelle.Checked == true)
|
||||
{
|
||||
if (FileConta > NumFileXDir)
|
||||
{
|
||||
DividiFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = DestDirStart;
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
|
||||
DividiFile = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = DestDirStart;
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
|
||||
DividiFile = false;
|
||||
}
|
||||
|
||||
foreach (var childFile in SourceDir.GetFiles("*.jpg"))
|
||||
{
|
||||
if (StopAttivo == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
setLabel10Text("File: " + childFile.Name);
|
||||
string b = (int.Parse(Label18.Text) + 1).ToString();
|
||||
// setLabel18Text(b)
|
||||
// setProgressBarValue(CInt(b))
|
||||
// Label10.Text = "File: " & childFile.Name
|
||||
// Label18.Text = (CType(Label18.Text, Integer) + 1).ToString
|
||||
// Application.DoEvents()
|
||||
|
||||
ContaFileXDir += 1;
|
||||
if (DividiFile == true)
|
||||
{
|
||||
if (ContaFileXDir == ContaDirXDir * NumFileXDir + 1)
|
||||
{
|
||||
ContaDirXDir += 1;
|
||||
if (rdbNumProgressiva.Checked == true)
|
||||
{
|
||||
TestoTemp = ContaDirXDir.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
TestoTemp = (ContaDirXDir * NumFileXDir).ToString();
|
||||
}
|
||||
|
||||
var loopTo = NumCifreDir - TestoTemp.Length;
|
||||
for (ContaTemp = 1; ContaTemp <= loopTo; ContaTemp++)
|
||||
TestoTemp = "0" + TestoTemp;
|
||||
if (DestDirStart.FullName.EndsWith(@"\"))
|
||||
{
|
||||
DestDir = new DirectoryInfo(DestDirStart.FullName + SuffixDir + TestoTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = new DirectoryInfo(DestDirStart.FullName + @"\" + SuffixDir + TestoTemp);
|
||||
}
|
||||
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Application.DoEvents()
|
||||
|
||||
|
||||
var ClsCreaImmagine = new ImageCreatorSharp(childFile.Name, SourceDir, DestDir, DestDirStart);
|
||||
// ClsCreaImmagine.NomeFileChild = childFile.Name
|
||||
// ClsCreaImmagine.DestDir = DestDir
|
||||
// ClsCreaImmagine.SourceDir = SourceDir
|
||||
// ClsCreaImmagine.DestDirStart = DestDirStart
|
||||
|
||||
ContaImmaginiThread += 1;
|
||||
//MyPool.InsertWorkItem(childFile.Name, new XyThreadAdd((_) => ClsCreaImmagine.CreaImmagineThread()), new object[1] { childFile.Name }, true);
|
||||
}
|
||||
|
||||
// copy all the sub-directories by recursively calling this same routine
|
||||
if (chkAggiornaSottodirectory.Checked == true)
|
||||
{
|
||||
foreach (var subDir in SourceDir.GetDirectories())
|
||||
creaImmaginiWithThreadMod(subDir.FullName, Path.Combine(DestDir.FullName, subDir.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getNumerazione()
|
||||
{
|
||||
int numerazione;
|
||||
|
|
@ -1045,212 +698,7 @@ public partial class MainForm
|
|||
|
||||
return numerazioneType;
|
||||
}
|
||||
|
||||
private void CreaimmaginiWithThreadDict(string SourcePath, string DestPath)
|
||||
{
|
||||
var dirSourceDest = new Dictionary<FileInfo, DirectoryInfo>();
|
||||
if (chkAggiornaSottodirectory.Checked & chkCreaSottocartelle.Checked)
|
||||
{
|
||||
var helper = new FileHelper(int.Parse(txtFilePerCartella.Text), txtSuffissoCartelle.Text,
|
||||
int.Parse(txtCifreContatore.Text), getNumerazione());
|
||||
// getfilesrecursive
|
||||
dirSourceDest =
|
||||
helper.GetFilesRecursive(new DirectoryInfo(SourcePath), new DirectoryInfo(DestPath), "*.jpg");
|
||||
}
|
||||
else if (chkAggiornaSottodirectory.Checked & !chkCreaSottocartelle.Checked)
|
||||
{
|
||||
// = getDirsDict(SourcePath, DestPath)
|
||||
}
|
||||
|
||||
foreach (var pair in dirSourceDest)
|
||||
{
|
||||
setLabel10Text("File: " + pair.Key.Name);
|
||||
string b = (int.Parse(Label18.Text) + 1).ToString();
|
||||
var ClsCreaImmagine = new ImageCreatorSharp(pair.Key, pair.Value);
|
||||
ContaImmaginiThread += 1;
|
||||
//MyPool.InsertWorkItem(pair.Key.Name, new XyThreadAdd((_) => ClsCreaImmagine.CreaImmagineThread()), new object[1] { pair.Key.Name }, true);
|
||||
}
|
||||
}
|
||||
|
||||
// il posto giusto dove fare modifiche
|
||||
private void CreaImmaginiWithThread(string SourcePath, string DestPath)
|
||||
{
|
||||
var SourceDir = new DirectoryInfo(SourcePath);
|
||||
var DestDirStart = new DirectoryInfo(DestPath);
|
||||
DirectoryInfo DestDir = null;
|
||||
int NumFileXDir = int.Parse(txtFilePerCartella.Text);
|
||||
string SuffixDir = txtSuffissoCartelle.Text;
|
||||
int NumCifreDir = int.Parse(txtCifreContatore.Text);
|
||||
bool DividiFile = false;
|
||||
StopAttivo = false;
|
||||
int FileConta = 0;
|
||||
int ContaFileXDir = 0;
|
||||
int ContaDirXDir = 0;
|
||||
string TestoTemp = "";
|
||||
int ContaTemp = 0;
|
||||
if (SourceDir.Exists)
|
||||
{
|
||||
FileConta = SourceDir.GetFiles("*.jpg").GetLength(0);
|
||||
lblFotoTotaliNum.Text = (int.Parse(lblFotoTotaliNum.Text) + FileConta).ToString();
|
||||
if (NumFileXDir > 0 & chkCreaSottocartelle.Checked == true)
|
||||
{
|
||||
if (FileConta > NumFileXDir)
|
||||
{
|
||||
DividiFile = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = DestDirStart;
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
|
||||
DividiFile = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = DestDirStart;
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
|
||||
DividiFile = false;
|
||||
}
|
||||
|
||||
foreach (var childFile in SourceDir.GetFiles("*.jpg"))
|
||||
{
|
||||
if (StopAttivo == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
// Label10.Text = "File: " & childFile.Name
|
||||
// Label18.Text = (CType(Label18.Text, Integer) + 1).ToString
|
||||
// Application.DoEvents()
|
||||
|
||||
ContaFileXDir += 1;
|
||||
if (DividiFile == true)
|
||||
{
|
||||
if (ContaFileXDir == ContaDirXDir * NumFileXDir + 1)
|
||||
{
|
||||
ContaDirXDir += 1;
|
||||
if (rdbNumProgressiva.Checked == true)
|
||||
{
|
||||
TestoTemp = ContaDirXDir.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
TestoTemp = (ContaDirXDir * NumFileXDir).ToString();
|
||||
}
|
||||
|
||||
var loopTo = NumCifreDir - TestoTemp.Length;
|
||||
for (ContaTemp = 1; ContaTemp <= loopTo; ContaTemp++)
|
||||
TestoTemp = "0" + TestoTemp;
|
||||
if (DestDirStart.FullName.EndsWith(@"\"))
|
||||
{
|
||||
DestDir = new DirectoryInfo(DestDirStart.FullName + SuffixDir + TestoTemp);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestDir = new DirectoryInfo(DestDirStart.FullName + @"\" + SuffixDir + TestoTemp);
|
||||
}
|
||||
|
||||
if (!DestDir.Exists)
|
||||
{
|
||||
DestDir.Create();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
var ClsCreaImmagine = new CreaImmagineSeparateThread();
|
||||
ClsCreaImmagine.DirectorySorgente = SourcePath;
|
||||
ClsCreaImmagine.DirectoryDestinazione = Model.DestinationPath;
|
||||
ClsCreaImmagine.DestDir = DestDir;
|
||||
ClsCreaImmagine.SourceDir = SourceDir;
|
||||
ClsCreaImmagine.DestDirStart = DestDirStart;
|
||||
ClsCreaImmagine.DimStandard = int.Parse(TextBox11.Text);
|
||||
ClsCreaImmagine.DimStandardMiniatura = int.Parse(TextBox25.Text);
|
||||
ClsCreaImmagine.UsaOrarioMiniatura = CheckBox12.Checked;
|
||||
ClsCreaImmagine.UsaOrarioTestoApplicare = CheckBox8.Checked;
|
||||
ClsCreaImmagine.UsaTempoGaraTestoApplicare = CheckBox7.Checked;
|
||||
ClsCreaImmagine.UsaRotazioneAutomatica = chkRotazioneAutomatica.Checked;
|
||||
ClsCreaImmagine.UsaForzaJpg = chkForzaJpg.Checked;
|
||||
if (CheckBox17.Checked)
|
||||
{
|
||||
ClsCreaImmagine.TestoNome = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClsCreaImmagine.TestoNome = false;
|
||||
}
|
||||
|
||||
if (CheckBox16.Checked)
|
||||
{
|
||||
ClsCreaImmagine.NomeData = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ClsCreaImmagine.NomeData = false;
|
||||
}
|
||||
|
||||
ClsCreaImmagine.TestoFirmaStart = Model.HorizontalText;
|
||||
ClsCreaImmagine.TestoFirmaStartV = TextBox29.Text;
|
||||
ClsCreaImmagine.DataPartenza = DateTimePicker1.Value;
|
||||
ClsCreaImmagine.TestoOrario = TextBox18.Text;
|
||||
ClsCreaImmagine.AltezzaSmall = int.Parse(TextBox5.Text);
|
||||
ClsCreaImmagine.LarghezzaSmall = int.Parse(TextBox5.Text);
|
||||
ClsCreaImmagine.CreaMiniature = CheckBox1.Checked;
|
||||
ClsCreaImmagine.AggiungiScritteMiniature = RadioButton3.Checked;
|
||||
ClsCreaImmagine.AggTempoGaraMin = RadioButton5.Checked;
|
||||
ClsCreaImmagine.AggNumTempMin = RadioButton7.Checked;
|
||||
ClsCreaImmagine.DimVert = int.Parse(TextBox30.Text);
|
||||
ClsCreaImmagine.MargVert = int.Parse(TextBox31.Text);
|
||||
ClsCreaImmagine.NomeFileChild = childFile.Name;
|
||||
ClsCreaImmagine.Suffisso = TextBox3.Text;
|
||||
// ClsCreaImmagine.Codice = TextBox13.Text
|
||||
|
||||
ClsCreaImmagine.Trasparenza = int.Parse(TextBox9.Text);
|
||||
ClsCreaImmagine.IlFont = ComboBox3.SelectedItem.ToString();
|
||||
ClsCreaImmagine.Grassetto = CheckBox3.Checked;
|
||||
ClsCreaImmagine.Posizione = ComboBox1.SelectedItem.ToString();
|
||||
ClsCreaImmagine.Allineamento = ComboBox2.SelectedItem.ToString();
|
||||
ClsCreaImmagine.Margine = int.Parse(TextBox12.Text);
|
||||
ClsCreaImmagine.LogoAltezza = int.Parse(TextBox14.Text);
|
||||
ClsCreaImmagine.LogoLarghezza = int.Parse(TextBox15.Text);
|
||||
|
||||
// ClsCreaImmagine.FontColoreR = CType(TextBox22.Text, Integer)
|
||||
// ClsCreaImmagine.FontColoreG = CType(TextBox23.Text, Integer)
|
||||
// ClsCreaImmagine.FontColoreB = CType(TextBox24.Text, Integer)
|
||||
ClsCreaImmagine.fontColoreRGB = ColorTranslator.FromHtml(TextBox34.Text);
|
||||
ClsCreaImmagine.LogoAggiungi = CheckBox5.Checked;
|
||||
ClsCreaImmagine.LogoNomeFile = TextBox10.Text;
|
||||
ClsCreaImmagine.LogoTrasparenza = TextBox19.Text;
|
||||
ClsCreaImmagine.LogoMargine = TextBox16.Text;
|
||||
ClsCreaImmagine.LogoPosizioneH = ComboBox4.Text;
|
||||
ClsCreaImmagine.LogoPosizioneV = ComboBox5.Text;
|
||||
ClsCreaImmagine.FotoGrandeDimOrigina = CheckBox15.Checked;
|
||||
ClsCreaImmagine.AltezzaBig = int.Parse(TextBox27.Text);
|
||||
ClsCreaImmagine.LarghezzaBig = int.Parse(TextBox28.Text);
|
||||
ClsCreaImmagine.DimMin = int.Parse(TextBox25.Text);
|
||||
ClsCreaImmagine.TestoMin = RadioButton6.Checked;
|
||||
ClsCreaImmagine.jpegQuality = int.Parse(TextBox32.Text);
|
||||
ClsCreaImmagine.jpegQualityMin = int.Parse(TextBox33.Text);
|
||||
ContaImmaginiThread += 1;
|
||||
MyPool.InsertWorkItem(childFile.Name, new XyThreadAdd(ClsCreaImmagine.CreaImmagineThread),
|
||||
new object[1] { childFile.Name }, true);
|
||||
}
|
||||
|
||||
// copy all the sub-directories by recursively calling this same routine
|
||||
if (chkAggiornaSottodirectory.Checked == true)
|
||||
{
|
||||
foreach (var subDir in SourceDir.GetDirectories())
|
||||
CreaImmaginiWithThread(subDir.FullName, Path.Combine(DestDir.FullName, subDir.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void CopyDirectoryFile(string SourcePath, string DestPath, bool OverWrite = false)
|
||||
{
|
||||
|
|
@ -1395,31 +843,6 @@ public partial class MainForm
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Private Declare Function CreateDC Lib "gdi32.dll" (ByVal strDriver As String, ByVal strDevice As String, ByVal strOutput As String, ByVal pData As IntPtr) As IntPtr
|
||||
// Private Declare Function DeleteDC Lib "gdi32.dll" (ByVal hdc As IntPtr) As Boolean
|
||||
// Private Declare Function GetPixel Lib "gdi32.dll" (ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer) As Integer
|
||||
// Private Declare Function GetCursorPos Lib "user32.dll" (ByRef lpPoint As Point) As Boolean
|
||||
|
||||
|
||||
// ''' <summary>
|
||||
// ''' Get the color relative to mouse position
|
||||
// ''' </summary>
|
||||
// Private Sub GetColor()
|
||||
// Dim hdcScreen As IntPtr = CreateDC("Display", Nothing, Nothing, IntPtr.Zero)
|
||||
// Dim pt As Point = New Point
|
||||
// GetCursorPos(pt)
|
||||
// Dim cr As Integer = GetPixel(hdcScreen, pt.X, pt.Y)
|
||||
// DeleteDC(hdcScreen)
|
||||
// Dim clr As Color = Color.FromArgb((cr And &HFF), (cr And &HFF00) >> 8, (cr And &HFF0000) >> 16)
|
||||
// PictureBox3.BackColor = clr
|
||||
// If WaterSelectColor = True Then
|
||||
// PictureBox2.BackColor = clr
|
||||
// End If
|
||||
// WaterSelectColor = False
|
||||
// End Sub
|
||||
|
||||
|
||||
private Color[] GetPixelColor(Point screenLocation)
|
||||
{
|
||||
// Dim bm As New Bitmap(1, 1, Imaging.PixelFormat.Format24bppRgb)
|
||||
|
|
@ -1494,13 +917,13 @@ public partial class MainForm
|
|||
lblFotoTotaliNum.Text = "0";
|
||||
Label18.Text = "0";
|
||||
Label43.Text = "-s";
|
||||
setPicSettings(Model.SourcePath, Model.DestinationPath);
|
||||
SetPicSettings(Model.SourcePath, Model.DestinationPath);
|
||||
ProgressBar1.Minimum = 0;
|
||||
ProgressBar1.Step = 1;
|
||||
ProgressBar1.Value = 0;
|
||||
|
||||
// Await CreaCatalogoParallel()
|
||||
var imgStf = _imageCreationService; //new ImageCreationStuff();
|
||||
|
||||
var imageCreationOptions = new ImageCreationStuff.Options
|
||||
{
|
||||
AggiornaSottodirectory = chkAggiornaSottodirectory.Checked,
|
||||
|
|
@ -1526,7 +949,7 @@ public partial class MainForm
|
|||
timer1.Interval = 1000 * 60;
|
||||
timer1.Enabled = true;
|
||||
|
||||
string time = await imgStf.CreaCatalogoParallel(imageCreationOptions, _results, UiUpdateEvent, token);
|
||||
string time = await _imageCreationService.CreaCatalogoParallel(imageCreationOptions, _results, UiUpdateEvent, token);
|
||||
Label43.Text = time;
|
||||
timer1.Enabled = false;
|
||||
}
|
||||
|
|
@ -1562,105 +985,6 @@ public partial class MainForm
|
|||
{
|
||||
Label10.Invoke(new Action(() => Label10.Text = text));
|
||||
}
|
||||
|
||||
|
||||
private async Task CreaCatalogoParallel()
|
||||
{
|
||||
var timeStart = DateTime.Now;
|
||||
ContaImmaginiThread = 0;
|
||||
setLabel10Text("Elaborazione in corso...");
|
||||
var imgStf = _imageCreationService;
|
||||
var imageCreationOptions = new ImageCreationStuff.Options();
|
||||
imageCreationOptions.AggiornaSottodirectory = chkAggiornaSottodirectory.Checked;
|
||||
imageCreationOptions.CreaSottocartelle = chkCreaSottocartelle.Checked;
|
||||
imageCreationOptions.FilePerCartella = int.Parse(txtFilePerCartella.Text);
|
||||
imageCreationOptions.SuffissoCartelle = txtSuffissoCartelle.Text;
|
||||
imageCreationOptions.CifreContatore = int.Parse(txtCifreContatore.Text);
|
||||
imageCreationOptions.NumerazioneType = GetNumerazioneEnum();
|
||||
imageCreationOptions.SourcePath = Model.SourcePath;
|
||||
imageCreationOptions.DestinationPath = Model.DestinationPath;
|
||||
await imgStf.ProcessImagesParallel(imageCreationOptions, _results, UiUpdateEvent);
|
||||
|
||||
// Await CreaImmaginiParallel(txtSorgente.Text, txtDestinazione.Text)
|
||||
|
||||
setLabel10Text("Finito");
|
||||
var timeStop = DateTime.Now;
|
||||
setLabel43Text(CalcTime(timeStart, timeStop, ContaImmaginiThread));
|
||||
}
|
||||
|
||||
// Private Async Function CreaImmaginiParallel(ByVal SourcePath As String, ByVal DestPath As String) As Task
|
||||
// Dim dataToProcess As List(Of FileData) = New List(Of FileData)
|
||||
|
||||
// 'Dim dirSourceDest As Dictionary(Of FileInfo, DirectoryInfo) = New Dictionary(Of FileInfo, DirectoryInfo)
|
||||
// If chkAggiornaSottodirectory.Checked And chkCreaSottocartelle.Checked Then
|
||||
|
||||
// Dim helperSharp As New FileHelperSharp()
|
||||
|
||||
// 'Dim helper As New FileHelper(CInt(txtFilePerCartella.Text), txtSuffissoCartelle.Text, CInt(txtCifreContatore.Text), getNumerazione())
|
||||
// 'getfilesrecursive
|
||||
|
||||
// Dim fileHelperOptions As FileHelperOptions = New FileHelperOptions()
|
||||
// fileHelperOptions.FilesPerFolder = CInt(txtFilePerCartella.Text)
|
||||
// fileHelperOptions.Suffix = txtSuffissoCartelle.Text
|
||||
// fileHelperOptions.CounterSize = CInt(txtCifreContatore.Text)
|
||||
// fileHelperOptions.NumerationType = GetNumerazioneEnum()
|
||||
|
||||
// dataToProcess = helperSharp.GetFilesRecursive(New DirectoryInfo(SourcePath), New DirectoryInfo(DestPath), "*.jpg", fileHelperOptions)
|
||||
|
||||
// 'dataToProcess = helper.GetFilesRecursiveParallel(New DirectoryInfo(SourcePath), New DirectoryInfo(DestPath), "*.jpg")
|
||||
// ElseIf chkAggiornaSottodirectory.Checked And Not chkCreaSottocartelle.Checked Then
|
||||
// ' TODO manca tutto?!?!?!?
|
||||
// End If
|
||||
|
||||
// Dim scheduler As TaskScheduler = New ConcurrentExclusiveSchedulerPair(TaskScheduler.Default, Environment.ProcessorCount * 2).ConcurrentScheduler
|
||||
|
||||
// Dim test As IEnumerable(Of Task) = From d In dataToProcess Select Task.Factory.StartNew(Sub()
|
||||
// 'setLabel10Text("File: " & p.File.Name)
|
||||
|
||||
// Dim b As String = (CType(Label18.Text, Integer) + 1).ToString
|
||||
|
||||
// Dim clsCreaImmagine As New ImageCreator(d.File, d.Directory)
|
||||
|
||||
// clsCreaImmagine.CreaImmagineThread(d.File.Name)
|
||||
|
||||
// ContaImmaginiThread += 1
|
||||
// UpdateCounter(ContaImmaginiThread & " " & d.File.Name)
|
||||
// End Sub, CancellationToken.None, TaskCreationOptions.LongRunning, scheduler) 'TODO Cancellation Token
|
||||
|
||||
// 'ThreadingHelper.StartAndWaitAllThrottled(test, CType(TextBox7.Text, Integer))
|
||||
|
||||
// Await Task.WhenAll(test)
|
||||
|
||||
// '= getDirsDict(SourcePath, DestPath)
|
||||
// 'Parallel.ForEach(dataToProcess,
|
||||
// ' Sub(p, state)
|
||||
// ' 'setLabel10Text("File: " & p.File.Name)
|
||||
|
||||
// ' Dim b As String = (CType(Label18.Text, Integer) + 1).ToString
|
||||
|
||||
// ' Dim clsCreaImmagine As New ImageCreator(p.File, p.Directory)
|
||||
|
||||
// ' clsCreaImmagine.CreaImmagineThread(p.File.Name)
|
||||
|
||||
// ' ContaImmaginiThread += 1
|
||||
// ' UpdateCounter(ContaImmaginiThread & " " & p.File.Name)
|
||||
// ' 'MyPool.InsertWorkItem(p.File.Name, New XyThreadAdd(AddressOf ClsCreaImmagine.CreaImmagineThread), New Object(0) {p.File.Name}, True)
|
||||
// ' ' TODO: BREAK ON STOP state.stop()
|
||||
|
||||
// ' End Sub)
|
||||
|
||||
// 'Dim pair As KeyValuePair(Of FileInfo, DirectoryInfo)
|
||||
// 'For Each pair In dirSourceDest
|
||||
|
||||
// ' setLabel10Text("File: " & pair.Key.Name)
|
||||
// ' Dim b As String = (CType(Label18.Text, Integer) + 1).ToString
|
||||
|
||||
// ' Dim ClsCreaImmagine As New ImageCreator(pair.Key, pair.Value)
|
||||
// ' ContaImmaginiThread += 1
|
||||
// ' MyPool.InsertWorkItem(pair.Key.Name, New XyThreadAdd(AddressOf ClsCreaImmagine.CreaImmagineThread), New Object(0) {pair.Key.Name}, True)
|
||||
|
||||
// 'Next
|
||||
// End Function
|
||||
}
|
||||
|
||||
public class PicInfo
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ namespace ImageCatalog_2
|
|||
services.AddTransient<ImageCreationStuff>();
|
||||
|
||||
services.AddSingleton<ParametriSetup>();
|
||||
services.AddSingleton<PicSettings>();
|
||||
|
||||
// Register your forms
|
||||
services.AddTransient<MainForm>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue