diff --git a/ResultWindow.axaml b/ResultWindow.axaml
index 4b83a45..4420b8f 100644
--- a/ResultWindow.axaml
+++ b/ResultWindow.axaml
@@ -18,7 +18,9 @@
x:Name="BtnShowSelected" Click="BtnShowSelected_OnClick"
Margin="10,10,10,10" />
-
+
+
+
\ No newline at end of file
diff --git a/ResultWindow.axaml.cs b/ResultWindow.axaml.cs
index d9586ab..271f16b 100644
--- a/ResultWindow.axaml.cs
+++ b/ResultWindow.axaml.cs
@@ -5,6 +5,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Layout;
+using Avalonia.Media;
namespace Logof_Client;
@@ -30,7 +31,43 @@ public partial class ResultWindow : Window
// Filter to only show persons with errors
var result_with_errors = result.Where(p => p.PersonError != null).ToList();
LblResultCount.Content = $"{result_with_errors.Count}/{ur_result.Count} Ergebnisse";
- DgResult.ItemsSource = result_with_errors;
+
+ StkResults.Children.Clear();
+ foreach (var person in result_with_errors) StkResults.Children.Add(CreatePersonGrid(person));
+ }
+
+ private Grid CreatePersonGrid(KasPerson person)
+ {
+ var grid = new Grid
+ {
+ ColumnDefinitions = ColumnDefinitions.Parse("100,*,100,*,100,*"),
+ RowDefinitions = RowDefinitions.Parse("Auto"),
+ Margin = new Thickness(0, 5, 0, 5),
+ Background = new SolidColorBrush(Color.Parse("#F0F0F0"))
+ };
+
+ // Refsid
+ grid.Children.Add(new TextBlock
+ {
+ Text = "refsid: ",
+ FontWeight = FontWeight.Bold, Margin = new Thickness(5)
+ });
+ grid.Children.Add(new TextBlock { Text = person.refsid.ToString(), Margin = new Thickness(5) });
+ Grid.SetColumn(grid.Children[1], 1);
+
+ // PLZ
+ grid.Children.Add(new TextBlock { Text = "plz:", FontWeight = FontWeight.Bold, Margin = new Thickness(5) });
+ Grid.SetColumn(grid.Children[2], 2);
+ grid.Children.Add(new TextBlock { Text = person.plz, Margin = new Thickness(5) });
+ Grid.SetColumn(grid.Children[3], 3);
+
+ // PPLZ
+ grid.Children.Add(new TextBlock { Text = "errors:", FontWeight = FontWeight.Bold, Margin = new Thickness(5) });
+ Grid.SetColumn(grid.Children[4], 4);
+ grid.Children.Add(new TextBlock { Text = person.PersonError.GetString(), Margin = new Thickness(5) });
+ Grid.SetColumn(grid.Children[5], 5);
+
+ return grid;
}
private void ViewSingle(int refsid)
@@ -112,46 +149,74 @@ public partial class ResultWindow : Window
private void UpdateFilter()
{
var temp_result = new List();
- var checked_types = new List();
- var checked_types_war = new List();
+
+ var checkedErrors = new HashSet();
+ var checkedWarnings = new HashSet();
+
+ // safer parsing: use TryParse and trim the Content string
foreach (var cb in errortypecheckboxes)
if (cb.IsChecked == true)
- checked_types.Add(
- (AddressCheck.ErrorTypes)Enum.Parse(typeof(AddressCheck.ErrorTypes), cb.Content.ToString()));
+ {
+ var s = cb.Content?.ToString()?.Trim();
+ if (!string.IsNullOrEmpty(s) &&
+ Enum.TryParse(s, true, out var et))
+ checkedErrors.Add(et);
+ }
foreach (var cb in warningtypecheckboxes)
if (cb.IsChecked == true)
- checked_types_war.Add(
- (AddressCheck.WarningTypes)Enum.Parse(typeof(AddressCheck.WarningTypes), cb.Content.ToString()));
+ {
+ var s = cb.Content?.ToString()?.Trim();
+ if (!string.IsNullOrEmpty(s) &&
+ Enum.TryParse(s, true, out var wt))
+ checkedWarnings.Add(wt);
+ }
- foreach (var person in ur_result)
- {
- if (person.PersonError == null) continue;
+ // If no checkboxes are selected, show all persons with errors (default behavior)
+ if (checkedErrors.Count == 0 && checkedWarnings.Count == 0)
+ temp_result = ur_result.Where(p => p.PersonError != null).ToList();
+ else
+ foreach (var person in ur_result)
+ {
+ if (person.PersonError == null) continue;
- foreach (var err in person.PersonError.errors)
- if (checked_types.Contains(err) && !temp_result.Contains(person))
+ var personErrors = person.PersonError.errors ?? Enumerable.Empty();
+ var personWarnings = person.PersonError.warnings ?? Enumerable.Empty();
+
+ var matchesError = false;
+ var matchesWarning = false;
+
+ // only test errors if the user selected error-types
+ if (checkedErrors.Count > 0)
+ matchesError = personErrors.Any(err => checkedErrors.Contains(err));
+
+ // only test warnings if the user selected warning-types
+ if (checkedWarnings.Count > 0)
+ matchesWarning = personWarnings.Any(war => checkedWarnings.Contains(war));
+
+ // If at least one category matches (OR across categories), include person
+ if ((matchesError || matchesWarning) && !temp_result.Contains(person))
temp_result.Add(person);
-
- foreach (var war in person.PersonError.warnings)
- if (checked_types_war.Contains(war) && !temp_result.Contains(person))
- temp_result.Add(person);
- }
+ }
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
- DgResult.ItemsSource = temp_result;
+
+ StkResults.Children.Clear();
+ foreach (var person in temp_result) StkResults.Children.Add(CreatePersonGrid(person));
}
+
private void BtnShowSelected_OnClick(object? sender, RoutedEventArgs e)
{
- foreach (var selected in DgResult.SelectedItems)
- try
- {
- var _asKas = (KasPerson)selected;
- ViewSingle(_asKas.refsid);
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
+ // foreach (var selected in DgResult.SelectedItems)
+ // try
+ // {
+ // var _asKas = (KasPerson)selected;
+ // ViewSingle(_asKas.refsid);
+ // }
+ // catch (Exception ex)
+ // {
+ // Console.WriteLine(ex.Message);
+ // }
}
}
\ No newline at end of file