1- using System . Windows . Input ;
2-
31namespace Codebreaker . MAUI . Views . Components ;
42
53public partial class GameResultDisplay : ContentView
64{
75 public GameResultDisplay ( )
86 {
97 InitializeComponent ( ) ;
10- BindingContext = this ;
11- }
12-
13- public GameMode GameMode
14- {
15- get => ( GameMode ) GetValue ( GameModeProperty ) ;
16- set => SetValue ( GameModeProperty , value ) ;
17- }
18-
19- public static readonly BindableProperty GameModeProperty =
20- BindableProperty . Create ( nameof ( GameMode ) , typeof ( GameMode ) , typeof ( GameResultDisplay ) , GameMode . NotRunning ) ;
21-
22- public ICommand ? LostCommand
23- {
24- get => ( ICommand ? ) GetValue ( LostCommandProperty ) ;
25- set => SetValue ( LostCommandProperty , value ) ;
26- }
27-
28- public static readonly BindableProperty LostCommandProperty =
29- BindableProperty . Create ( nameof ( LostCommand ) , typeof ( ICommand ) , typeof ( GameResultDisplay ) , propertyChanged : OnLostCommandPropertyChanged ) ;
30-
31- public bool IsLostButtonVisible => LostCommand is not null ;
32-
33- public ICommand ? WonCommand
34- {
35- get => ( ICommand ? ) GetValue ( WonCommandProperty ) ;
36- set => SetValue ( WonCommandProperty , value ) ;
37- }
38-
39- public static readonly BindableProperty WonCommandProperty =
40- BindableProperty . Create ( nameof ( LostCommand ) , typeof ( ICommand ) , typeof ( GameResultDisplay ) , propertyChanged : OnWonCommandPropertyChanged ) ;
41-
42- public bool IsWonButtonVisible => WonCommand is not null ;
43-
44- private static void OnWonCommandPropertyChanged ( BindableObject bindable , object oldValue , object newValue )
45- {
46- var that = ( GameResultDisplay ) bindable ;
47- that . OnPropertyChanged ( nameof ( WonCommand ) ) ;
48- that . OnPropertyChanged ( nameof ( IsWonButtonVisible ) ) ;
49- }
50-
51- private static void OnLostCommandPropertyChanged ( BindableObject bindable , object oldValue , object newValue )
52- {
53- var that = ( GameResultDisplay ) bindable ;
54- that . OnPropertyChanged ( nameof ( LostCommand ) ) ;
55- that . OnPropertyChanged ( nameof ( IsLostButtonVisible ) ) ;
568 }
579}
0 commit comments