modernized picsettings
This commit is contained in:
parent
4ceb46d65c
commit
63aac7f911
5 changed files with 243 additions and 915 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue