Skip to content

Commit c4d487b

Browse files
committed
Finalizing changes. There are issued that need fixing before versioning an nuget release
1 parent 47bba8e commit c4d487b

File tree

10 files changed

+722
-524
lines changed

10 files changed

+722
-524
lines changed

SimpleDataGrid.Example/AdvancedExamplesViewModel.cs

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using SimpleDataGrid.Pagination;
2-
using System;
3-
using System.Collections.Generic;
42
using System.ComponentModel;
5-
using System.Linq;
6-
using System.IO;
7-
using System.Reflection;
83

94
namespace SimpleDataGrid.Example;
105

@@ -45,41 +40,24 @@ private static List<Person> GetPeople()
4540
return people;
4641
}
4742

48-
public void ApplyFilter(int minAge)
49-
{
50-
People.SetFilter("minAge", p => p.Age >= minAge);
51-
}
43+
public void ApplyFilter(int minAge) => People.SetFilter("minAge", p => p.Age >= minAge);
5244

53-
public void ApplyMaxAgeFilter(int maxAge)
54-
{
55-
People.SetFilter("maxAge", p => p.Age <= maxAge);
56-
}
45+
public void ApplyMaxAgeFilter(int maxAge) => People.SetFilter("maxAge", p => p.Age <= maxAge);
5746

58-
public void ApplyNameFilter(string namePrefix)
59-
{
60-
People.SetFilter("namePrefix", p => p.Name.StartsWith(namePrefix, StringComparison.OrdinalIgnoreCase));
61-
}
47+
public void ApplyNameFilter(string namePrefix) => People.SetFilter("namePrefix", p => p.Name.StartsWith(namePrefix, StringComparison.OrdinalIgnoreCase));
6248

63-
public void RemoveFilter(string key)
64-
{
65-
People.RemoveFilter(key);
66-
}
49+
public void RemoveFilter(string key) => People.RemoveFilter(key);
6750

6851
public IReadOnlyCollection<string> ActiveFilters => People.GetActiveFilters();
6952

7053
public string CustomFilterExpression { get; set; } = "Age > 30 && Name.Contains(\"Person 1\")";
7154

72-
public void ClearFilter()
73-
{
74-
People.ClearFilters();
75-
}
55+
public void ClearFilter() => People.ClearFilters();
7656

77-
public void ApplyCustomFilter()
78-
{
57+
public void ApplyCustomFilter() =>
7958
// This is a placeholder. A real implementation would parse the CustomFilterExpression
8059
// and create a Func<Person, bool> from it.
8160
People.SetFilter("customFilter", p => p.Age > 30);
82-
}
8361

8462
public void ExportCurrentPageToCsv()
8563
{
@@ -90,13 +68,13 @@ public void ExportCurrentPageToCsv()
9068

9169
// Add header row
9270
var headers = typeof(Person).GetProperties().Select(p => p.Name);
93-
csv.AppendLine(string.Join(",", headers));
71+
csv.AppendJoin(",", headers).AppendLine();
9472

9573
// Add data rows
96-
foreach (Person item in items)
74+
foreach (var item in items)
9775
{
9876
var fields = typeof(Person).GetProperties().Select(p => p.GetValue(item)?.ToString() ?? string.Empty);
99-
csv.AppendLine(string.Join(",", fields));
77+
csv.AppendJoin(",", fields).AppendLine();
10078
}
10179

10280
var filePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "CurrentPage.csv");
@@ -105,8 +83,5 @@ public void ExportCurrentPageToCsv()
10583
}
10684

10785
public event PropertyChangedEventHandler? PropertyChanged;
108-
protected virtual void OnPropertyChanged(string propertyName)
109-
{
110-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
111-
}
86+
protected virtual void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
11287
}

SimpleDataGrid.Example/AdvancedExamplesWindow.xaml.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
using SimpleDataGrid.Controls;
2-
using System;
3-
using System.Collections.Generic;
41
using System.Windows;
52
using System.Windows.Controls;
63

74
namespace SimpleDataGrid.Example;
85

96
public partial class AdvancedExamplesWindow : Window
107
{
11-
public AdvancedExamplesWindow()
12-
{
13-
InitializeComponent();
14-
}
8+
public AdvancedExamplesWindow() => InitializeComponent();
159

1610
private void PreviousButton_Click(object sender, RoutedEventArgs e)
1711
{
@@ -25,15 +19,9 @@ private void NextButton_Click(object sender, RoutedEventArgs e)
2519
viewModel.People.NextPage();
2620
}
2721

28-
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e)
29-
{
30-
ApplyMultiColumnSearch();
31-
}
22+
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) => ApplyMultiColumnSearch();
3223

33-
private void SearchOption_Changed(object sender, RoutedEventArgs e)
34-
{
35-
ApplyMultiColumnSearch();
36-
}
24+
private void SearchOption_Changed(object sender, RoutedEventArgs e) => ApplyMultiColumnSearch();
3725

3826
private void ApplyMultiColumnSearch()
3927
{
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
using System;
21
using System.Globalization;
32
using System.Windows.Data;
43

5-
namespace SimpleDataGrid.Example.Converters
4+
namespace SimpleDataGrid.Example.Converters;
5+
6+
public class ItemCountConverter : IMultiValueConverter
67
{
7-
public class ItemCountConverter : IMultiValueConverter
8+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
89
{
9-
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
10+
if (values.Length == 4 && values[0] is int count && values[1] is int page && values[2] is int total && values[3] is int pageSize)
1011
{
11-
if (values.Length == 4 && values[0] is int count && values[1] is int page && values[2] is int total && values[3] is int pageSize)
12-
{
13-
var start = (page - 1) * pageSize + 1;
14-
var end = start + count - 1;
15-
return $"Showing items {start}-{end} of {total}";
16-
}
17-
return string.Empty;
18-
}
19-
20-
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
21-
{
22-
throw new NotImplementedException();
12+
var start = ((page - 1) * pageSize) + 1;
13+
var end = start + count - 1;
14+
return $"Showing items {start}-{end} of {total}";
2315
}
16+
return string.Empty;
2417
}
18+
19+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) => throw new NotImplementedException();
2520
}

SimpleDataGrid.Example/MainViewModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using SimpleDataGrid.Pagination;
2-
using System;
3-
using System.Collections.Generic;
42

53
namespace SimpleDataGrid.Example;
64

SimpleDataGrid.Example/MainWindow.xaml.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using SimpleDataGrid.Controls;
2-
using System;
3-
using System.Collections.Generic;
41
using System.Windows;
52
using System.Windows.Controls;
63

0 commit comments

Comments
 (0)