@@ -27,12 +27,11 @@ public class CustomCellDrawer : CustomCellDrawerInteractorBase, ICustomCellDrawe
2727 private static IPen ButtonBackgroundPen = new Pen ( new SolidColorBrush ( Colors . White ) , 0 ) ;
2828 private static IPen ButtonBackgroundHoverPen = new Pen ( new SolidColorBrush ( Color . FromRgb ( 245 , 245 , 245 ) ) , 0 ) ;
2929 private static IPen ButtonBackgroundPressedPen = new Pen ( new SolidColorBrush ( Color . FromRgb ( 215 , 215 , 215 ) ) , 0 ) ;
30-
30+ private static IPen ButtonBackgroundDisabledPen = new Pen ( new SolidColorBrush ( Color . FromRgb ( 170 , 170 , 170 ) ) , 0 ) ;
31+
3132 private Point mouseCursor ;
3233 private bool leftPressed ;
3334
34-
35-
3635 static CustomCellDrawer ( )
3736 {
3837 ModifiedCellPen . GetResource ( "FastTableView.ModifiedCellPen" , ModifiedCellPen , out ModifiedCellPen ) ;
@@ -42,6 +41,7 @@ static CustomCellDrawer()
4241 ButtonBackgroundPen . GetResource ( "FastTableView.ButtonBackgroundPen" , ButtonBackgroundPen , out ButtonBackgroundPen ) ;
4342 ButtonBackgroundHoverPen . GetResource ( "FastTableView.ButtonBackgroundHoverPen" , ButtonBackgroundHoverPen , out ButtonBackgroundHoverPen ) ;
4443 ButtonBackgroundPressedPen . GetResource ( "FastTableView.ButtonBackgroundPressedPen" , ButtonBackgroundPressedPen , out ButtonBackgroundPressedPen ) ;
44+ ButtonBackgroundDisabledPen . GetResource ( "FastTableView.ButtonBackgroundDisabledPen" , ButtonBackgroundDisabledPen , out ButtonBackgroundDisabledPen ) ;
4545 }
4646
4747 public void DrawRow ( DrawingContext context , ITableRow r , Rect rect )
@@ -65,13 +65,13 @@ public bool UpdateCursor(Point point, bool leftPressed)
6565 return true ;
6666 }
6767
68- private void DrawButton ( DrawingContext context , Rect rect , string text , int margin )
68+ private void DrawButton ( DrawingContext context , Rect rect , string text , int margin , bool enabled = true )
6969 {
7070 rect = rect . Deflate ( margin ) ;
7171
7272 bool isOver = rect . Contains ( mouseCursor ) ;
7373
74- context . DrawRectangle ( ( isOver ? ( leftPressed ? ButtonBackgroundPressedPen : ButtonBackgroundHoverPen ) : ButtonBackgroundPen ) . Brush , ButtonBorderPen , rect , 4 , 4 ) ;
74+ context . DrawRectangle ( ( ! enabled ? ButtonBackgroundDisabledPen : isOver ? ( leftPressed ? ButtonBackgroundPressedPen : ButtonBackgroundHoverPen ) : ButtonBackgroundPen ) . Brush , ButtonBorderPen , rect , 4 , 4 ) ;
7575
7676 var state = context . PushClip ( rect ) ;
7777 var ft = new FormattedText
@@ -92,7 +92,7 @@ public bool Draw(DrawingContext context, ref Rect rect, ITableCell c)
9292
9393 if ( cell . ActionCommand != null )
9494 {
95- DrawButton ( context , rect , cell . ActionLabel , 3 ) ;
95+ DrawButton ( context , rect , cell . ActionLabel , 3 , cell . ActionCommand . CanExecute ( null ) ) ;
9696 return true ;
9797 }
9898
0 commit comments