From 0e4da1b15009c66a53d5f2727262435227172d26 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 11 May 2026 10:24:15 +0200 Subject: [PATCH 01/13] [fix:] calling combinging methods used initial string-id we removed years ago :eyes: --- MainWindow.axaml.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index cb6c1f4..f4be4fb 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -703,7 +703,7 @@ public partial class MainWindow : Window list.Add((KasAddressList)item); try { - StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem), "difference", GetCombiningTyp()); + StartCombine(list, Convert.ToInt32((LstCustomers.SelectedItem as Customer).ID), "difference", GetCombiningTyp()); } catch { @@ -734,11 +734,11 @@ public partial class MainWindow : Window list.Add((KasAddressList)item); try { - StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "intersection", GetCombiningTyp()); + StartCombine(list, Convert.ToInt32((LstCustomers.SelectedItem as Customer).ID), "intersection", GetCombiningTyp()); } - catch + catch (Exception ex) { - + Console.WriteLine("Error while trying to start intersection: " + ex.Message); } } @@ -761,7 +761,7 @@ public partial class MainWindow : Window foreach (var item in LstCustomerAdressSets.SelectedItems) list.Add((KasAddressList)item); - StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "symdiff", GetCombiningTyp()); + StartCombine(list, Convert.ToInt32((LstCustomers.SelectedItem as Customer).ID), "symdiff", GetCombiningTyp()); } private async void BtnGenerateLabels_OnClick(object? sender, RoutedEventArgs e) From ddea77bf3f5d78e50a2f661709b57dbdbdba0f4b Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 11 May 2026 11:13:14 +0200 Subject: [PATCH 02/13] [feat:] running sheets frontend --- MainWindow.axaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MainWindow.axaml b/MainWindow.axaml index ec71c2c..406823d 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -254,6 +254,7 @@ + @@ -273,6 +274,10 @@ + + + + From 58fed451a19d27f99b8c1b17530c1dc3b4b82fce Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 11 May 2026 17:41:57 +0200 Subject: [PATCH 03/13] [chore:] more running sheet frontend --- MainWindow.axaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MainWindow.axaml b/MainWindow.axaml index 406823d..7d679e0 100644 --- a/MainWindow.axaml +++ b/MainWindow.axaml @@ -297,6 +297,10 @@ + + + + From bd565960ba80c799fbb8af9886bb914fa5804fe2 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 11 May 2026 17:42:14 +0200 Subject: [PATCH 04/13] [chore:] running sheet creation call --- Tasks/PdfBuilder.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index d33a587..880a46a 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -105,6 +105,11 @@ public class PdfBuilder } CreateAddressLabelPdfWithPlaceholder(addresses, placeholderText, outputPath); + + if (_settings.exportRunningSheets) + { + ExportRunningSheets(addressSetId, outputPath); + } } /// @@ -387,4 +392,20 @@ public class PdfBuilder if (left < 0 || top < 0 || right < 0 || bottom < 0) throw new ArgumentException("Margins cannot be negative"); } + + public void ExportRunningSheets(int setID, string path) + { + if (path.EndsWith(".pdf")) + { + path = path.Substring(0, path.Length - 4); + path = path + "-Laufzettel.pdf"; + } + else + { + path = path + "-Laufzettel.pdf"; + } + + + + } } From a72722745b8a6f981de38dc635e0d9d1b52999a0 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Mon, 11 May 2026 17:44:38 +0200 Subject: [PATCH 05/13] [chore:] running sheet parameters in settings --- DataStore/Settings.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DataStore/Settings.cs b/DataStore/Settings.cs index fedaa23..120a0ee 100644 --- a/DataStore/Settings.cs +++ b/DataStore/Settings.cs @@ -70,6 +70,9 @@ public class PdfExportSettings public double fontSize { get; set; } = 9; public double smallFontSize { get; set; } = 6; + public bool exportRunningSheets { get; set; } = true; + public double rsNumGrouped { get; set; } = 25; + public double rsPlzStartpoint { get; set; } = 2; } public class Global From 6c1d0e7a701cb6308af17c9c9617ffde36448013 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 13 May 2026 14:26:30 +0200 Subject: [PATCH 06/13] [chore:] initial rs pdf page builder --- Tasks/PdfBuilder.cs | 49 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index 880a46a..0271e77 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -104,6 +104,11 @@ public class PdfBuilder addresses.Add(addr); } + if (addresses.Count == 0) + { + MessageBox.Show(MainWindow._instance, "Keine validen Adressen konnten generiert werden. Abbruch.", "Fehler"); + return; + } CreateAddressLabelPdfWithPlaceholder(addresses, placeholderText, outputPath); if (_settings.exportRunningSheets) @@ -404,8 +409,48 @@ public class PdfBuilder { path = path + "-Laufzettel.pdf"; } + + CreateRunningSheets(setID, path); + + } + + public void CreateRunningSheets(int setID, string path) + { + KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID); + var document = new PdfDocument(); + document.Info.Title = $"Laufzettel für {list.Name}"; + document.Info.Subject = "powered by logofclient"; + document.Info.Author = "logofclient"; + + int margin = 50; + + List<(int, int)> grouped_nums = GroupAddresses(setID); + + var page = document.AddPage(); + page.Size = PageSize.A4; + + var gfx = XGraphics.FromPdfPage(page); + + var width = page.Width.Point-margin; + var height = page.Height.Point-margin; + gfx.DrawLine(XPens.Black, margin, margin, margin, height); + gfx.DrawLine(XPens.Black, margin, margin, width, margin); + gfx.DrawLine(XPens.Black, width, margin, margin, height); + gfx.DrawLine(XPens.Black, margin, height, width, margin); + + var font = new XFont("Times New Roman", 20, XFontStyleEx.BoldItalic); + + gfx.DrawString($"Versand {list.Name}", font, XBrushes.Black, + new XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center); + - - + document.Save(path); + } + + public List<(int, int)> GroupAddresses(int setID) + { + + + return null; } } From 57b4ac5001465954f740a2027bd3795504d0b87a Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 27 May 2026 09:06:04 +0200 Subject: [PATCH 07/13] [chore:] initial page setup (running sheets) --- Tasks/PdfBuilder.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index 0271e77..8d467e8 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -435,14 +435,21 @@ public class PdfBuilder var height = page.Height.Point-margin; gfx.DrawLine(XPens.Black, margin, margin, margin, height); gfx.DrawLine(XPens.Black, margin, margin, width, margin); - gfx.DrawLine(XPens.Black, width, margin, margin, height); - gfx.DrawLine(XPens.Black, margin, height, width, margin); + gfx.DrawLine(XPens.Black, width, margin, width, height); + gfx.DrawLine(XPens.Black, margin, height, width, height); - var font = new XFont("Times New Roman", 20, XFontStyleEx.BoldItalic); - - gfx.DrawString($"Versand {list.Name}", font, XBrushes.Black, - new XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center); + var boldfont = new XFont("Cantarell", 11, XFontStyleEx.Bold); + var font = new XFont("Cantarell", 11, XFontStyleEx.Regular); + var bigboldfont = new XFont("Cantarell", 35, XFontStyleEx.Bold); + int number = 0; + gfx.DrawString($"Versand {list.Name}", boldfont, XBrushes.Black, + new XRect(margin+5, margin, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"powered by logofclient", font, XBrushes.Black, + new XRect(margin+5, margin+25, width-margin, 25), XStringFormats.CenterLeft); + + gfx.DrawString($"{number}", bigboldfont, XBrushes.Black, + new XRect(margin, margin, width-margin, (height-margin)/2), XStringFormats.Center); document.Save(path); } From 8b740304f6c702f061ecbdc39c95609b11adff7d Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 3 Jun 2026 16:03:29 +0200 Subject: [PATCH 08/13] [fix:] running-sheet configurations are ints --- DataStore/Settings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DataStore/Settings.cs b/DataStore/Settings.cs index 120a0ee..67be3fe 100644 --- a/DataStore/Settings.cs +++ b/DataStore/Settings.cs @@ -71,8 +71,8 @@ public class PdfExportSettings public double fontSize { get; set; } = 9; public double smallFontSize { get; set; } = 6; public bool exportRunningSheets { get; set; } = true; - public double rsNumGrouped { get; set; } = 25; - public double rsPlzStartpoint { get; set; } = 2; + public int rsNumGrouped { get; set; } = 25; + public int rsPlzStartpoint { get; set; } = 2; } public class Global From b22d33dc9762ebd5f7c7aa0fae06b53bbecef2b2 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 3 Jun 2026 16:03:49 +0200 Subject: [PATCH 09/13] [chore:] implemented GetCustomerByID() --- DataStore/Settings.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DataStore/Settings.cs b/DataStore/Settings.cs index 67be3fe..89890a0 100644 --- a/DataStore/Settings.cs +++ b/DataStore/Settings.cs @@ -165,6 +165,19 @@ public class Customer public char separator { get; set; } = ','; public int ID { get; } + public static Customer GetCustomerByID(int id) + { + foreach (var customer in Settings._instance.customers.customers) + { + if (id == customer.ID) + { + return customer; + } + } + + return null; + } + // public static int GetIDByCustomerListItem(string item_content) // { From 5a47fedcf0363173fc7e3bcc0f486be4272a8b50 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 3 Jun 2026 16:04:39 +0200 Subject: [PATCH 10/13] [feat:] basic running-sheet creation implementation (buggy, because of plzs) --- Tasks/PdfBuilder.cs | 121 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 98 insertions(+), 23 deletions(-) diff --git a/Tasks/PdfBuilder.cs b/Tasks/PdfBuilder.cs index 8d467e8..0b292f2 100644 --- a/Tasks/PdfBuilder.cs +++ b/Tasks/PdfBuilder.cs @@ -424,40 +424,115 @@ public class PdfBuilder int margin = 50; - List<(int, int)> grouped_nums = GroupAddresses(setID); + var grouped_nums = GroupAddresses(setID); - var page = document.AddPage(); - page.Size = PageSize.A4; + foreach (var result in grouped_nums) + { + var page = document.AddPage(); + page.Size = PageSize.A4; - var gfx = XGraphics.FromPdfPage(page); + var gfx = XGraphics.FromPdfPage(page); - var width = page.Width.Point-margin; - var height = page.Height.Point-margin; - gfx.DrawLine(XPens.Black, margin, margin, margin, height); - gfx.DrawLine(XPens.Black, margin, margin, width, margin); - gfx.DrawLine(XPens.Black, width, margin, width, height); - gfx.DrawLine(XPens.Black, margin, height, width, height); + var width = page.Width.Point-margin; + var height = page.Height.Point-margin; + gfx.DrawLine(XPens.Black, margin, margin, margin, height); + gfx.DrawLine(XPens.Black, margin, margin, width, margin); + gfx.DrawLine(XPens.Black, width, margin, width, height); + gfx.DrawLine(XPens.Black, margin, height, width, height); - var boldfont = new XFont("Cantarell", 11, XFontStyleEx.Bold); - var font = new XFont("Cantarell", 11, XFontStyleEx.Regular); - var bigboldfont = new XFont("Cantarell", 35, XFontStyleEx.Bold); + var boldfont = new XFont("Cantarell", 11, XFontStyleEx.Bold); + var font = new XFont("Cantarell", 11, XFontStyleEx.Regular); + var bigboldfont = new XFont("Cantarell", 35, XFontStyleEx.Bold); + + // Versandinfo + gfx.DrawString($"Versand {list.Name}", boldfont, XBrushes.Black, + new XRect(margin+5, margin, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"Start: ", font, XBrushes.Black, + new XRect(margin+5, margin+25, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"{result.Item3}", font, XBrushes.Black, + new XRect(margin+75, margin+25, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"Ende: ", font, XBrushes.Black, + new XRect(margin+5, margin+40, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"{result.Item4}", font, XBrushes.Black, + new XRect(margin+75, margin+40, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"Kunde: ", font, XBrushes.Black, + new XRect(margin+5, margin+55, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"{Customer.GetCustomerByID(list.owner_id).name}", font, XBrushes.Black, + new XRect(margin+75, margin+55, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"Absender: ", font, XBrushes.Black, + new XRect(margin+5, margin+70, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"{Customer.GetCustomerByID(list.owner_id).sender_address}", font, XBrushes.Black, + new XRect(margin+75, margin+70, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"Anzahl: ", font, XBrushes.Black, + new XRect(margin+5, margin+85, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"{result.Item5}", font, XBrushes.Black, + new XRect(margin+75, margin+85, width-margin, 25), XStringFormats.CenterLeft); + + // logofclient ad + gfx.DrawString($"powered by logofclient", font, XBrushes.Black, + new XRect(margin+5, height-55, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"(c) 2026 MyPapertown", font, XBrushes.Black, + new XRect(margin+5, height-40, width-margin, 25), XStringFormats.CenterLeft); + gfx.DrawString($"mypapercloud.de/logof", font, XBrushes.Black, + new XRect(margin+5, height-25, width-margin, 25), XStringFormats.CenterLeft); - int number = 0; - gfx.DrawString($"Versand {list.Name}", boldfont, XBrushes.Black, - new XRect(margin+5, margin, width-margin, 25), XStringFormats.CenterLeft); - gfx.DrawString($"powered by logofclient", font, XBrushes.Black, - new XRect(margin+5, margin+25, width-margin, 25), XStringFormats.CenterLeft); - - gfx.DrawString($"{number}", bigboldfont, XBrushes.Black, - new XRect(margin, margin, width-margin, (height-margin)/2), XStringFormats.Center); + + int total_frac = 0; + foreach (var item in grouped_nums) + { + if (item.Item2 == result.Item2) total_frac++; + } + + // group number + gfx.DrawString($"{result.Item2}", bigboldfont, XBrushes.Black, + new XRect(margin, margin, width-margin, (height-margin)/2), XStringFormats.Center); + gfx.DrawString($"Fraktion {result.Item1}/{total_frac}", font, XBrushes.Black, + new XRect(margin, margin, width-margin, (height-margin)/2 + 50), XStringFormats.Center); + } document.Save(path); } - public List<(int, int)> GroupAddresses(int setID) + /// + /// Calculates address groups to summarize for the single pages of the running sheets. + /// + /// + /// List of quadruples consisting of a number and the starting of the plz, as well as first, last plz and total amount of addresses + public List<(int, string, string, string, int)> GroupAddresses(int setID) { + int grpcount = Settings._instance.pdfExport.rsNumGrouped; // Amount of addresses per group + int stpoint = Settings._instance.pdfExport.rsPlzStartpoint; // group starting point (first n characters of the plz) + KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID); + if (list == null) + throw new Exception("AddressSet nicht gefunden"); + + List<(int, string, string, string, int)> output = new(); + List> sorted_list = list.KasPersons + .Where(x => !string.IsNullOrEmpty(x?.used_plz) && + x.used_plz.Length >= stpoint) + .OrderBy(x => x.used_plz) + .GroupBy(x => x.used_plz.Substring(0, stpoint)) + .ToList(); + + foreach (var group in sorted_list) + { + string start = group.Key; + int fraktion = 0; - return null; + for (int count = 0; count < group.Count(); count += grpcount) + { + fraktion++; + + int currentGroupSize = Math.Min(grpcount, group.Count() - count); + + string first = group.ElementAt(count).used_plz; + string last = group.ElementAt(count + currentGroupSize - 1).used_plz; + + output.Add((fraktion, start, first, last, currentGroupSize)); + } + } + + return output; } } From 0750c51448ee18a1a88c59deac86c491095fc1a4 Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 3 Jun 2026 16:05:02 +0200 Subject: [PATCH 11/13] [chore:] used_plz at KasPerson for the plz used in the final address) --- DataStore/DataStructures.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/DataStore/DataStructures.cs b/DataStore/DataStructures.cs index c2b5dad..ad5bef0 100644 --- a/DataStore/DataStructures.cs +++ b/DataStore/DataStructures.cs @@ -178,6 +178,23 @@ public class KasPerson public string abteilung { get; set; } public string funktionad { get; set; } + public string used_plz { get; set; } = ""; + + public static void SetUsedPLZ(int id, string plz) + { + foreach (var set in Settings._instance.addressSets.addresses) + { + foreach (var add in set.KasPersons) + { + if (add.id == id) + { + add.used_plz = plz; + return; + } + } + } + } + public static int GenerateNewID(int base_id) { //var newid = 100000 + base_id; From 1b200ee41e40632d9e56d76089792bbfb9e2971d Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Wed, 3 Jun 2026 16:05:11 +0200 Subject: [PATCH 12/13] [chore:] set used_plz --- Tasks/AddressCreation.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tasks/AddressCreation.cs b/Tasks/AddressCreation.cs index e1f3105..0c937ec 100644 --- a/Tasks/AddressCreation.cs +++ b/Tasks/AddressCreation.cs @@ -104,6 +104,7 @@ public static class AddressCreator // Alternative A: pplz valid and city existing if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land)) { + KasPerson.SetUsedPLZ(id, address.pplz); string_address = address.pplz + " " + address.ort + "\n" + string_address; address_line_count++; if (!string.IsNullOrWhiteSpace(address.postfach)) @@ -150,6 +151,7 @@ public static class AddressCreator } // Alternative B: plz valid and city existing else if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.plz, address.land)) { + KasPerson.SetUsedPLZ(id, address.plz); string_address = address.plz + " " + address.ort + "\n" + string_address; address_line_count++; if (!string.IsNullOrWhiteSpace(address.strasse)) From 516ca587401d9349e63718c170d81c535b5bfddc Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Thu, 4 Jun 2026 07:52:08 +0200 Subject: [PATCH 13/13] [fix:] plz/pplz was not normalized during address creation --- Tasks/AddressCreation.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Tasks/AddressCreation.cs b/Tasks/AddressCreation.cs index 0c937ec..b543a3b 100644 --- a/Tasks/AddressCreation.cs +++ b/Tasks/AddressCreation.cs @@ -104,8 +104,9 @@ public static class AddressCreator // Alternative A: pplz valid and city existing if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.pplz, address.land)) { - KasPerson.SetUsedPLZ(id, address.pplz); - string_address = address.pplz + " " + address.ort + "\n" + string_address; + string pplz = NormalizeGermanPLZ(address.pplz); + KasPerson.SetUsedPLZ(id, pplz); + string_address = pplz + " " + address.ort + "\n" + string_address; address_line_count++; if (!string.IsNullOrWhiteSpace(address.postfach)) { @@ -151,8 +152,9 @@ public static class AddressCreator } // Alternative B: plz valid and city existing else if (!string.IsNullOrEmpty(address.ort) && CheckPLZ(address.plz, address.land)) { - KasPerson.SetUsedPLZ(id, address.plz); - string_address = address.plz + " " + address.ort + "\n" + string_address; + string plz = NormalizeGermanPLZ(address.plz); + KasPerson.SetUsedPLZ(id, plz); + string_address = plz + " " + address.ort + "\n" + string_address; address_line_count++; if (!string.IsNullOrWhiteSpace(address.strasse)) { @@ -251,4 +253,23 @@ public static class AddressCreator // For non-German countries, accept any non-empty postal code return true; } + + public static string NormalizeGermanPLZ(string plz) + { + if(plz.Length == 5) return plz; + if(plz.Length > 5) + { + return plz.Substring(0, 5); + } + + if (plz.Length < 5) + { + int toadd = 5 - plz.Length; + for (int i = 0; i < toadd; i++) + { + plz = "0" + plz; + } + } + return plz; + } } \ No newline at end of file