This commit is contained in:
Maddo 2017-09-22 15:26:44 +02:00
commit a2dca4b750
3 changed files with 36 additions and 13 deletions

View file

@ -24,6 +24,10 @@ namespace CatalogLib
private FileInfo _currentFile;
public void Start(FileInfo workFile)
{
Stopwatch s = new Stopwatch();
s.Start();
_currentFile = workFile;
@ -119,10 +123,11 @@ namespace CatalogLib
//image.DrawText("sssssssssssssssssssssssssssssssssssssssssssssss", font, Color.Black, new Vector2(200, 200));
image.Save(Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
//image.Resize(200, 200).Save("");
MaddoLogger.Log("Saved Image: {0} to: {1}", workFile.FullName, Path.Combine(PicSettings.Instance.DirectoryDestinazione, workFile.Name));
}
s.Stop();
MaddoLogger.Log("Time Taken for {0}: {1}", workFile.FullName, s.Elapsed);
}
private void SetExtraText(Image<Rgba32> image)

View file

@ -187,7 +187,10 @@
</StackPanel>
<Button Content="Start" Command="{Binding StartCommand}" Style="{DynamicResource AccentedSquareButtonStyle}"></Button>
<Button Content="STOP" Command="{Binding StopCommand}" Style="{DynamicResource SquareButtonStyle}"/>
<TextBlock Text="{Binding CurrentImage}"></TextBlock>
<TextBlock Text="{Binding TotalPictures}"></TextBlock>
</StackPanel>
</GroupBox>
</StackPanel>

View file

@ -139,7 +139,10 @@ namespace WPFCatalog
var tasks = new List<Task>();
// todo folder mode
MaddoLogger.Log("Starting elaboration");
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
var files = Directory.EnumerateFiles(PicSettings.DirectorySorgente).ToArray();
TotalPictures = files.Count();
foreach (var file in files)
{
//Task t = new Task(() =>
//{
@ -147,14 +150,9 @@ namespace WPFCatalog
// //CompleteFile(file);
//});
var t = FileTask(file);
if (t != null)
{
tasks.Add(t);
}
else
{
MaddoLogger.LogError("Task was null for file: {0}", file);
}
tasks.Add(t);
//_tasks.Add(new ImageTask() { ImageName = file, TaskImage = t, Completed = false });
//t.Start();
@ -178,8 +176,8 @@ namespace WPFCatalog
MaddoLogger.Log("Starting task for image {0}", file);
IImageProcessor i = new ImgSharpCreator();
await Task.Run(() => i.Start(new FileInfo(file)));
CurrentImage = file;
TotalPictures--;
}
private void CompleteFile(string file)
@ -260,6 +258,23 @@ namespace WPFCatalog
#region Proprietà
private string _currentImage;
public string CurrentImage
{
get => _currentImage;
set { _currentImage = value; RaisePropertyChanged("CurrentImage"); }
}
private int _totalPictures;
public int TotalPictures
{
get => _totalPictures;
set { _totalPictures = value; RaisePropertyChanged("TotalPictures"); }
}
public PicSettings SettingsString
{
get { return PicSettings; }