[chore:] better result window
This commit is contained in:
+61
-2
@@ -3,8 +3,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" Icon="assets/icon.ico"
|
||||
xmlns:local="using:Logof_Client"
|
||||
x:Class="Logof_Client.ResultWindow"
|
||||
Title="Ergebnis">
|
||||
Title="Ergebnis" x:DataType="local:ResultWindow">
|
||||
<Grid Grid.ColumnDefinitions="200,*">
|
||||
<Grid>
|
||||
<Label Content="Filter" Margin="10,10,10,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
|
||||
@@ -21,7 +22,65 @@
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<!-- <TextBlock x:Name="TbResults"></TextBlock> -->
|
||||
<ListBox x:Name="LbResults"></ListBox>
|
||||
<!-- <ListBox x:Name="LbResults"></ListBox> -->
|
||||
<!-- <DataGrid ItemsSource="{Binding Results}" IsReadOnly="True" -->
|
||||
<!-- AutoGenerateColumns="False"> -->
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- <DataGrid.Columns> -->
|
||||
<!-- <DataGridTextColumn Header="ID" -->
|
||||
<!-- Binding="{Binding PersonId}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Name" -->
|
||||
<!-- Binding="{Binding Name}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Errors" -->
|
||||
<!-- Binding="{Binding Errors}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Warnings" -->
|
||||
<!-- Binding="{Binding Warnings}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Refsid" -->
|
||||
<!-- Binding="{Binding Refsid}" /> -->
|
||||
<!-- </DataGrid.Columns> -->
|
||||
<!-- -->
|
||||
<!-- </DataGrid> -->
|
||||
<ListBox ItemsSource="{Binding Results}" SelectedItems="{Binding SelectedResults}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding PersonId}" />
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding Refsid}" />
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Text="{Binding Name}" />
|
||||
|
||||
<TextBlock Grid.Column="3"
|
||||
Text="{Binding Errors}" />
|
||||
|
||||
<TextBlock Grid.Column="4"
|
||||
Text="{Binding Warnings}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<!-- <StackPanel x:Name="StkResults" Orientation="Vertical" Margin="10" /> -->
|
||||
</ScrollViewer>
|
||||
|
||||
|
||||
+66
-13
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -8,38 +11,72 @@ using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Logof_Client;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
public partial class ResultWindow : Window
|
||||
public partial class ResultWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private List<ResultItem> _results = new();
|
||||
|
||||
public List<ResultItem> Results
|
||||
{
|
||||
get => _results;
|
||||
private set
|
||||
{
|
||||
_results = value;
|
||||
PropertyChanged?.Invoke(
|
||||
this,
|
||||
new PropertyChangedEventArgs(nameof(Results))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public List<CheckBox> errortypecheckboxes = new();
|
||||
public KasAddressList ur_addresses = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
||||
public List<KasPerson> ur_result;
|
||||
public List<CheckBox> warningtypecheckboxes = new();
|
||||
public List<ResultItem>? SelectedResults { get; set; }
|
||||
|
||||
public ResultWindow(List<KasPerson> result,
|
||||
int addressSetID)
|
||||
public ResultWindow(List<KasPerson> result, int addressSetID)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = this;
|
||||
|
||||
ur_result = result;
|
||||
|
||||
Load(result);
|
||||
}
|
||||
|
||||
private void GenerateView(List<KasPerson> result)
|
||||
{
|
||||
//public List<ResultItem> Results { get; private set; } = new();
|
||||
private void GenerateView(List<KasPerson> result) {
|
||||
try
|
||||
{
|
||||
// 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";
|
||||
|
||||
LbResults.Items.Clear();
|
||||
foreach (var person in result_with_errors) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
//LbResults.Items.Clear();
|
||||
// foreach (var person in result_with_errors)
|
||||
// LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
Results = result_with_errors
|
||||
.Select(person => new ResultItem
|
||||
{
|
||||
Person = person,
|
||||
PersonId = person.id,
|
||||
Name = $"{person.vorname} {person.name}".Trim(),
|
||||
Errors = string.Join(", ", person.PersonError.errors),
|
||||
Warnings = string.Join(", ", person.PersonError.warnings),
|
||||
Refsid = person.refsid.ToString() ?? ""
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Error while generating result view: " + ex.Message, Logger.LogType.Warning);
|
||||
}
|
||||
Logger.Log("Error while generating result view: " + ex.Message, Logger.LogType.Warning);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ViewSingle(int id)
|
||||
@@ -179,8 +216,9 @@ public partial class ResultWindow : Window
|
||||
|
||||
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
||||
|
||||
LbResults.Items.Clear();
|
||||
foreach (var person in temp_result) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
//LbResults.Items.Clear();
|
||||
GenerateView(temp_result);
|
||||
//foreach (var person in temp_result) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
|
||||
} catch (Exception ex)
|
||||
{
|
||||
@@ -200,4 +238,19 @@ public partial class ResultWindow : Window
|
||||
Console.WriteLine("Updating filter...");
|
||||
UpdateFilter();
|
||||
}
|
||||
}
|
||||
//public ObservableCollection<ResultItem> Results { get; } = new();
|
||||
}
|
||||
public class ResultItem
|
||||
{
|
||||
public int PersonId { get; init; }
|
||||
|
||||
public string Name { get; init; } = "";
|
||||
|
||||
public string Errors { get; init; } = "";
|
||||
|
||||
public string Warnings { get; init; } = "";
|
||||
|
||||
public string Refsid { get; init; } = "";
|
||||
|
||||
public KasPerson Person { get; init; } = null!;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user