push sb view
continuous-integration/drone/push Build is failing Details

test_old_branch
Jérémy Mouyon 11 months ago
parent 6067b0e54b
commit 0437e4a184

@ -8,13 +8,13 @@
<VerticalStackLayout MaximumWidthRequest="200" Background="Transparent"> <VerticalStackLayout MaximumWidthRequest="200" Background="Transparent">
<CollectionView ItemsSource="{Binding NamesPlayers}"> <CollectionView ItemsSource="{Binding ScoreboardList}">
<CollectionView.ItemsLayout> <CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/> <GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout> </CollectionView.ItemsLayout>
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<controls:ScoreboardLine Nameplayer="{Binding NameTag}"></controls:ScoreboardLine> <controls:ScoreboardLine Nameplayer="{Binding Key.NameTag}"></controls:ScoreboardLine>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>

@ -1,4 +1,6 @@
using QwirkleClassLibrary.Players; using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Boards;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
@ -6,43 +8,39 @@ namespace Qwirkle.Views;
public partial class Scoreboard : ContentView, INotifyPropertyChanged public partial class Scoreboard : ContentView, INotifyPropertyChanged
{ {
private IOrderedEnumerable<KeyValuePair<Player, int>> scoreboard; private Game game = ((App)Application.Current!).Game;
private Dictionary<Player, int> currentScoreBoard;
private List<Player> namesPlayers; private IOrderedEnumerable<KeyValuePair<string, int>> scoreboard;
public List<Player> NamesPlayers
private ObservableCollection<KeyValuePair<string, int>> scoreboardList;
public ObservableCollection<KeyValuePair<string, int>> ScoreboardList
{ {
get => namesPlayers; get => scoreboardList;
set set
{ {
if (namesPlayers != value) if (scoreboardList != value)
{ {
namesPlayers = value; scoreboardList = value;
OnPropertyChanged(nameof(NamesPlayers)); OnPropertyChanged(nameof(ScoreboardList));
} }
} }
} }
public Scoreboard() public Scoreboard()
{ {
InitializeComponent(); InitializeComponent();
BindingContext = this; BindingContext = this;
scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag); scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
currentScoreBoard = scoreboard.ToDictionary<Player, int>(); ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(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) private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{ {
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag); ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
currentScoreBoard = scoreboard.ToDictionary<Player, int>();
NamesPlayers = currentScoreBoard.Keys.ToList();
} }
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
@ -51,7 +49,4 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
} }
Loading…
Cancel
Save