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">
<CollectionView ItemsSource="{Binding NamesPlayers}">
<CollectionView ItemsSource="{Binding ScoreboardList}">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<controls:ScoreboardLine Nameplayer="{Binding NameTag}"></controls:ScoreboardLine>
<controls:ScoreboardLine Nameplayer="{Binding Key.NameTag}"></controls:ScoreboardLine>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

@ -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<KeyValuePair<Player, int>> scoreboard;
private Dictionary<Player, int> currentScoreBoard;
private Game game = ((App)Application.Current!).Game;
private List<Player> namesPlayers;
public List<Player> NamesPlayers
private IOrderedEnumerable<KeyValuePair<string, int>> scoreboard;
private ObservableCollection<KeyValuePair<string, int>> scoreboardList;
public ObservableCollection<KeyValuePair<string, int>> 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<Player, int>();
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
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)
{
scoreboard = ((App)Application.Current!).Game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
currentScoreBoard = scoreboard.ToDictionary<Player, int>();
NamesPlayers = currentScoreBoard.Keys.ToList();
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
}
public event PropertyChangedEventHandler? PropertyChanged;
@ -51,7 +49,4 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Loading…
Cancel
Save