Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3e14731429 | |||
| df6c187a00 | |||
| 98b5198f6f | |||
| 1a6459d60b | |||
| 43e6c35beb |
@@ -10,6 +10,7 @@ public class Settings
|
|||||||
public static Settings _instance = new();
|
public static Settings _instance = new();
|
||||||
public AddressSets addressSets = new();
|
public AddressSets addressSets = new();
|
||||||
public Customers customers = new();
|
public Customers customers = new();
|
||||||
|
public PdfExportSettings pdfExport { get; set; } = new();
|
||||||
|
|
||||||
public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"logofclient", "config.json");
|
"logofclient", "config.json");
|
||||||
@@ -52,6 +53,25 @@ public class Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PdfExportSettings
|
||||||
|
{
|
||||||
|
public double cellPaddingTopMm { get; set; } = 5;
|
||||||
|
public double cellPaddingBottomMm { get; set; } = 5;
|
||||||
|
public double cellPaddingLeftMm { get; set; } = 5;
|
||||||
|
public double cellPaddingRightMm { get; set; } = 5;
|
||||||
|
|
||||||
|
public double pageMarginTopMm { get; set; } = 0;
|
||||||
|
public double pageMarginBottomMm { get; set; } = 0;
|
||||||
|
public double pageMarginLeftMm { get; set; } = 0;
|
||||||
|
public double pageMarginRightMm { get; set; } = 0;
|
||||||
|
|
||||||
|
public int rowsPerPage { get; set; } = 7;
|
||||||
|
public int columnsPerPage { get; set; } = 3;
|
||||||
|
|
||||||
|
public double fontSize { get; set; } = 9;
|
||||||
|
public double smallFontSize { get; set; } = 6;
|
||||||
|
}
|
||||||
|
|
||||||
public class Global
|
public class Global
|
||||||
{
|
{
|
||||||
public static Global _instance;
|
public static Global _instance;
|
||||||
|
|||||||
+90
-33
@@ -28,7 +28,7 @@
|
|||||||
<Label FontSize="20" Content="Addressverwaltung" VerticalContentAlignment="Center" />
|
<Label FontSize="20" Content="Addressverwaltung" VerticalContentAlignment="Center" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid RowDefinitions="2*,*,*">
|
<Grid RowDefinitions="3*,80,2*">
|
||||||
<Grid ColumnDefinitions="*,*" Grid.Row="0">
|
<Grid ColumnDefinitions="*,*" Grid.Row="0">
|
||||||
<!-- Kunden -->
|
<!-- Kunden -->
|
||||||
<Grid Margin="30,30,10,30">
|
<Grid Margin="30,30,10,30">
|
||||||
@@ -78,6 +78,14 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</MenuItem.Header>
|
</MenuItem.Header>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetRename_OnClick" IsEnabled="False">
|
||||||
|
<MenuItem.Header>
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<LucideIcon Kind="Trash" Width="12" Height="12" Size="12" />
|
||||||
|
<Label Content="Löschen" VerticalContentAlignment="Center" />
|
||||||
|
</StackPanel>
|
||||||
|
</MenuItem.Header>
|
||||||
|
</MenuItem>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</ListBox.ContextMenu>
|
</ListBox.ContextMenu>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
@@ -91,23 +99,10 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<!-- <Grid Grid.Row="0"> -->
|
<!-- <Grid ColumnDefinitions="*,*,*" Grid.Row="1"> -->
|
||||||
<!-- <StackPanel Orientation="Horizontal" VerticalAlignment="Center" -->
|
<StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="10" HorizontalAlignment="Center"
|
||||||
<!-- HorizontalAlignment="Center"> -->
|
|
||||||
<!-- <TextBox x:Name="TbFilename" Watermark="Dateipfad" Width="400" -->
|
|
||||||
<!-- VerticalContentAlignment="Center" /> -->
|
|
||||||
<!-- <Button x:Name="BtnChooseFile" Margin="10,0,0,0" Click="BtnChooseFile_OnClick"> -->
|
|
||||||
<!-- <StackPanel Orientation="Horizontal"> -->
|
|
||||||
<!-- <LucideIcon Kind="FolderOpen" Width="16" Height="16" Size="16" /> -->
|
|
||||||
<!-- <Label Content="Öffnen" VerticalContentAlignment="Center" /> -->
|
|
||||||
<!-- </StackPanel> -->
|
|
||||||
<!-- </Button> -->
|
|
||||||
<!-- </StackPanel> -->
|
|
||||||
<!-- </Grid> -->
|
|
||||||
<Grid Grid.ColumnDefinitions="*,*" Grid.Row="1">
|
|
||||||
<StackPanel Grid.Column="0" Width="250" Orientation="Vertical" HorizontalAlignment="Right"
|
|
||||||
Margin="0,0,5,0">
|
Margin="0,0,5,0">
|
||||||
<Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
|
<Button Width="250" HorizontalContentAlignment="Center"
|
||||||
Margin="0,0,0,10" IsEnabled="False"
|
Margin="0,0,0,10" IsEnabled="False"
|
||||||
x:Name="BtnCheck" Click="BtnCheck_OnClick">
|
x:Name="BtnCheck" Click="BtnCheck_OnClick">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -116,7 +111,7 @@
|
|||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" IsEnabled="False"
|
<Button Width="250" IsEnabled="False"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Click="BtnCombine_OnClick" x:Name="BtnCombine"
|
Click="BtnCombine_OnClick" x:Name="BtnCombine"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
@@ -126,19 +121,7 @@
|
|||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" IsEnabled="False"
|
<Button Width="250" IsEnabled="False"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnRepair"
|
|
||||||
Margin="0,0,0,10">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<LucideIcon Kind="Hammer" Width="36" Height="36" />
|
|
||||||
<Label Content="Reparieren" VerticalContentAlignment="Center" FontSize="15"
|
|
||||||
FontWeight="Bold" />
|
|
||||||
</StackPanel>
|
|
||||||
</Button>
|
|
||||||
</StackPanel>
|
|
||||||
<StackPanel Grid.Column="1" Width="250" Orientation="Vertical" HorizontalAlignment="Left"
|
|
||||||
Margin="5,0,0,0">
|
|
||||||
<Button HorizontalAlignment="Stretch" IsEnabled="False"
|
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnShorten"
|
HorizontalContentAlignment="Center" x:Name="BtnShorten"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@@ -147,7 +130,7 @@
|
|||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" IsEnabled="False"
|
<Button Width="250" IsEnabled="False"
|
||||||
Click="BtnGenerateLabels_OnClick"
|
Click="BtnGenerateLabels_OnClick"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnGenerateLabels"
|
HorizontalContentAlignment="Center" x:Name="BtnGenerateLabels"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
@@ -158,8 +141,17 @@
|
|||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Width="250" IsEnabled="False"
|
||||||
|
HorizontalContentAlignment="Center" x:Name="BtnRepair"
|
||||||
|
Margin="0,0,0,10">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<LucideIcon Kind="Hammer" Width="36" Height="36" />
|
||||||
|
<Label Content="Reparieren" VerticalContentAlignment="Center" FontSize="15"
|
||||||
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<!-- </Grid> -->
|
||||||
<Grid Grid.Row="2" Margin="20" IsVisible="True" x:Name="GrdCalcMan">
|
<Grid Grid.Row="2" Margin="20" IsVisible="True" x:Name="GrdCalcMan">
|
||||||
<Image Source="assets/calc_man.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
<Image Source="assets/calc_man.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
</Grid>
|
</Grid>
|
||||||
@@ -234,6 +226,71 @@
|
|||||||
<CheckBox HorizontalAlignment="Center" x:Name="CbMergeExportUnmerged" IsChecked="False">Speichere Unverarbeitete in neuem Verteiler</CheckBox>
|
<CheckBox HorizontalAlignment="Center" x:Name="CbMergeExportUnmerged" IsChecked="False">Speichere Unverarbeitete in neuem Verteiler</CheckBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Grid Grid.Row="2" Margin="20" ColumnDefinitions="*,5*,*" IsVisible="False" x:Name="GrdExportMarginOptions">
|
||||||
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="20">
|
||||||
|
<Grid ColumnDefinitions="*,*,*" ColumnSpacing="20">
|
||||||
|
<StackPanel Orientation="Vertical" Spacing="10">
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Zellenrand oben (mm)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingTop" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Zellenrand unten (mm)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingBot" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Zellenrand links (mm)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingLeft" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Zellenrand rechts (mm)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargCellPaddingRight" Minimum="0" Maximum="20" Value="5"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="10">
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Content="Zellenabstand oben"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="TbExpMargMarginTop" Minimum="0" Maximum="20" Value="0"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Content="Zellenabstand unten"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="TbExpMargMarginBottom" Minimum="0" Maximum="20" Value="0"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Content="Zellenabstand rechts"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="TbExpMargMarginRight" Minimum="0" Maximum="20" Value="0"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Content="Zellenabstand links"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="TbExpMargMarginLeft" Minimum="0" Maximum="20" Value="0"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<StackPanel Grid.Column="2" Orientation="Vertical" Spacing="10">
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Content="Zeilen pro Seite"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="TbExpMargRowsPerPage" Minimum="1" Maximum="10" Value="7"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Spalten pro Seite"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargColumnsPerPage" Minimum="1" Maximum="8" Value="3"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Schriftgröße (groß)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargFontSize" Minimum="5" Maximum="30" Value="9"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
<Grid ColumnDefinitions="*,*">
|
||||||
|
<Label Grid.Column="0" Content="Schriftgröße (klein)"></Label>
|
||||||
|
<NumericUpDown Grid.Column="1" x:Name="NudExpMargSmallFontSize" Minimum="3" Maximum="30" Value="6"></NumericUpDown>
|
||||||
|
</Grid>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
|
<Button Content="Start" Click="BtnStartGenerateLabels_OnClick"></Button>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem IsEnabled="False">
|
<TabItem IsEnabled="False">
|
||||||
|
|||||||
+97
-1
@@ -5,6 +5,7 @@ using System.IO;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
using Logof_Client.Wiki;
|
using Logof_Client.Wiki;
|
||||||
|
|
||||||
@@ -33,6 +34,8 @@ public partial class MainWindow : Window
|
|||||||
WindowState = WindowState.Maximized;
|
WindowState = WindowState.Maximized;
|
||||||
Global.Load();
|
Global.Load();
|
||||||
Settings.Load();
|
Settings.Load();
|
||||||
|
LoadPdfExportOptions();
|
||||||
|
HookPdfExportOptionEvents();
|
||||||
|
|
||||||
RefreshCountryView();
|
RefreshCountryView();
|
||||||
|
|
||||||
@@ -183,12 +186,14 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
GrdCalcMan.IsVisible = false;
|
GrdCalcMan.IsVisible = false;
|
||||||
GrdCombineTypes.IsVisible = true;
|
GrdCombineTypes.IsVisible = true;
|
||||||
|
GrdExportMarginOptions.IsVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MakeCalcManVisible()
|
private void MakeCalcManVisible()
|
||||||
{
|
{
|
||||||
GrdCalcMan.IsVisible = true;
|
GrdCalcMan.IsVisible = true;
|
||||||
GrdCombineTypes.IsVisible = false;
|
GrdCombineTypes.IsVisible = false;
|
||||||
|
GrdExportMarginOptions.IsVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void StartCombine(Uri path)
|
private async void StartCombine(Uri path)
|
||||||
@@ -730,6 +735,16 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
private async void BtnGenerateLabels_OnClick(object? sender, RoutedEventArgs e)
|
private async void BtnGenerateLabels_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
GrdCalcMan.IsVisible = false;
|
||||||
|
GrdCombineTypes.IsVisible = false;
|
||||||
|
GrdExportMarginOptions.IsVisible = true;
|
||||||
|
LoadPdfExportOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void BtnStartGenerateLabels_OnClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SavePdfExportOptions();
|
||||||
|
|
||||||
var saveDialog = new SaveFileDialog
|
var saveDialog = new SaveFileDialog
|
||||||
{
|
{
|
||||||
DefaultExtension = "pdf",
|
DefaultExtension = "pdf",
|
||||||
@@ -739,7 +754,7 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(filePath))
|
if (!string.IsNullOrEmpty(filePath))
|
||||||
{
|
{
|
||||||
var builder = new PdfBuilder();
|
var builder = new PdfBuilder(Settings._instance.pdfExport);
|
||||||
|
|
||||||
builder.CreateAddressLabelPdfFromAddressSetWithPlaceholder(
|
builder.CreateAddressLabelPdfFromAddressSetWithPlaceholder(
|
||||||
Convert.ToInt32(LstCustomerAdressSets.SelectedItems[0].ToString().Split(" - ")[0]),
|
Convert.ToInt32(LstCustomerAdressSets.SelectedItems[0].ToString().Split(" - ")[0]),
|
||||||
@@ -750,6 +765,87 @@ public partial class MainWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HookPdfExportOptionEvents()
|
||||||
|
{
|
||||||
|
var controls = GetPdfExportControls();
|
||||||
|
foreach (var control in controls) control.ValueChanged += PdfExportOption_OnValueChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadPdfExportOptions()
|
||||||
|
{
|
||||||
|
var options = Settings._instance.pdfExport ?? new PdfExportSettings();
|
||||||
|
|
||||||
|
NudExpMargCellPaddingTop.Value = (decimal)options.cellPaddingTopMm;
|
||||||
|
NudExpMargCellPaddingBot.Value = (decimal)options.cellPaddingBottomMm;
|
||||||
|
NudExpMargCellPaddingLeft.Value = (decimal)options.cellPaddingLeftMm;
|
||||||
|
NudExpMargCellPaddingRight.Value = (decimal)options.cellPaddingRightMm;
|
||||||
|
|
||||||
|
TbExpMargMarginTop.Value = (decimal)options.pageMarginTopMm;
|
||||||
|
TbExpMargMarginBottom.Value = (decimal)options.pageMarginBottomMm;
|
||||||
|
TbExpMargMarginLeft.Value = (decimal)options.pageMarginLeftMm;
|
||||||
|
TbExpMargMarginRight.Value = (decimal)options.pageMarginRightMm;
|
||||||
|
|
||||||
|
TbExpMargRowsPerPage.Value = options.rowsPerPage;
|
||||||
|
NudExpMargColumnsPerPage.Value = options.columnsPerPage;
|
||||||
|
NudExpMargFontSize.Value = (decimal)options.fontSize;
|
||||||
|
NudExpMargSmallFontSize.Value = (decimal)options.smallFontSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SavePdfExportOptions()
|
||||||
|
{
|
||||||
|
Settings._instance.pdfExport = new PdfExportSettings
|
||||||
|
{
|
||||||
|
cellPaddingTopMm = ReadDouble(NudExpMargCellPaddingTop),
|
||||||
|
cellPaddingBottomMm = ReadDouble(NudExpMargCellPaddingBot),
|
||||||
|
cellPaddingLeftMm = ReadDouble(NudExpMargCellPaddingLeft),
|
||||||
|
cellPaddingRightMm = ReadDouble(NudExpMargCellPaddingRight),
|
||||||
|
pageMarginTopMm = ReadDouble(TbExpMargMarginTop),
|
||||||
|
pageMarginBottomMm = ReadDouble(TbExpMargMarginBottom),
|
||||||
|
pageMarginLeftMm = ReadDouble(TbExpMargMarginLeft),
|
||||||
|
pageMarginRightMm = ReadDouble(TbExpMargMarginRight),
|
||||||
|
rowsPerPage = ReadInt(TbExpMargRowsPerPage, 7),
|
||||||
|
columnsPerPage = ReadInt(NudExpMargColumnsPerPage, 3),
|
||||||
|
fontSize = ReadDouble(NudExpMargFontSize),
|
||||||
|
smallFontSize = ReadDouble(NudExpMargSmallFontSize)
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PdfExportOption_OnValueChanged(object? sender, NumericUpDownValueChangedEventArgs e)
|
||||||
|
{
|
||||||
|
SavePdfExportOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double ReadDouble(NumericUpDown control)
|
||||||
|
{
|
||||||
|
return (double)(control.Value ?? 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int ReadInt(NumericUpDown control, int fallback)
|
||||||
|
{
|
||||||
|
return (int)Math.Round(control.Value ?? fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
private NumericUpDown[] GetPdfExportControls()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
[
|
||||||
|
NudExpMargCellPaddingTop,
|
||||||
|
NudExpMargCellPaddingBot,
|
||||||
|
NudExpMargCellPaddingLeft,
|
||||||
|
NudExpMargCellPaddingRight,
|
||||||
|
TbExpMargMarginTop,
|
||||||
|
TbExpMargMarginBottom,
|
||||||
|
TbExpMargMarginLeft,
|
||||||
|
TbExpMargMarginRight,
|
||||||
|
TbExpMargRowsPerPage,
|
||||||
|
NudExpMargColumnsPerPage,
|
||||||
|
NudExpMargFontSize,
|
||||||
|
NudExpMargSmallFontSize
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private void TbSettingsCustomerSenderAddress_OnTextChanged(object? sender, TextChangedEventArgs e)
|
private void TbSettingsCustomerSenderAddress_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
|
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
|
||||||
|
|||||||
+35
-49
@@ -11,35 +11,15 @@ namespace Logof_Client;
|
|||||||
|
|
||||||
public class PdfBuilder
|
public class PdfBuilder
|
||||||
{
|
{
|
||||||
// Table layout
|
private readonly PdfExportSettings _settings;
|
||||||
private const int CellsPerRow = 3;
|
|
||||||
private const int CellsPerPage = 21; // 3 columns × 7 rows
|
|
||||||
private readonly XFont _boldFont;
|
private readonly XFont _boldFont;
|
||||||
private readonly double _cellHeight = 42.43; // mm
|
|
||||||
private readonly double _cellPaddingBottom = 5; // mm
|
|
||||||
|
|
||||||
// Padding inside cells
|
|
||||||
private readonly double _cellPaddingLeft = 5; // mm
|
|
||||||
private readonly double _cellPaddingTop = 5; // mm
|
|
||||||
|
|
||||||
// Cell dimensions (in mm)
|
|
||||||
private readonly double _cellWidth = 70; // mm
|
|
||||||
|
|
||||||
// Font settings
|
|
||||||
private readonly double _fontSize = 9;
|
|
||||||
|
|
||||||
private readonly double _marginBottom = 1; // mm
|
|
||||||
|
|
||||||
// Paper and layout settings
|
|
||||||
private readonly double _marginLeft = 0; // mm
|
|
||||||
private readonly double _marginRight = 0; // mm
|
|
||||||
private readonly double _marginTop = 0; // mm
|
|
||||||
private readonly XFont _regularFont;
|
private readonly XFont _regularFont;
|
||||||
private readonly XFont _smallFont;
|
private readonly XFont _smallFont;
|
||||||
|
|
||||||
public PdfBuilder()
|
public PdfBuilder(PdfExportSettings? settings = null)
|
||||||
{
|
{
|
||||||
EnsureFontResolverRegistered();
|
EnsureFontResolverRegistered();
|
||||||
|
_settings = settings ?? new PdfExportSettings();
|
||||||
|
|
||||||
// Select first font from build output fonts folder (AppContext.BaseDirectory/fonts)
|
// Select first font from build output fonts folder (AppContext.BaseDirectory/fonts)
|
||||||
var chosenFamily = "Arial";
|
var chosenFamily = "Arial";
|
||||||
@@ -57,9 +37,9 @@ public class PdfBuilder
|
|||||||
chosenFamily = "Arial";
|
chosenFamily = "Arial";
|
||||||
}
|
}
|
||||||
|
|
||||||
_boldFont = new XFont(chosenFamily, 9, XFontStyleEx.Bold);
|
_boldFont = new XFont(chosenFamily, _settings.fontSize, XFontStyleEx.Bold);
|
||||||
_regularFont = new XFont(chosenFamily, 9, XFontStyleEx.Regular);
|
_regularFont = new XFont(chosenFamily, _settings.fontSize, XFontStyleEx.Regular);
|
||||||
_smallFont = new XFont(chosenFamily, 6, XFontStyleEx.Regular);
|
_smallFont = new XFont(chosenFamily, _settings.smallFontSize, XFontStyleEx.Regular);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EnsureFontResolverRegistered()
|
private static void EnsureFontResolverRegistered()
|
||||||
@@ -159,20 +139,17 @@ public class PdfBuilder
|
|||||||
|
|
||||||
private void DrawPage(XGraphics gfx, List<string> addresses, ref int addressIndex)
|
private void DrawPage(XGraphics gfx, List<string> addresses, ref int addressIndex)
|
||||||
{
|
{
|
||||||
var cellCount = 0;
|
for (var row = 0; row < _settings.rowsPerPage; row++)
|
||||||
|
|
||||||
for (var row = 0; row < 7; row++)
|
|
||||||
{
|
{
|
||||||
for (var col = 0; col < 3; col++)
|
for (var col = 0; col < _settings.columnsPerPage; col++)
|
||||||
{
|
{
|
||||||
if (addressIndex >= addresses.Count) break;
|
if (addressIndex >= addresses.Count) break;
|
||||||
|
|
||||||
var x = MmToPoints(_marginLeft + col * _cellWidth);
|
var x = MmToPoints(_settings.pageMarginLeftMm + col * GetCellWidthMm());
|
||||||
var y = MmToPoints(_marginTop + row * _cellHeight);
|
var y = MmToPoints(_settings.pageMarginTopMm + row * GetCellHeightMm());
|
||||||
|
|
||||||
DrawCell(gfx, x, y, addresses[addressIndex]);
|
DrawCell(gfx, x, y, addresses[addressIndex]);
|
||||||
addressIndex++;
|
addressIndex++;
|
||||||
cellCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addressIndex >= addresses.Count) break;
|
if (addressIndex >= addresses.Count) break;
|
||||||
@@ -182,13 +159,11 @@ public class PdfBuilder
|
|||||||
private void DrawPageWithPlaceholder(XGraphics gfx, List<string> addresses, ref int addressIndex,
|
private void DrawPageWithPlaceholder(XGraphics gfx, List<string> addresses, ref int addressIndex,
|
||||||
ref bool isFirstCell, string placeholderText)
|
ref bool isFirstCell, string placeholderText)
|
||||||
{
|
{
|
||||||
var cellCount = 0;
|
for (var row = 0; row < _settings.rowsPerPage; row++)
|
||||||
|
for (var col = 0; col < _settings.columnsPerPage; col++)
|
||||||
for (var row = 0; row < 7; row++)
|
|
||||||
for (var col = 0; col < 3; col++)
|
|
||||||
{
|
{
|
||||||
var x = MmToPoints(_marginLeft + col * _cellWidth);
|
var x = MmToPoints(_settings.pageMarginLeftMm + col * GetCellWidthMm());
|
||||||
var y = MmToPoints(_marginTop + row * _cellHeight);
|
var y = MmToPoints(_settings.pageMarginTopMm + row * GetCellHeightMm());
|
||||||
|
|
||||||
// First cell: placeholder
|
// First cell: placeholder
|
||||||
if (isFirstCell)
|
if (isFirstCell)
|
||||||
@@ -205,15 +180,13 @@ public class PdfBuilder
|
|||||||
{
|
{
|
||||||
DrawEmptyCell(gfx, x, y);
|
DrawEmptyCell(gfx, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
cellCount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawCell(XGraphics gfx, double x, double y, string? address)
|
private void DrawCell(XGraphics gfx, double x, double y, string? address)
|
||||||
{
|
{
|
||||||
var cellWidthPoints = MmToPoints(_cellWidth);
|
var cellWidthPoints = MmToPoints(GetCellWidthMm());
|
||||||
var cellHeightPoints = MmToPoints(_cellHeight);
|
var cellHeightPoints = MmToPoints(GetCellHeightMm());
|
||||||
|
|
||||||
// Draw cell border
|
// Draw cell border
|
||||||
var rect = new XRect(x, y, cellWidthPoints, cellHeightPoints);
|
var rect = new XRect(x, y, cellWidthPoints, cellHeightPoints);
|
||||||
@@ -225,8 +198,8 @@ public class PdfBuilder
|
|||||||
|
|
||||||
private void DrawEmptyCell(XGraphics gfx, double x, double y)
|
private void DrawEmptyCell(XGraphics gfx, double x, double y)
|
||||||
{
|
{
|
||||||
var cellWidthPoints = MmToPoints(_cellWidth);
|
var cellWidthPoints = MmToPoints(GetCellWidthMm());
|
||||||
var cellHeightPoints = MmToPoints(_cellHeight);
|
var cellHeightPoints = MmToPoints(GetCellHeightMm());
|
||||||
|
|
||||||
var rect = new XRect(x, y, cellWidthPoints, cellHeightPoints);
|
var rect = new XRect(x, y, cellWidthPoints, cellHeightPoints);
|
||||||
gfx.DrawRectangle(XPens.Black, rect);
|
gfx.DrawRectangle(XPens.Black, rect);
|
||||||
@@ -234,11 +207,12 @@ public class PdfBuilder
|
|||||||
|
|
||||||
private void DrawMarkdownText(XGraphics gfx, string text, double x, double y, double cellWidth, double cellHeight)
|
private void DrawMarkdownText(XGraphics gfx, string text, double x, double y, double cellWidth, double cellHeight)
|
||||||
{
|
{
|
||||||
var paddingLeftPoints = MmToPoints(_cellPaddingLeft);
|
var paddingLeftPoints = MmToPoints(_settings.cellPaddingLeftMm);
|
||||||
var paddingTopPoints = MmToPoints(_cellPaddingTop);
|
var paddingRightPoints = MmToPoints(_settings.cellPaddingRightMm);
|
||||||
var paddingBottomPoints = MmToPoints(_cellPaddingBottom);
|
var paddingTopPoints = MmToPoints(_settings.cellPaddingTopMm);
|
||||||
|
var paddingBottomPoints = MmToPoints(_settings.cellPaddingBottomMm);
|
||||||
|
|
||||||
var maxWidth = cellWidth - paddingLeftPoints * 2;
|
var maxWidth = Math.Max(0, cellWidth - paddingLeftPoints - paddingRightPoints);
|
||||||
|
|
||||||
// Split text by newlines and remove empty trailing lines
|
// Split text by newlines and remove empty trailing lines
|
||||||
var rawLines = text.Split(new[] { "\n" }, StringSplitOptions.None);
|
var rawLines = text.Split(new[] { "\n" }, StringSplitOptions.None);
|
||||||
@@ -382,6 +356,18 @@ public class PdfBuilder
|
|||||||
return mm * 2.834645669;
|
return mm * 2.834645669;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double GetCellWidthMm()
|
||||||
|
{
|
||||||
|
var availableWidthMm = 210d - _settings.pageMarginLeftMm - _settings.pageMarginRightMm;
|
||||||
|
return availableWidthMm / _settings.columnsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double GetCellHeightMm()
|
||||||
|
{
|
||||||
|
var availableHeightMm = 297d - _settings.pageMarginTopMm - _settings.pageMarginBottomMm;
|
||||||
|
return availableHeightMm / _settings.rowsPerPage;
|
||||||
|
}
|
||||||
|
|
||||||
// Configuration methods to allow customization
|
// Configuration methods to allow customization
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user