@@ -2,13 +2,13 @@ namespace UnoPongWars.Presentation;
2
2
3
3
public sealed partial class GamePage : Page
4
4
{
5
- private readonly Color UnoBleu = Color . FromArgb ( 255 , 27 , 154 , 249 ) ;
6
- private readonly Color UnoVert = Color . FromArgb ( 255 , 107 , 227 , 173 ) ;
5
+ private readonly Color Blue = Color . FromArgb ( 255 , 27 , 154 , 249 ) ;
6
+ private readonly Color Green = Color . FromArgb ( 255 , 107 , 227 , 173 ) ;
7
7
8
8
public object ViewModel { get ; set ; }
9
9
10
- public Color PlayerColor ( Cell cell ) => cell . Player == 0 ? UnoBleu : UnoVert ;
11
- public Color CellColor ( Cell cell ) => cell . Player == 0 ? UnoVert : UnoBleu ;
10
+ public Color PlayerColor ( Cell cell ) => cell . Player == 0 ? Blue : Green ;
11
+ public Color CellColor ( Cell cell ) => cell . Player == 0 ? Green : Blue ;
12
12
13
13
public GamePage ( )
14
14
{
@@ -18,52 +18,52 @@ public GamePage()
18
18
. Background ( Theme . Brushes . Background . Default )
19
19
. Content (
20
20
new Grid ( )
21
- . Margin ( 20 )
22
- . RowDefinitions ( "*,auto,auto" )
23
- . Children (
24
- new Viewbox ( )
25
- . HorizontalAlignment ( HorizontalAlignment . Center )
26
- . Child (
27
- new ItemsRepeater ( )
28
- . ItemsSource ( ( ) => vm . Cells )
29
- . VerticalAlignment ( VerticalAlignment . Center )
30
- . Width ( 160 )
31
- . Height ( 160 )
32
- . Layout ( new UniformGridLayout ( )
33
- . Orientation ( Orientation . Vertical )
34
- . MaximumRowsOrColumns ( 16 ) )
35
- . ItemTemplate < Cell > ( cell =>
36
- new Grid ( )
37
- . Children (
38
- new Rectangle ( )
39
- . Width ( 10 )
40
- . Height ( 10 )
41
- . Fill ( x => x . Binding ( ( ) => cell )
42
- . Convert ( cell => new SolidColorBrush ( CellColor ( cell ) ) ) ) ,
43
- new Ellipse ( )
44
- . Width ( 10 )
45
- . Height ( 10 )
46
- . Fill ( x => x . Binding ( ( ) => cell )
47
- . Convert ( cell => new SolidColorBrush ( PlayerColor ( cell ) ) ) )
48
- . Visibility ( x => x . Binding ( ( ) => cell )
49
- . Convert ( cell => cell . HasBall ? Visibility . Visible : Visibility . Collapsed ) ) ) ) ) ,
50
- new TextBlock ( )
51
- . Text ( x => x . Binding ( ( ) => vm . Score ) )
21
+ . Margin ( 20 )
22
+ . RowDefinitions ( "*,Auto,Auto" )
23
+ . Children (
24
+ new Viewbox ( )
52
25
. HorizontalAlignment ( HorizontalAlignment . Center )
53
- . Style ( Theme . TextBlock . Styles . HeadlineSmall )
54
- . Margin ( 10 )
55
- . Grid ( row : 1 ) ,
56
- new Slider ( )
57
- . MaxWidth ( 400 )
58
- . Margin ( 16 )
59
- . Maximum ( 1000 )
26
+ . Child (
27
+ new ItemsRepeater ( )
28
+ . ItemsSource ( ( ) => vm . Cells )
29
+ . VerticalAlignment ( VerticalAlignment . Center )
30
+ . Width ( 160 )
31
+ . Height ( 160 )
32
+ . Layout (
33
+ new UniformGridLayout ( )
34
+ . Orientation ( Orientation . Vertical )
35
+ . MaximumRowsOrColumns ( 16 ) )
36
+ . ItemTemplate < Cell > ( cell => CellTemplate ( cell ) ) ) ,
37
+ new TextBlock ( )
38
+ . Text ( ( ) => vm . Score )
39
+ . HorizontalAlignment ( HorizontalAlignment . Center )
40
+ . Style ( Theme . TextBlock . Styles . HeadlineSmall )
41
+ . Margin ( 10 )
42
+ . Grid ( row : 1 ) ,
43
+ new Slider ( )
44
+ . MaxWidth ( 400 )
45
+ . Margin ( 16 )
46
+ . Maximum ( 1000 )
60
47
#if __ANDROID__
61
- . Minimum ( 100 )
48
+ . Minimum ( 100 )
62
49
#else
63
- . Minimum ( 10 )
50
+ . Minimum ( 10 )
64
51
#endif
65
- . Grid ( row : 2 )
66
- . Value ( x => x . Binding ( ( ) => vm . Speed ) . TwoWay ( ) )
52
+ . Grid ( row : 2 )
53
+ . Value ( x => x . Binding ( ( ) => vm . Speed ) . TwoWay ( ) )
67
54
) ) ) ;
68
55
}
56
+
57
+ private Grid CellTemplate ( Cell cell )
58
+ => new Grid ( )
59
+ . Children (
60
+ new Rectangle ( )
61
+ . Width ( 10 )
62
+ . Height ( 10 )
63
+ . Fill ( ( ) => cell , cell => new SolidColorBrush ( CellColor ( cell ) ) ) ,
64
+ new Ellipse ( )
65
+ . Width ( 10 )
66
+ . Height ( 10 )
67
+ . Fill ( ( ) => cell , cell => new SolidColorBrush ( PlayerColor ( cell ) ) )
68
+ . Visibility ( ( ) => cell , cell => cell . HasBall ? Visibility . Visible : Visibility . Collapsed ) ) ;
69
69
}
0 commit comments