[chore:] big code-cleanup session

This commit is contained in:
2026-08-02 14:34:49 +02:00
parent 7b49ed8b47
commit 59e7d96131
18 changed files with 134 additions and 597 deletions
+12 -89
View File
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
SetSettingsCustomerEnabledState(false);
//Hide();
var s = new StartupWindow();
//var s = new StartupWindow();
//s.Show();
_instance = this;
@@ -85,74 +85,43 @@ public partial class MainWindow : Window
{
Logger.Log($"Error while doing wiki stuff: {ex.Message}", Logger.LogType.Error);
}
//Thread.Sleep(3000);
//Show();
}
private async void StartAddressCheck(int addresSetID)
{
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
var progressWindow = new ProgressWindow();
progressWindow.Show(_instance);
var processor = new AddressCheck(progressWindow);
var result = await processor.Perform(addresSetID);
// foreach (var item in result)
// {
// }
progressWindow.Close();
new ResultWindow(result, addresSetID).Show();
Settings.Save();
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
}
private async void StartAddressShortener(KasAddressList set)
{
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
var progressWindow = new ProgressWindow();
progressWindow.Show(_instance);
var processor = new AddressShortener(progressWindow);
await processor.Perform(set);
// foreach (var item in result)
// {
// }
progressWindow.Close();
Settings.Save();
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
}
private async void StartAddressRepairer(KasAddressList set)
{
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
var progressWindow = new ProgressWindow();
progressWindow.Show(_instance);
var processor = new AddressRepair(progressWindow);
await processor.Perform(set);
// foreach (var item in result)
// {
// }
progressWindow.Close();
Settings.Save();
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
}
@@ -170,7 +139,7 @@ public partial class MainWindow : Window
Process.Start(new ProcessStartInfo
{
FileName = "https://mypapercloud.de/logof/",
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
UseShellExecute = true
});
}
catch (Exception ex)
@@ -186,7 +155,7 @@ public partial class MainWindow : Window
Process.Start(new ProcessStartInfo
{
FileName = "https://mypapercloud.de/logof/wiki/",
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
UseShellExecute = true
});
}
catch (Exception ex)
@@ -202,7 +171,7 @@ public partial class MainWindow : Window
Process.Start(new ProcessStartInfo
{
FileName = "https://git.mypapercloud.de/fierke/logofclient",
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
UseShellExecute = true
});
}
catch (Exception ex)
@@ -251,19 +220,6 @@ public partial class MainWindow : Window
_selectedWikiFilePath = item.Path;
var text = await _wikiService.LoadFileContentAsync(item.Path);
MsvWikiView.Markdown = text;
// try
// {
// PreviewPanel.Children.Clear();
// var rendered = MarkdownRenderer.Render(text ?? string.Empty);
// PreviewPanel.Children.Add(rendered);
// }
// catch (Exception ex)
// {
// Logger.Log($"Error while rendering markdown: {ex.Message}", Logger.LogType.Error);
// PreviewPanel.Children.Clear();
// PreviewPanel.Children.Add(new TextBlock { Text = text ?? string.Empty });
// }
EditButton.IsEnabled = true;
}
else
@@ -407,8 +363,7 @@ public partial class MainWindow : Window
TbWikiPath.Text = chosen;
Global._instance.wiki_storage_path = chosen;
Global.Save();
// reinit wiki service and reload tree
_wikiService = new WikiService();
PopulateNavTree();
}
@@ -424,7 +379,6 @@ public partial class MainWindow : Window
if (folder == null || folder.Count == 0) return;
var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
//TbFontPath.Text = chosen;
Global._instance.font_path = chosen;
Global.Save();
}
@@ -468,9 +422,6 @@ public partial class MainWindow : Window
Settings._instance.addressSets.addresses.Add(result.Item2);
Settings.Save();
progressWindow.Close();
//new ResultWindow(result, addresSetID).Show();
}
@@ -500,8 +451,6 @@ public partial class MainWindow : Window
foreach (var customer in Settings._instance.customers.customers)
if (customer.ID == Settings._instance.customers.current.ID)
customer.name = TbSettingsCustomerName.Text;
//Settings.Save();
//RefreshCustomerItems();
}
private void LstSettingsCustomers_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
@@ -510,9 +459,6 @@ public partial class MainWindow : Window
if (LstSettingsCustomers.SelectedIndex < 0) return;
Settings._instance.customers.current =
((Customer)LstSettingsCustomers.SelectedItems[0]);
//foreach (var customer in Settings._instance.customers.customers)
//if (customer.ID == Settings._instance.customers.current.ID)
//{
TbSettingsCustomerDescription.Text = Settings._instance.customers.current.description;
TbSettingsCustomerName.Text = Settings._instance.customers.current.name;
TbSettingsCustomerSenderAddress.Text = Settings._instance.customers.current.sender_address;
@@ -522,7 +468,6 @@ public partial class MainWindow : Window
else
TbSettingsCustomerPatchInfo.Text = "";
SetSettingsCustomerEnabledState();
//}
}
private void SetSettingsCustomerEnabledState(bool enable = true)
@@ -550,8 +495,6 @@ public partial class MainWindow : Window
PopulateNavTree(editedWikiFilePath, editedWikiFilePath);
};
ew.Show();
//await MessageBox.Show(this, "Edit feature is currently disabled.", "Edit Disabled");
}
public void RefreshCustomerItems(int index = 0)
@@ -618,7 +561,7 @@ public partial class MainWindow : Window
{
try
{
MakeCalcManVisible();
MakeCalcManVisible();
var opts = new FilePickerOpenOptions();
opts.Title = "Address-Set importieren...";
opts.AllowMultiple = false;
@@ -628,14 +571,11 @@ public partial class MainWindow : Window
opts.FileTypeFilter = new[] { type };
var paths = await StorageProvider.OpenFilePickerAsync(opts);
if (paths?.Count <= 0) return;
if (LstCustomers.SelectedIndex < 0) return;
var selected_path = paths[0].Path;
foreach (var customer in Settings._instance.customers.customers)
if (customer == ((Customer)LstCustomers.SelectedItems[0]))
{
@@ -651,8 +591,6 @@ public partial class MainWindow : Window
got.Item2.SetOwner(customer.ID);
Settings._instance.addressSets.addresses.Add(got.Item2);
}
//var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
RefreshAddressSetListItems(customer.ID);
}
else
@@ -667,8 +605,6 @@ public partial class MainWindow : Window
got.Item2.SetOwner(customer.ID);
Settings._instance.addressSets.addresses.Add(got.Item2);
}
//var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
RefreshAddressSetListItems(customer.ID);
}
}
@@ -732,9 +668,6 @@ public partial class MainWindow : Window
BtnShorten.IsEnabled = false;
BtnRepair.IsEnabled = false;
}
}
}
@@ -753,19 +686,13 @@ public partial class MainWindow : Window
opts.FileTypeFilter = new[] { type };
var paths = await StorageProvider.OpenFilePickerAsync(opts);
if (paths?.Count <= 0) return;
//if (LstSettingsCustomers.SelectedIndex < 0) return;
var selected_path = paths[0].Path;
foreach (var customer in Settings._instance.customers.customers)
if (customer.ID == ((Customer)LstSettingsCustomers.SelectedItems[0]).ID)
customer.patch = AddressPatch.Import(selected_path);
Settings.Save();
} catch (Exception ex)
{
@@ -796,7 +723,6 @@ public partial class MainWindow : Window
MessageBox.Show(this, "Unknown Error: " + ex.Message, "Error");
Logger.Log($"Error while converting: {ex.Message}", Logger.LogType.Error);
}
}
private void BtnCombineDifference_OnClick(object? sender, RoutedEventArgs e)
@@ -850,7 +776,8 @@ public partial class MainWindow : Window
if (RbComprefsid.IsChecked == true)
{
return CombineAddresses.CombineType.refsid;
} else if (RbCompfinAd.IsChecked == true)
}
if (RbCompfinAd.IsChecked == true)
{
return CombineAddresses.CombineType.final_adress;
}
@@ -912,7 +839,7 @@ public partial class MainWindow : Window
filePath
);
Logger.Log("PDF OK");
Logger.Log("PDF seems OK");
}
}
@@ -1109,9 +1036,7 @@ public partial class MainWindow : Window
}
if (_selectedCountry == null) return;
//Console.WriteLine("Refreshing alternatives...");
foreach (var a in _selectedCountry.alternatives) LbSettingsAlternatives.Items.Add(a);
//Console.WriteLine(a);
TbSettingsCountryName.Text = _selectedCountry.name;
TbSettingsCountryTranslation.Text = _selectedCountry.translation;
@@ -1266,7 +1191,6 @@ public partial class MainWindow : Window
if (set.ID == id)
{
curr_set = set;
}
@@ -1329,7 +1253,6 @@ public partial class MainWindow : Window
{
Logger.Log($"Error while changing CSV divider: {ex.Message}", Logger.LogType.Error);
}
}
private async void MnIAdSetDelete_OnClick(object? sender, RoutedEventArgs e)
@@ -1347,14 +1270,14 @@ public partial class MainWindow : Window
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);
}}
}
}
}
private void Tb_OnTextChanged(object? sender, TextChangedEventArgs e)