diff --git a/LeanderShiftPlannerV2/FileIO/ShiftPlanIO.cs b/LeanderShiftPlannerV2/FileIO/ShiftPlanIO.cs index 03b0958..f5cab70 100644 --- a/LeanderShiftPlannerV2/FileIO/ShiftPlanIO.cs +++ b/LeanderShiftPlannerV2/FileIO/ShiftPlanIO.cs @@ -18,7 +18,7 @@ namespace LeanderShiftPlannerV2.FileIO if (!Directory.Exists(Constants.ShiftPlanPath)) Directory.CreateDirectory(Constants.ShiftPlanPath); } - public static SKImage GenerateShiftPlanPng(ShiftPlan shiftPlan) + public static SKImage GenerateShiftPlanPng(ShiftPlan shiftPlan, string font) { Dictionary<(int, int), List> names = GetNamesDict(shiftPlan); @@ -30,7 +30,7 @@ namespace LeanderShiftPlannerV2.FileIO using (SKBitmap bitmap = new SKBitmap(1000, 850)) using (SKCanvas canvas = new SKCanvas(bitmap)) { - SKFont smallTextFont = new SKFont(SKTypeface.FromFile(Constants.FontPath)) { Size = 24 }; + SKFont smallTextFont = new SKFont(SKTypeface.FromFile($"Resources/font/{font}")) { Size = 24 }; SKPaint rectColorGray = new SKPaint { Color = SKColors.LightGray, Style = SKPaintStyle.Stroke, StrokeWidth = 5 }; SKPaint textColorGray = new SKPaint { Color = SKColors.Gray }; @@ -40,7 +40,7 @@ namespace LeanderShiftPlannerV2.FileIO canvas.Clear(SKColors.White); // Draw Topic - using (SKFont topic = new SKFont(SKTypeface.FromFile(Constants.FontPath))) + using (SKFont topic = new SKFont(SKTypeface.FromFile($"Resources/font/{font}"))) { topic.Size = 40; string text1 = "Schichtplan "; @@ -106,12 +106,13 @@ namespace LeanderShiftPlannerV2.FileIO } } - public static void ExportShiftPlan(SKImage image, int id) + public static void ExportShiftPlan(SKImage image, int id, string font) { CheckFileSystem(); using SKData data = image.Encode(SKEncodedImageFormat.Png, 100); - using FileStream dataStream = File.OpenWrite(Constants.ShiftPlanPath + $"ShiftPlan_{id}.png"); + if (!Directory.Exists(Constants.ShiftPlanPath + $"/{font}/")) Directory.CreateDirectory(Constants.ShiftPlanPath + $"/{font}/"); + using FileStream dataStream = File.OpenWrite(Constants.ShiftPlanPath + $"/{font}/" + $"ShiftPlan_{id}.png"); data.SaveTo(dataStream); } diff --git a/LeanderShiftPlannerV2/LeanderShiftPlannerV2.csproj b/LeanderShiftPlannerV2/LeanderShiftPlannerV2.csproj index 426bcc6..788560e 100644 --- a/LeanderShiftPlannerV2/LeanderShiftPlannerV2.csproj +++ b/LeanderShiftPlannerV2/LeanderShiftPlannerV2.csproj @@ -36,6 +36,9 @@ Always + + Always + Always diff --git a/LeanderShiftPlannerV2/Resources/font/Roboto.ttf b/LeanderShiftPlannerV2/Resources/font/Roboto.ttf new file mode 100644 index 0000000..7e3bb2f Binary files /dev/null and b/LeanderShiftPlannerV2/Resources/font/Roboto.ttf differ diff --git a/LeanderShiftPlannerV2/Util/Constants.cs b/LeanderShiftPlannerV2/Util/Constants.cs index e825fb3..0158daa 100644 --- a/LeanderShiftPlannerV2/Util/Constants.cs +++ b/LeanderShiftPlannerV2/Util/Constants.cs @@ -14,7 +14,9 @@ namespace LeanderShiftPlannerV2.Util public const string ShiftPlanPath = ExportPath + @"/ShiftPlans/"; public const string TimesheetPath = ExportPath + "/Timesheets/"; public const string TimesheetResource = @"Resources/templates/timesheet.xlsx"; - public const string FontPath = @"Resources/font/Emblem.ttf"; + public const string FontPath = @"Resources/font/"; + public const string FontEmblem = "Emblem.ttf"; + public const string FontRoboto = "Roboto.ttf"; // TimeSheets public static readonly string TimeSheetSourceRandom = "Random"; diff --git a/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs b/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs index f9348a4..c362b6f 100644 --- a/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs +++ b/LeanderShiftPlannerV2/View/LeanderShiftPlannerView/LeanderShiftPlannerMainWindow.axaml.cs @@ -11,6 +11,7 @@ using Avalonia.Threading; using LeanderShiftPlannerV2.FileIO; using LeanderShiftPlannerV2.Model; using LeanderShiftPlannerV2.Service; +using LeanderShiftPlannerV2.Util; using LeanderShiftPlannerV2.View.ErrorView; using LeanderShiftPlannerV2.View.LeanderControls; @@ -164,8 +165,11 @@ public partial class LeanderShiftPlannerMainWindow : Window private void ButtonSaveShiftPlans_Click(object? sender, RoutedEventArgs e) { foreach (ShiftPlan shiftPlan in _appService.ShiftPlanService.GetShiftPlans()) - ShiftPlanIO.ExportShiftPlan(ShiftPlanIO.GenerateShiftPlanPng(shiftPlan), - _appService.ShiftPlanService.GetNextID()); + { + int currentId = _appService.ShiftPlanService.GetNextID(); + ShiftPlanIO.ExportShiftPlan(ShiftPlanIO.GenerateShiftPlanPng(shiftPlan, Constants.FontEmblem), currentId, Constants.FontEmblem); + ShiftPlanIO.ExportShiftPlan(ShiftPlanIO.GenerateShiftPlanPng(shiftPlan ,Constants.FontRoboto), currentId, Constants.FontRoboto); + } } private void ButtonStartCalculation_Click(object? sender, RoutedEventArgs e) diff --git a/LeanderShiftPlannerV2/View/ShiftPlanView/ShiftPlanViewer.axaml.cs b/LeanderShiftPlannerV2/View/ShiftPlanView/ShiftPlanViewer.axaml.cs index 77222fc..7e76ccc 100644 --- a/LeanderShiftPlannerV2/View/ShiftPlanView/ShiftPlanViewer.axaml.cs +++ b/LeanderShiftPlannerV2/View/ShiftPlanView/ShiftPlanViewer.axaml.cs @@ -3,6 +3,7 @@ using Avalonia.Interactivity; using LeanderShiftPlannerV2.FileIO; using LeanderShiftPlannerV2.Model; using LeanderShiftPlannerV2.Service; +using LeanderShiftPlannerV2.Util; using SkiaSharp; namespace LeanderShiftPlannerV2.View.ShiftPlanView; @@ -19,7 +20,7 @@ public partial class ShiftPlanViewer : Window this._appService = appService; this._model = shiftPlan; - this._image = ShiftPlanIO.GenerateShiftPlanPng(shiftPlan); + this._image = ShiftPlanIO.GenerateShiftPlanPng(shiftPlan, Constants.FontEmblem); InitListView(); InitImageView(); @@ -39,6 +40,8 @@ public partial class ShiftPlanViewer : Window private void ButtonSaveShiftPlan_Click(object sender, RoutedEventArgs e) { - ShiftPlanIO.ExportShiftPlan(_image, _appService.ShiftPlanService.GetNextID()); + int currentId = _appService.ShiftPlanService.GetNextID(); + ShiftPlanIO.ExportShiftPlan(_image, currentId, Constants.FontEmblem); + ShiftPlanIO.ExportShiftPlan(_image, currentId, Constants.FontRoboto); } } \ No newline at end of file