- add Roboto.ttf, just because it was requested
This commit is contained in:
@@ -18,7 +18,7 @@ namespace LeanderShiftPlannerV2.FileIO
|
|||||||
if (!Directory.Exists(Constants.ShiftPlanPath)) Directory.CreateDirectory(Constants.ShiftPlanPath);
|
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<string>> names = GetNamesDict(shiftPlan);
|
Dictionary<(int, int), List<string>> names = GetNamesDict(shiftPlan);
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ namespace LeanderShiftPlannerV2.FileIO
|
|||||||
using (SKBitmap bitmap = new SKBitmap(1000, 850))
|
using (SKBitmap bitmap = new SKBitmap(1000, 850))
|
||||||
using (SKCanvas canvas = new SKCanvas(bitmap))
|
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
|
SKPaint rectColorGray = new SKPaint
|
||||||
{ Color = SKColors.LightGray, Style = SKPaintStyle.Stroke, StrokeWidth = 5 };
|
{ Color = SKColors.LightGray, Style = SKPaintStyle.Stroke, StrokeWidth = 5 };
|
||||||
SKPaint textColorGray = new SKPaint { Color = SKColors.Gray };
|
SKPaint textColorGray = new SKPaint { Color = SKColors.Gray };
|
||||||
@@ -40,7 +40,7 @@ namespace LeanderShiftPlannerV2.FileIO
|
|||||||
canvas.Clear(SKColors.White);
|
canvas.Clear(SKColors.White);
|
||||||
|
|
||||||
// Draw Topic
|
// Draw Topic
|
||||||
using (SKFont topic = new SKFont(SKTypeface.FromFile(Constants.FontPath)))
|
using (SKFont topic = new SKFont(SKTypeface.FromFile($"Resources/font/{font}")))
|
||||||
{
|
{
|
||||||
topic.Size = 40;
|
topic.Size = 40;
|
||||||
string text1 = "Schichtplan ";
|
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();
|
CheckFileSystem();
|
||||||
|
|
||||||
using SKData data = image.Encode(SKEncodedImageFormat.Png, 100);
|
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);
|
data.SaveTo(dataStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
<EmbeddedResource Include="Resources\font\Emblem.ttf">
|
<EmbeddedResource Include="Resources\font\Emblem.ttf">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Resources\font\Roboto.ttf">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Resources\templates\timesheet.xlsx">
|
<EmbeddedResource Include="Resources\templates\timesheet.xlsx">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
BIN
LeanderShiftPlannerV2/Resources/font/Roboto.ttf
Normal file
BIN
LeanderShiftPlannerV2/Resources/font/Roboto.ttf
Normal file
Binary file not shown.
@@ -14,7 +14,9 @@ namespace LeanderShiftPlannerV2.Util
|
|||||||
public const string ShiftPlanPath = ExportPath + @"/ShiftPlans/";
|
public const string ShiftPlanPath = ExportPath + @"/ShiftPlans/";
|
||||||
public const string TimesheetPath = ExportPath + "/Timesheets/";
|
public const string TimesheetPath = ExportPath + "/Timesheets/";
|
||||||
public const string TimesheetResource = @"Resources/templates/timesheet.xlsx";
|
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
|
// TimeSheets
|
||||||
public static readonly string TimeSheetSourceRandom = "Random";
|
public static readonly string TimeSheetSourceRandom = "Random";
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Avalonia.Threading;
|
|||||||
using LeanderShiftPlannerV2.FileIO;
|
using LeanderShiftPlannerV2.FileIO;
|
||||||
using LeanderShiftPlannerV2.Model;
|
using LeanderShiftPlannerV2.Model;
|
||||||
using LeanderShiftPlannerV2.Service;
|
using LeanderShiftPlannerV2.Service;
|
||||||
|
using LeanderShiftPlannerV2.Util;
|
||||||
using LeanderShiftPlannerV2.View.ErrorView;
|
using LeanderShiftPlannerV2.View.ErrorView;
|
||||||
using LeanderShiftPlannerV2.View.LeanderControls;
|
using LeanderShiftPlannerV2.View.LeanderControls;
|
||||||
|
|
||||||
@@ -164,8 +165,11 @@ public partial class LeanderShiftPlannerMainWindow : Window
|
|||||||
private void ButtonSaveShiftPlans_Click(object? sender, RoutedEventArgs e)
|
private void ButtonSaveShiftPlans_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (ShiftPlan shiftPlan in _appService.ShiftPlanService.GetShiftPlans())
|
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)
|
private void ButtonStartCalculation_Click(object? sender, RoutedEventArgs e)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Avalonia.Interactivity;
|
|||||||
using LeanderShiftPlannerV2.FileIO;
|
using LeanderShiftPlannerV2.FileIO;
|
||||||
using LeanderShiftPlannerV2.Model;
|
using LeanderShiftPlannerV2.Model;
|
||||||
using LeanderShiftPlannerV2.Service;
|
using LeanderShiftPlannerV2.Service;
|
||||||
|
using LeanderShiftPlannerV2.Util;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
|
||||||
namespace LeanderShiftPlannerV2.View.ShiftPlanView;
|
namespace LeanderShiftPlannerV2.View.ShiftPlanView;
|
||||||
@@ -19,7 +20,7 @@ public partial class ShiftPlanViewer : Window
|
|||||||
|
|
||||||
this._appService = appService;
|
this._appService = appService;
|
||||||
this._model = shiftPlan;
|
this._model = shiftPlan;
|
||||||
this._image = ShiftPlanIO.GenerateShiftPlanPng(shiftPlan);
|
this._image = ShiftPlanIO.GenerateShiftPlanPng(shiftPlan, Constants.FontEmblem);
|
||||||
|
|
||||||
InitListView();
|
InitListView();
|
||||||
InitImageView();
|
InitImageView();
|
||||||
@@ -39,6 +40,8 @@ public partial class ShiftPlanViewer : Window
|
|||||||
|
|
||||||
private void ButtonSaveShiftPlan_Click(object sender, RoutedEventArgs e)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user