Tasks and resize
This commit is contained in:
parent
0d8ab38efd
commit
27a2affc19
2 changed files with 64 additions and 12 deletions
|
|
@ -9,6 +9,7 @@ using MaddoLibrary.Base.Log;
|
||||||
using SixLabors.Fonts;
|
using SixLabors.Fonts;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Drawing;
|
using SixLabors.ImageSharp.Drawing;
|
||||||
|
using SixLabors.ImageSharp.Processing;
|
||||||
using Font = SixLabors.Fonts.Font;
|
using Font = SixLabors.Fonts.Font;
|
||||||
using FontFamily = SixLabors.Fonts.FontFamily;
|
using FontFamily = SixLabors.Fonts.FontFamily;
|
||||||
using FontStyle = SixLabors.Fonts.FontStyle;
|
using FontStyle = SixLabors.Fonts.FontStyle;
|
||||||
|
|
@ -32,6 +33,9 @@ namespace CatalogLib
|
||||||
MaddoLogger.Log("Loaded Image: {0}", workFile.FullName);
|
MaddoLogger.Log("Loaded Image: {0}", workFile.FullName);
|
||||||
//image.Rotate(-90);
|
//image.Rotate(-90);
|
||||||
|
|
||||||
|
//if (PicSettings.Instance.r)
|
||||||
|
image.Mutate(x => x.Resize(PicSettings.Instance.FotoAltezza, PicSettings.Instance.FotoLarghezza, new BoxResampler()));
|
||||||
|
|
||||||
if (PicSettings.Instance.GeneraleRotazioneAutomatica)
|
if (PicSettings.Instance.GeneraleRotazioneAutomatica)
|
||||||
{
|
{
|
||||||
image.Mutate(img => img.AutoOrient());
|
image.Mutate(img => img.AutoOrient());
|
||||||
|
|
@ -156,7 +160,13 @@ namespace CatalogLib
|
||||||
float scalingFactor = Math.Min(image.Width / size.Width, image.Height / size.Height);
|
float scalingFactor = Math.Min(image.Width / size.Width, image.Height / size.Height);
|
||||||
Font scaledFont = new Font(font, scalingFactor * font.Size);
|
Font scaledFont = new Font(font, scalingFactor * font.Size);
|
||||||
|
|
||||||
image.Mutate(x => x.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center, new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom }));
|
image.Mutate(x =>
|
||||||
|
x.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center,
|
||||||
|
new TextGraphicsOptions(true)
|
||||||
|
{
|
||||||
|
HorizontalAlignment = HorizontalAlignment.Center,
|
||||||
|
VerticalAlignment = VerticalAlignment.Bottom
|
||||||
|
}));
|
||||||
//image.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center, new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom });
|
//image.DrawText(PicSettings.Instance.TestoApplicareOrizzontale, scaledFont, g, center, new TextGraphicsOptions(true) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Bottom });
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using CatalogLib;
|
using CatalogLib;
|
||||||
using GalaSoft.MvvmLight.Command;
|
using GalaSoft.MvvmLight.Command;
|
||||||
|
using MaddoLibrary.Base.Log;
|
||||||
using MaddoLibrary.Helpers;
|
using MaddoLibrary.Helpers;
|
||||||
using WPFCatalog.Messages;
|
using WPFCatalog.Messages;
|
||||||
|
|
||||||
|
|
@ -76,19 +77,60 @@ namespace WPFCatalog
|
||||||
//string s = d.Name;
|
//string s = d.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private struct ImageTask
|
||||||
|
{
|
||||||
|
public Task TaskImage;
|
||||||
|
public string ImageName;
|
||||||
|
public bool Completed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//private List<ImageTask> _tasks;
|
||||||
|
private async void Start()
|
||||||
|
{
|
||||||
|
Task outerTask = new Task(() =>
|
||||||
|
{
|
||||||
|
var tasks = new List<Task>();
|
||||||
|
// todo folder mode
|
||||||
|
MaddoLogger.Log("Starting elaboration");
|
||||||
|
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
|
||||||
|
{
|
||||||
|
//Task t = new Task(() =>
|
||||||
|
//{
|
||||||
|
|
||||||
|
// //CompleteFile(file);
|
||||||
|
//});
|
||||||
|
tasks.Add(FileTask(file));
|
||||||
|
//_tasks.Add(new ImageTask() { ImageName = file, TaskImage = t, Completed = false });
|
||||||
|
//t.Start();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Task.WhenAll(tasks).Start();
|
||||||
|
|
||||||
|
//tt.RunSynchronously();
|
||||||
|
MaddoLogger.Log("Finished");
|
||||||
|
DialogHelper.PopUpAlert("Finished", "message");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
outerTask.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task FileTask(string file)
|
||||||
|
{
|
||||||
|
MaddoLogger.Log("Starting task for image {0}", file);
|
||||||
|
IImageProcessor i = new ImgSharpCreator();
|
||||||
|
|
||||||
|
//ImageCreator2 i = new ImageCreator2();
|
||||||
|
i.Start(new FileInfo(file));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompleteFile(string file)
|
||||||
{
|
{
|
||||||
|
|
||||||
// todo folder mode
|
|
||||||
|
|
||||||
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
|
|
||||||
{
|
|
||||||
IImageProcessor i = new ImgSharpCreator();
|
|
||||||
|
|
||||||
//ImageCreator2 i = new ImageCreator2();
|
|
||||||
i.Start(new FileInfo(file));
|
|
||||||
}
|
|
||||||
DialogHelper.PopUpAlert("Finished", "message");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenSourceFolder()
|
private void OpenSourceFolder()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue