2121
2222#if WINFORM || ANDROID
2323using RGFloat = System . Single ;
24+ using RGPoint = unvell . ReoGrid . Graphics . Point ;
2425#elif WPF
2526using RGFloat = System . Double ;
27+ using RGPoint = unvell . ReoGrid . Graphics . Point ;
28+ using System . Windows . Controls ;
2629#elif iOS
2730using RGFloat = System . Double ;
2831#endif // WINFORM
@@ -110,25 +113,25 @@ public void Apply()
110113 if ( columnHeader == null ) { c ++ ; continue ; }
111114
112115 var columnFilterBody = columnHeader . Body as AutoColumnFilterBody ;
113- if ( columnFilterBody == null || columnFilterBody . IsSelectAll )
116+ if ( columnFilterBody == null || columnFilterBody . IsSelectAll == true )
114117 {
115118 c ++ ; continue ;
116119 }
117120
118121 var cell = this . Worksheet . GetCell ( r , c ) ;
119- if ( cell == null ) { c ++ ; continue ; }
122+ // if (cell == null) { c++; continue; }
120123
121- var text = cell . DisplayText ;
122- if ( string . IsNullOrEmpty ( text ) ) text = LanguageResource . Filter_Blanks ;
124+ var text = cell == null ? string . Empty : cell . DisplayText ;
125+ if ( string . IsNullOrEmpty ( text ) ) text = LanguageResource . Filter_Blanks ;
123126
124127 if ( ! columnFilterBody . SelectedTextItems . Contains ( text ) )
125128 {
126129 // hide the row
127130 return false ;
128131 }
129132
130- c += cell . Colspan ;
131- }
133+ c += cell == null ? 1 : cell . Colspan ;
134+ }
132135
133136 // show the row
134137 return true ;
@@ -245,23 +248,29 @@ public void OnPaint(CellDrawingContext dc, Size headerSize)
245248 {
246249 Rectangle bounds = GetColumnFilterButtonRect ( headerSize ) ;
247250
248- SolidColor color1 = controlStyle . GetColHeadStartColor ( isHover : false , isInvalid : false ,
249- isSelected : IsDropdown , isFullSelected : false ) ;
251+ SolidColor color1 = controlStyle . GetColHeadStartColor ( isHover : false , isInvalid : false ,
252+ isSelected : IsDropdown , isFullSelected : ! ( IsSelectAll == true ) ) ;
250253
251- SolidColor color2 = controlStyle . GetColHeadEndColor ( isHover : false , isInvalid : false ,
252- isSelected : IsDropdown , isFullSelected : false ) ;
254+ SolidColor color2 = controlStyle . GetColHeadEndColor ( isHover : false , isInvalid : false ,
255+ isSelected : IsDropdown , isFullSelected : ! ( IsSelectAll == true ) ) ;
253256
254- var g = dc . Graphics ;
257+ var g = dc . Graphics ;
255258
256259 g . FillRectangleLinear ( color1 , color2 , 90f , bounds ) ;
257260
258261 g . DrawRectangle ( bounds , unvell . ReoGrid . Rendering . StaticResources . SystemColor_ControlDark ) ;
259262
260- unvell . Common . GraphicsToolkit . FillTriangle ( dc . Graphics . PlatformGraphics ,
261- Math . Min ( 7 * dc . Worksheet . renderScaleFactor , 7.0f ) ,
262- new Point ( bounds . X + bounds . Width / 2 , bounds . Y + bounds . Height / 2 ) ,
263- unvell . Common . GraphicsToolkit . TriangleDirection . Down ) ;
264- }
263+ if ( IsSelectAll == true )
264+ Common . GraphicsToolkit . FillTriangle ( dc . Graphics . PlatformGraphics ,
265+ Math . Min ( 7 * dc . Worksheet . renderScaleFactor , 7.0f ) ,
266+ new Point ( bounds . X + bounds . Width / 2 , bounds . Y + bounds . Height / 2 ) ,
267+ Common . GraphicsToolkit . TriangleDirection . Down ) ;
268+ else
269+ Common . GraphicsToolkit . FillTriangle ( dc . Graphics . PlatformGraphics ,
270+ Math . Min ( 7 * dc . Worksheet . renderScaleFactor , 7.0f ) ,
271+ new Point ( bounds . X + bounds . Width / 2 , bounds . Y + bounds . Height / 2 ) ,
272+ Common . GraphicsToolkit . TriangleDirection . DownFilter ) ;
273+ }
265274 }
266275
267276 /// <summary>
@@ -332,16 +341,19 @@ internal Rectangle GetColumnFilterButtonRect(Size size)
332341 /// </summary>
333342 public System . Windows . Forms . ContextMenuStrip ContextMenuStrip { get ; set ; }
334343#elif WPF
335-
344+ /// <summary>
345+ /// Get or set the context menu of column filter.
346+ /// </summary>
347+ public ContextMenu ContextMenuStrip { get ; set ; }
336348#endif
337349
338- internal List < string > selectedTextItems = new List < string > ( ) ;
350+ internal List < string > selectedTextItems = new List < string > ( ) ;
339351
340352 /// <summary>
341353 /// Get or set whether or not this column is marked as SelectAll.
342354 /// The column is marked as SelectAll will be ignored during filter.
343355 /// </summary>
344- public bool IsSelectAll { get ; set ; }
356+ public bool ? IsSelectAll { get ; set ; }
345357
346358 private TextFilterCollection textItemsCollection ;
347359
@@ -421,7 +433,7 @@ public void Add(string item)
421433 if ( ! this . columnFilter . selectedTextItems . Contains ( item ) )
422434 {
423435 this . columnFilter . selectedTextItems . Add ( item ) ;
424- this . columnFilter . IsSelectAll = false ;
436+ // this.columnFilter.IsSelectAll = false;
425437 }
426438 }
427439
@@ -431,7 +443,7 @@ public void Add(string item)
431443 public void Clear ( )
432444 {
433445 this . columnFilter . selectedTextItems . Clear ( ) ;
434- columnFilter . IsSelectAll = false ;
446+ // columnFilter.IsSelectAll = false;
435447 }
436448
437449 /// <summary>
@@ -477,7 +489,7 @@ public bool IsReadOnly
477489 /// <returns>true if item exist and has been removed successfully</returns>
478490 public bool Remove ( string item )
479491 {
480- this . columnFilter . IsSelectAll = false ;
492+ // this.columnFilter.IsSelectAll = false;
481493 return this . columnFilter . selectedTextItems . Remove ( item ) ;
482494 }
483495
@@ -488,7 +500,7 @@ public bool Remove(string item)
488500 public void AddRange ( IEnumerable < string > items )
489501 {
490502 this . columnFilter . selectedTextItems . AddRange ( items ) ;
491- this . columnFilter . IsSelectAll = false ;
503+ // this.columnFilter.IsSelectAll = false;
492504 }
493505 }
494506 #endregion // TextFilterCollection
@@ -506,11 +518,11 @@ public List<string> GetDistinctItems()
506518 int maxRow = this . ColumnHeader . Worksheet . MaxContentRow ;
507519
508520 this . ColumnHeader . Worksheet . IterateCells ( this . autoFilter . ApplyRange . Row ,
509- this . ColumnHeader . Index , this . autoFilter . ApplyRange . Rows , 1 , true ,
521+ this . ColumnHeader . Index , this . autoFilter . ApplyRange . Rows , 1 , false ,
510522 ( r , c , cell ) =>
511- {
512- var str = cell . DisplayText ;
513- if ( string . IsNullOrEmpty ( str ) ) str = LanguageResource . Filter_Blanks ;
523+ {
524+ var str = cell == null ? string . Empty : cell . DisplayText ;
525+ if ( string . IsNullOrEmpty ( str ) ) str = LanguageResource . Filter_Blanks ;
514526
515527 if ( ! items . Contains ( str ) )
516528 {
@@ -544,7 +556,7 @@ public void OnDataChange(int startRow, int endRow)
544556 /// </summary>
545557 public event EventHandler FilterButtonPressed ;
546558
547- internal bool RaiseFilterButtonPress ( AutoColumnFilterBody headerBody , Point point )
559+ internal bool RaiseFilterButtonPress ( AutoColumnFilterBody headerBody , RGPoint point )
548560 {
549561 if ( headerBody . ColumnHeader == null ) return false ;
550562
@@ -562,11 +574,9 @@ internal bool RaiseFilterButtonPress(AutoColumnFilterBody headerBody, Point poin
562574#if WINFORM
563575 unvell . ReoGrid . WinForm . ColumnFilterContextMenu . ShowFilterPanel ( headerBody , ( System . Drawing . Point ) point ) ;
564576#elif WPF
565- var ctx = new System . Windows . Controls . ContextMenu ( ) ;
566- ctx . Items . Add ( new System . Windows . Controls . MenuItem ( ) { Header = "Item" } ) ;
567- ctx . IsOpen = true ;
577+ unvell . ReoGrid . WPF . ColumnFilterContextMenu . ShowFilterPanel ( headerBody , point ) ;
568578#endif // WPF
569- return true ;
579+ return true ;
570580 }
571581
572582 return false ;
0 commit comments