From b75d6f0566a00483c6e9243c0fe8701dbb74c8fc Mon Sep 17 00:00:00 2001 From: Elias Fierke Date: Thu, 3 Jul 2025 11:07:38 +0200 Subject: [PATCH] [chore:] changed string to Uri for filePaths --- MainWindow.axaml.cs | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index 1729e27..30946d4 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -1,18 +1,21 @@ using System; using Avalonia.Controls; using Avalonia.Interactivity; +using Avalonia.Platform.Storage; namespace Logof_Client; public partial class MainWindow : Window { + public Uri filePath; + public MainWindow() { InitializeComponent(); try { var temppath = "kaspersons.csv"; - var result = DataImport.ImportKasAddressList(temppath); + var result = DataImport.ImportKasAddressList(new Uri(temppath)); if (result.Item1) { var check_result = AddressCheck.Perform(result.Item2); @@ -53,4 +56,42 @@ public partial class MainWindow : Window { throw new NotImplementedException(); } + + private async void BtnChooseFile_OnClick(object? sender, RoutedEventArgs e) + { + var topLevel = GetTopLevel(this); + var file = await topLevel!.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions + { + Title = "KAS-CSV-Datei auswählen", + AllowMultiple = false, + FileTypeFilter = new[] + { + new FilePickerFileType(".csv-Datei") + { + Patterns = new[] { "*.csv" } + //Patterns = new[] { "*" } + } + } + }); + + if (file == null) return; + TbFilename.Text = file[0].Path.ToString(); + filePath = file[0].Path; + } + + private void BtnCheck_OnClick(object? sender, RoutedEventArgs e) + { + if (filePath == null) MessageBox.Show(this, "Bitte zunächst eine Datei auswählen", "Datei fehlt"); + var result = DataImport.ImportKasAddressList(filePath); + if (result.Item1) + { + var check_result = AddressCheck.Perform(result.Item2); + foreach (var item in check_result) + { + Console.WriteLine(); + Console.Write(item.Item1 + " "); + foreach (var error in item.Item2) Console.Write(error + ", "); + } + } + } } \ No newline at end of file