6 Commits

Author SHA1 Message Date
fierke 75b6b1dc4d [chore:] various tiny improvements 2026-05-20 08:00:20 +02:00
fierke 1161a437c4 [fix:] wiki preview reloading after saving changes 2026-05-19 09:44:14 +02:00
fierke 605ba95848 [fix:] message box center screen startup 2026-05-19 09:32:06 +02:00
fierke eb38bafd23 [feat:] delete address sets (FINALLY, this was so hard to implement, it took almost 2 minutes) 2026-05-19 09:31:35 +02:00
fierke e2d5ae2a70 Merge pull request '[fix?:] windows paths (ai-based since windows is boring)' (#57) from windows-paths into main
Reviewed-on: #57

since this still works on any linux machines and theoretical on windows machines, we're merging it to prevent wrong commits cause i configured something wrong
2026-05-19 07:24:01 +00:00
fierke b3ab21ae38 [fix?:] windows paths (ai-based since windows is boring) 2026-05-18 11:42:32 +02:00
6 changed files with 107 additions and 36 deletions
+13 -6
View File
@@ -24,8 +24,7 @@ public class Settings
public static void Save() public static void Save()
{ {
if (!Directory.Exists(Global._instance.config_path)) if (!Directory.Exists(Global._instance.config_path))
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Directory.CreateDirectory(Global._instance.config_path);
"logofclient"));
// if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path; // if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
var json = JsonConvert.SerializeObject(_instance); var json = JsonConvert.SerializeObject(_instance);
@@ -79,14 +78,14 @@ public class Global
_instance = this; _instance = this;
} }
public string config_path { get; } = Path.Combine( public string config_path { get; set; } = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"logofclient"); "logofclient");
public void SetConfigPath(string path) public void SetConfigPath(string path)
{ {
Path.Combine( if (!string.IsNullOrWhiteSpace(path))
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); config_path = PathUtilities.NormalizeFileSystemPath(path);
} }
public string wiki_storage_path { get; set; } = Path.Combine( public string wiki_storage_path { get; set; } = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
@@ -121,7 +120,8 @@ public class Global
var contents = File.ReadAllText(Path.Combine( var contents = File.ReadAllText(Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
"global.config")); "global.config"));
_instance = JsonConvert.DeserializeObject<Global>(contents); _instance = JsonConvert.DeserializeObject<Global>(contents) ?? new Global();
_instance.NormalizePaths();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -130,6 +130,13 @@ public class Global
Save(); Save();
} }
} }
private void NormalizePaths()
{
config_path = PathUtilities.NormalizeFileSystemPath(config_path);
wiki_storage_path = PathUtilities.NormalizeFileSystemPath(wiki_storage_path);
font_path = PathUtilities.NormalizeFileSystemPath(font_path);
}
} }
public class Customers public class Customers
+1 -1
View File
@@ -78,7 +78,7 @@
</StackPanel> </StackPanel>
</MenuItem.Header> </MenuItem.Header>
</MenuItem> </MenuItem>
<MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetRename_OnClick" IsEnabled="False"> <MenuItem x:Name="MnIAdSetDelete" Click="MnIAdSetDelete_OnClick" IsEnabled="True">
<MenuItem.Header> <MenuItem.Header>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<LucideIcon Kind="Trash" Width="12" Height="12" Size="12" /> <LucideIcon Kind="Trash" Width="12" Height="12" Size="12" />
+79 -19
View File
@@ -38,6 +38,11 @@ public partial class MainWindow : Window
Logger.Log("Loading settings..."); Logger.Log("Loading settings...");
Global.Load(); Global.Load();
Settings.Load(); Settings.Load();
if (!string.IsNullOrWhiteSpace(Global._instance.config_path))
TbConfigPath.Text = PathUtilities.NormalizeFileSystemPath(Global._instance.config_path);
LoadPdfExportOptions(); LoadPdfExportOptions();
HookPdfExportOptionEvents(); HookPdfExportOptionEvents();
@@ -57,7 +62,7 @@ public partial class MainWindow : Window
try try
{ {
if (!string.IsNullOrWhiteSpace(Global._instance.wiki_storage_path)) if (!string.IsNullOrWhiteSpace(Global._instance.wiki_storage_path))
TbWikiPath.Text = Global._instance.wiki_storage_path; TbWikiPath.Text = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -132,6 +137,8 @@ public partial class MainWindow : Window
private void MnuExit_OnClick(object? sender, RoutedEventArgs e) private void MnuExit_OnClick(object? sender, RoutedEventArgs e)
{ {
Settings.Save();
Global.Save();
Environment.Exit(0); Environment.Exit(0);
} }
@@ -212,6 +219,11 @@ public partial class MainWindow : Window
private async void NavTree_SelectionChanged(object? sender, SelectionChangedEventArgs e) private async void NavTree_SelectionChanged(object? sender, SelectionChangedEventArgs e)
{
ReloadWikiItem();
}
private async void ReloadWikiItem()
{ {
if (NavTree.SelectedItem is TreeViewItem t && t.Tag is WikiItem item && !item.IsFolder) if (NavTree.SelectedItem is TreeViewItem t && t.Tag is WikiItem item && !item.IsFolder)
{ {
@@ -255,6 +267,8 @@ public partial class MainWindow : Window
ExpandAndFindNode(nodes, selectPath, out var selectedNode) && ExpandAndFindNode(nodes, selectPath, out var selectedNode) &&
selectedNode != null) selectedNode != null)
NavTree.SelectedItem = selectedNode; NavTree.SelectedItem = selectedNode;
ReloadWikiItem();
}catch (Exception ex) }catch (Exception ex)
{ {
Logger.Log($"Error while populating nav tree: {ex.Message}", Logger.LogType.Error); Logger.Log($"Error while populating nav tree: {ex.Message}", Logger.LogType.Error);
@@ -275,7 +289,7 @@ public partial class MainWindow : Window
{ {
try try
{ {
var wikiRoot = Global._instance.wiki_storage_path; var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (NavTree.SelectedItem is TreeViewItem treeItem && treeItem.Tag is WikiItem selectedItem) if (NavTree.SelectedItem is TreeViewItem treeItem && treeItem.Tag is WikiItem selectedItem)
{ {
if (selectedItem.IsFolder) return selectedItem.Path; if (selectedItem.IsFolder) return selectedItem.Path;
@@ -294,6 +308,9 @@ public partial class MainWindow : Window
private static bool PathsEqual(string left, string right) private static bool PathsEqual(string left, string right)
{ {
left = PathUtilities.NormalizeFileSystemPath(left);
right = PathUtilities.NormalizeFileSystemPath(right);
var normalizedLeft = Path.GetFullPath(left) var normalizedLeft = Path.GetFullPath(left)
.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
var normalizedRight = Path.GetFullPath(right) var normalizedRight = Path.GetFullPath(right)
@@ -337,7 +354,7 @@ public partial class MainWindow : Window
private void OpenFolderButton_Click(object? sender, RoutedEventArgs e) private void OpenFolderButton_Click(object? sender, RoutedEventArgs e)
{ {
var path = Global._instance.wiki_storage_path; var path = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
if (!Directory.Exists(path)) return; if (!Directory.Exists(path)) return;
try try
@@ -364,9 +381,9 @@ public partial class MainWindow : Window
}); });
if (folder == null || folder.Count == 0) return; if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path; var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
TbWikiPath.Text = chosen.ToString(); TbWikiPath.Text = chosen;
Global._instance.wiki_storage_path = chosen.ToString(); Global._instance.wiki_storage_path = chosen;
Global.Save(); Global.Save();
// reinit wiki service and reload tree // reinit wiki service and reload tree
@@ -384,9 +401,9 @@ public partial class MainWindow : Window
}); });
if (folder == null || folder.Count == 0) return; if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path; var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
TbFontPath.Text = chosen.ToString(); TbFontPath.Text = chosen;
Global._instance.font_path = chosen.ToString(); Global._instance.font_path = chosen;
Global.Save(); Global.Save();
} }
@@ -400,8 +417,8 @@ public partial class MainWindow : Window
}); });
if (folder == null || folder.Count == 0) return; if (folder == null || folder.Count == 0) return;
var chosen = folder[0].Path; var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
Global._instance.SetConfigPath(chosen.ToString()); Global._instance.SetConfigPath(chosen);
TbConfigPath.Text = Global._instance.config_path; TbConfigPath.Text = Global._instance.config_path;
Global.Save(); Global.Save();
@@ -441,6 +458,7 @@ public partial class MainWindow : Window
TbSettingsCustomerDescription.Text = ""; TbSettingsCustomerDescription.Text = "";
TbSettingsCustomerName.Text = ""; TbSettingsCustomerName.Text = "";
TbSettingsCustomerPatchInfo.Text = ""; TbSettingsCustomerPatchInfo.Text = "";
TbSettingsCustomerName.Focus();
Settings.Save(); Settings.Save();
RefreshCustomerItems(); RefreshCustomerItems();
@@ -491,7 +509,13 @@ public partial class MainWindow : Window
return; return;
} }
var editedWikiFilePath = _selectedWikiFilePath;
EditorWindow ew = new(_selectedWikiFilePath); EditorWindow ew = new(_selectedWikiFilePath);
ew.Closed += (_, _) =>
{
if (!string.IsNullOrWhiteSpace(editedWikiFilePath) && File.Exists(editedWikiFilePath))
PopulateNavTree(editedWikiFilePath, editedWikiFilePath);
};
ew.Show(); ew.Show();
//await MessageBox.Show(this, "Edit feature is currently disabled.", "Edit Disabled"); //await MessageBox.Show(this, "Edit feature is currently disabled.", "Edit Disabled");
@@ -829,10 +853,7 @@ public partial class MainWindow : Window
if (!string.IsNullOrWhiteSpace(filePath)) if (!string.IsNullOrWhiteSpace(filePath))
{ {
if (filePath.StartsWith("file://")) filePath = PathUtilities.NormalizeFileSystemPath(filePath);
{
filePath = new Uri(filePath).LocalPath;
}
Console.WriteLine($"PATH: {filePath}"); Console.WriteLine($"PATH: {filePath}");
@@ -1106,11 +1127,18 @@ public partial class MainWindow : Window
result = result.Trim(); result = result.Trim();
if (!result.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) result += ".md"; if (!result.EndsWith(".md", StringComparison.OrdinalIgnoreCase)) result += ".md";
if (!Directory.Exists(Global._instance.wiki_storage_path)) var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
Directory.CreateDirectory(Global._instance.wiki_storage_path); if (!Directory.Exists(wikiRoot))
Directory.CreateDirectory(wikiRoot);
try try
{ {
if (PathUtilities.HasInvalidFileNameChars(result))
{
MessageBox.Show(this, "Der Dateiname enthält ungültige Zeichen.", "Fehler");
return;
}
var targetDirectory = GetSelectedWikiTargetDirectory(); var targetDirectory = GetSelectedWikiTargetDirectory();
Directory.CreateDirectory(targetDirectory); Directory.CreateDirectory(targetDirectory);
var newFilePath = Path.Combine(targetDirectory, result); var newFilePath = Path.Combine(targetDirectory, result);
@@ -1131,11 +1159,18 @@ public partial class MainWindow : Window
result = result.Trim(); result = result.Trim();
if (!Directory.Exists(Global._instance.wiki_storage_path)) var wikiRoot = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
Directory.CreateDirectory(Global._instance.wiki_storage_path); if (!Directory.Exists(wikiRoot))
Directory.CreateDirectory(wikiRoot);
try try
{ {
if (PathUtilities.HasInvalidFileNameChars(result))
{
MessageBox.Show(this, "Der Ordnername enthält ungültige Zeichen.", "Fehler");
return;
}
var targetDirectory = GetSelectedWikiTargetDirectory(); var targetDirectory = GetSelectedWikiTargetDirectory();
var newFolderPath = Path.Combine(targetDirectory, result); var newFolderPath = Path.Combine(targetDirectory, result);
Directory.CreateDirectory(newFolderPath); Directory.CreateDirectory(newFolderPath);
@@ -1223,4 +1258,29 @@ public partial class MainWindow : Window
} }
} }
private async void MnIAdSetDelete_OnClick(object? sender, RoutedEventArgs e)
{
if(await MessageBox.Show(this,"Wirklich löschen?","",MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
var cus_id = ((Customer)LstCustomers.SelectedItems[0]).ID;
var id = (LstCustomerAdressSets.SelectedItems[0] as KasAddressList).ID;
try
{
foreach (var set in Settings._instance.addressSets.addresses)
if (set.ID == id)
{
Settings._instance.addressSets.addresses.Remove(set);
Settings.Save();
RefreshAddressSetListItems(cus_id);
break;
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.StackTrace, "Fehler");
Logger.Log($"Error while deleting address set: {ex.Message}", Logger.LogType.Error);
}}
}
} }
+1 -1
View File
@@ -2,7 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" SizeToContent="WidthAndHeight" mc:Ignorable="d" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen"
x:Class="Logof_Client.MessageBox" Icon="assets/icon.ico" x:Class="Logof_Client.MessageBox" Icon="assets/icon.ico"
Title="MessageBox"> Title="MessageBox">
<StackPanel> <StackPanel>
+7 -6
View File
@@ -14,14 +14,14 @@ public partial class EditorWindow : Window
try try
{ {
InitializeComponent(); InitializeComponent();
this.filename = filename; this.filename = PathUtilities.NormalizeFileSystemPath(filename);
if (!string.IsNullOrWhiteSpace(filename) && File.Exists(filename)) if (!string.IsNullOrWhiteSpace(this.filename) && File.Exists(this.filename))
{ {
var content = TbContent; var content = TbContent;
if (content != null) content.Text = File.ReadAllText(this.filename); if (content != null) content.Text = File.ReadAllText(this.filename);
Title = "Wiki Editor - " + filename; Title = "Wiki Editor - " + filename;
} }
else if (!string.IsNullOrWhiteSpace(filename)) else if (!string.IsNullOrWhiteSpace(this.filename))
{ {
MessageBox.Show(null, "Die Datei existiert nicht", "Fehler"); MessageBox.Show(null, "Die Datei existiert nicht", "Fehler");
Close(); Close();
@@ -35,7 +35,7 @@ public partial class EditorWindow : Window
try try
{ {
File.WriteAllText(filename, TbContent.Text); File.WriteAllText(filename, TbContent.Text);
MainWindow._instance.PopulateNavTree(); MainWindow._instance.PopulateNavTree(filename, filename);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -49,7 +49,8 @@ public partial class EditorWindow : Window
private void BtnSaveAs_OnClick(object? sender, RoutedEventArgs e) private void BtnSaveAs_OnClick(object? sender, RoutedEventArgs e)
{ {
MessageBox.Show(null, MessageBox.Show(null,
"Feature noch nicht implemetiert.\nErstelle neue Dateien unter " + Global._instance.wiki_storage_path, "Feature noch nicht implemetiert.\nErstelle neue Dateien unter " +
PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path),
"Fehler"); "Fehler");
} }
@@ -65,4 +66,4 @@ public partial class EditorWindow : Window
MainWindow._instance.PopulateNavTree(); MainWindow._instance.PopulateNavTree();
Close(); Close();
} }
} }
+6 -3
View File
@@ -13,7 +13,7 @@ public class WikiService
// prefer global wiki storage path if configured // prefer global wiki storage path if configured
if (Global._instance != null && !string.IsNullOrWhiteSpace(Global._instance.wiki_storage_path)) if (Global._instance != null && !string.IsNullOrWhiteSpace(Global._instance.wiki_storage_path))
{ {
var cfg = Global._instance.wiki_storage_path; var cfg = PathUtilities.NormalizeFileSystemPath(Global._instance.wiki_storage_path);
WikiRootFullPath = Path.IsPathRooted(cfg) WikiRootFullPath = Path.IsPathRooted(cfg)
? cfg ? cfg
: Path.Combine(Directory.GetCurrentDirectory(), cfg); : Path.Combine(Directory.GetCurrentDirectory(), cfg);
@@ -25,8 +25,11 @@ public class WikiService
wikiRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), wikiRoot = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"logofclient", "logofclient",
"wiki"); "wiki");
wikiRoot = PathUtilities.NormalizeFileSystemPath(wikiRoot);
WikiRoot = wikiRoot; WikiRoot = wikiRoot;
WikiRootFullPath = Path.Combine(Directory.GetCurrentDirectory(), wikiRoot); WikiRootFullPath = Path.IsPathRooted(wikiRoot)
? wikiRoot
: Path.Combine(Directory.GetCurrentDirectory(), wikiRoot);
} }
} }
@@ -68,4 +71,4 @@ public class WikiService
if (!File.Exists(path)) return Task.FromResult<string?>(null); if (!File.Exists(path)) return Task.FromResult<string?>(null);
return File.ReadAllTextAsync(path); return File.ReadAllTextAsync(path);
} }
} }