diff --git a/source/Trek-12/Models/Game/OperationCell.cs b/source/Trek-12/Models/Game/OperationCell.cs index d8ac6da..c17791d 100644 --- a/source/Trek-12/Models/Game/OperationCell.cs +++ b/source/Trek-12/Models/Game/OperationCell.cs @@ -1,3 +1,5 @@ +using System.ComponentModel; + namespace Models.Game { /// @@ -5,10 +7,20 @@ namespace Models.Game /// public class OperationCell : Position { + + private bool isChecked; /// /// It tells if the operation is checked or not in the operation grid of the game. /// - public bool IsChecked { get; private set; } + public bool IsChecked + { + get => isChecked; + private set + { + isChecked = value; + OnPropertyChanged(nameof(IsChecked)); + } + } /// /// Constructor of the OperationCell class. diff --git a/source/Trek-12/Models/Game/Position.cs b/source/Trek-12/Models/Game/Position.cs index c1b75da..d34ece5 100644 --- a/source/Trek-12/Models/Game/Position.cs +++ b/source/Trek-12/Models/Game/Position.cs @@ -1,10 +1,13 @@ -namespace Models.Game +using System.ComponentModel; +using System.Runtime.CompilerServices; + +namespace Models.Game { /// /// The Position (x,y) of a cell in the game. /// - public class Position + public class Position : INotifyPropertyChanged { /// /// The X coordinate. @@ -26,5 +29,19 @@ X = x; Y = y; } + + /// + /// Event raised when a property is changed to notify the view. + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + /// Trigger the PropertyChanged event for a specific property. + /// + /// Name of the property that changed. + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } \ No newline at end of file