1- using System . Globalization ;
2- using System . Windows . Data ;
3- using System . Windows . Media ;
4-
5- using static CodeBreaker . Shared . Models . Data . Colors ;
6-
7- namespace CodeBreaker . WPF . Converters ;
1+ namespace Codebreaker . WPF . Converters ;
82
93public class ColorNameToBrushConverter : IValueConverter
104{
11- private static readonly Brush s_blackBrush = new SolidColorBrush ( Colors . Black ) ;
12- private static readonly Brush s_whiteBrush = new SolidColorBrush ( Colors . White ) ;
5+ private static readonly Brush s_orangeBrush = new SolidColorBrush ( Colors . Orange ) ;
6+ private static readonly Brush s_PurpleBrush = new SolidColorBrush ( Colors . Purple ) ;
137 private static readonly Brush s_redBrush = new SolidColorBrush ( Color . FromRgb ( 209 , 52 , 56 ) ) ;
148 private static readonly Brush s_greenBrush = new SolidColorBrush ( Color . FromRgb ( 0 , 173 , 86 ) ) ;
159 private static readonly Brush s_blueBrush = new SolidColorBrush ( Color . FromRgb ( 79 , 107 , 237 ) ) ;
1610 private static readonly Brush s_yellowBrush = new SolidColorBrush ( Color . FromRgb ( 252 , 225 , 0 ) ) ;
1711 private static readonly Brush s_emptyBrush = new SolidColorBrush ( Color . FromRgb ( 160 , 174 , 178 ) ) ;
1812
19- public Brush BlackBrush { get ; set ; } = s_blackBrush ;
20- public Brush WhiteBrush { get ; set ; } = s_whiteBrush ;
13+ public Brush OrangeBrush { get ; set ; } = s_orangeBrush ;
14+ public Brush PurpleBrush { get ; set ; } = s_PurpleBrush ;
2115 public Brush RedBrush { get ; set ; } = s_redBrush ;
2216 public Brush GreenBrush { get ; set ; } = s_greenBrush ;
2317 public Brush BlueBrush { get ; set ; } = s_blueBrush ;
@@ -26,14 +20,15 @@ public class ColorNameToBrushConverter : IValueConverter
2620
2721 public object ? Convert ( object value , Type targetType , object parameter , CultureInfo culture )
2822 {
23+
2924 return value switch
3025 {
31- Black => BlackBrush ,
32- White => WhiteBrush ,
33- Red => RedBrush ,
34- Green => GreenBrush ,
35- Blue => BlueBrush ,
36- Yellow => YellowBrush ,
26+ "Purple" => OrangeBrush ,
27+ "Orange" => PurpleBrush ,
28+ " Red" => RedBrush ,
29+ " Green" => GreenBrush ,
30+ " Blue" => BlueBrush ,
31+ " Yellow" => YellowBrush ,
3732 _ => EmptyBrush
3833 } ;
3934 }
0 commit comments