[chore:] rearrangend some result window features for debugging purposes (unfinal)
This commit is contained in:
@@ -18,7 +18,9 @@
|
|||||||
x:Name="BtnShowSelected" Click="BtnShowSelected_OnClick"
|
x:Name="BtnShowSelected" Click="BtnShowSelected_OnClick"
|
||||||
Margin="10,10,10,10" />
|
Margin="10,10,10,10" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<DataGrid x:Name="DgResult" Grid.Column="1" AutoGenerateColumns="True" />
|
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||||
|
<StackPanel x:Name="StkResults" Orientation="Vertical" Margin="10" />
|
||||||
|
</ScrollViewer>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
@@ -5,6 +5,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace Logof_Client;
|
namespace Logof_Client;
|
||||||
|
|
||||||
@@ -30,7 +31,43 @@ public partial class ResultWindow : Window
|
|||||||
// Filter to only show persons with errors
|
// Filter to only show persons with errors
|
||||||
var result_with_errors = result.Where(p => p.PersonError != null).ToList();
|
var result_with_errors = result.Where(p => p.PersonError != null).ToList();
|
||||||
LblResultCount.Content = $"{result_with_errors.Count}/{ur_result.Count} Ergebnisse";
|
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)
|
private void ViewSingle(int refsid)
|
||||||
@@ -112,46 +149,74 @@ public partial class ResultWindow : Window
|
|||||||
private void UpdateFilter()
|
private void UpdateFilter()
|
||||||
{
|
{
|
||||||
var temp_result = new List<KasPerson>();
|
var temp_result = new List<KasPerson>();
|
||||||
var checked_types = new List<AddressCheck.ErrorTypes>();
|
|
||||||
var checked_types_war = new List<AddressCheck.WarningTypes>();
|
var checkedErrors = new HashSet<AddressCheck.ErrorTypes>();
|
||||||
|
var checkedWarnings = new HashSet<AddressCheck.WarningTypes>();
|
||||||
|
|
||||||
|
// safer parsing: use TryParse and trim the Content string
|
||||||
foreach (var cb in errortypecheckboxes)
|
foreach (var cb in errortypecheckboxes)
|
||||||
if (cb.IsChecked == true)
|
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<AddressCheck.ErrorTypes>(s, true, out var et))
|
||||||
|
checkedErrors.Add(et);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var cb in warningtypecheckboxes)
|
foreach (var cb in warningtypecheckboxes)
|
||||||
if (cb.IsChecked == true)
|
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<AddressCheck.WarningTypes>(s, true, out var wt))
|
||||||
|
checkedWarnings.Add(wt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
foreach (var person in ur_result)
|
||||||
{
|
{
|
||||||
if (person.PersonError == null) continue;
|
if (person.PersonError == null) continue;
|
||||||
|
|
||||||
foreach (var err in person.PersonError.errors)
|
var personErrors = person.PersonError.errors ?? Enumerable.Empty<AddressCheck.ErrorTypes>();
|
||||||
if (checked_types.Contains(err) && !temp_result.Contains(person))
|
var personWarnings = person.PersonError.warnings ?? Enumerable.Empty<AddressCheck.WarningTypes>();
|
||||||
temp_result.Add(person);
|
|
||||||
|
|
||||||
foreach (var war in person.PersonError.warnings)
|
var matchesError = false;
|
||||||
if (checked_types_war.Contains(war) && !temp_result.Contains(person))
|
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);
|
temp_result.Add(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
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)
|
private void BtnShowSelected_OnClick(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
foreach (var selected in DgResult.SelectedItems)
|
// foreach (var selected in DgResult.SelectedItems)
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
var _asKas = (KasPerson)selected;
|
// var _asKas = (KasPerson)selected;
|
||||||
ViewSingle(_asKas.refsid);
|
// ViewSingle(_asKas.refsid);
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
Console.WriteLine(ex.Message);
|
// Console.WriteLine(ex.Message);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user