11using SimpleDataGrid . Pagination ;
2- using System ;
3- using System . Collections . Generic ;
42using System . ComponentModel ;
5- using System . Linq ;
6- using System . IO ;
7- using System . Reflection ;
83
94namespace 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}
0 commit comments