From 0437e4a184d2bfaa6257c4ee12fa7f5b033abc0d Mon Sep 17 00:00:00 2001 From: "jeremy.mouyon" Date: Tue, 4 Jun 2024 11:15:31 +0200 Subject: [PATCH] push sb view --- Qwirkle/QwirkleViews/Views/Scoreboard.xaml | 4 +- Qwirkle/QwirkleViews/Views/Scoreboard.xaml.cs | 43 ++++++++----------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/Qwirkle/QwirkleViews/Views/Scoreboard.xaml b/Qwirkle/QwirkleViews/Views/Scoreboard.xaml index 1982d53..1bc0c8d 100644 --- a/Qwirkle/QwirkleViews/Views/Scoreboard.xaml +++ b/Qwirkle/QwirkleViews/Views/Scoreboard.xaml @@ -8,13 +8,13 @@ - + - + diff --git a/Qwirkle/QwirkleViews/Views/Scoreboard.xaml.cs b/Qwirkle/QwirkleViews/Views/Scoreboard.xaml.cs index 7aa9b84..82d3f81 100644 --- a/Qwirkle/QwirkleViews/Views/Scoreboard.xaml.cs +++ b/Qwirkle/QwirkleViews/Views/Scoreboard.xaml.cs @@ -1,4 +1,6 @@ using QwirkleClassLibrary.Players; +using QwirkleClassLibrary.Games; +using QwirkleClassLibrary.Boards; using System.Collections.ObjectModel; using System.ComponentModel; @@ -6,43 +8,39 @@ namespace Qwirkle.Views; public partial class Scoreboard : ContentView, INotifyPropertyChanged { - private IOrderedEnumerable> scoreboard; - private Dictionary currentScoreBoard; + private Game game = ((App)Application.Current!).Game; - private List namesPlayers; - public List NamesPlayers + private IOrderedEnumerable> scoreboard; + + private ObservableCollection> scoreboardList; + public ObservableCollection> ScoreboardList { - get => namesPlayers; + get => scoreboardList; set { - if (namesPlayers != value) + if (scoreboardList != value) { - namesPlayers = value; - OnPropertyChanged(nameof(NamesPlayers)); + scoreboardList = value; + OnPropertyChanged(nameof(ScoreboardList)); } } } + public Scoreboard() - { - InitializeComponent(); + { + InitializeComponent(); BindingContext = this; - scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag); - currentScoreBoard = scoreboard.ToDictionary(); + scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key); + ScoreboardList = new ObservableCollection>(scoreboard); - NamesPlayers = currentScoreBoard.Keys.ToList(); - - ((App)Application.Current!).Game.Board.PropertyChanged += Board_PropertyChanged; + game.Board.PropertyChanged += Board_PropertyChanged; } private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { - - scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag); - currentScoreBoard = scoreboard.ToDictionary(); - - NamesPlayers = currentScoreBoard.Keys.ToList(); - + scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag); + ScoreboardList = new ObservableCollection>(scoreboard); } public event PropertyChangedEventHandler? PropertyChanged; @@ -51,7 +49,4 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } - - - } \ No newline at end of file