Merge remote-tracking branch 'origin/master'
continuous-integration/drone/push Build is passing Details

test_old_branch
Jules LASCRET 11 months ago
commit fbcce2b5c8

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

@ -3,6 +3,7 @@ using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Boards;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
namespace Qwirkle.Views;
@ -12,10 +13,10 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
private IOrderedEnumerable<KeyValuePair<string, int>> scoreboard;
private ObservableCollection<KeyValuePair<string, int>> scoreboardList;
private ObservableCollection<KeyValuePair<string, int>>? scoreboardList;
public ObservableCollection<KeyValuePair<string, int>> ScoreboardList
{
get => scoreboardList;
get => scoreboardList!;
set
{
if (scoreboardList != value)
@ -34,13 +35,6 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key);
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
game.Board.PropertyChanged += Board_PropertyChanged;
}
private void Board_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
scoreboard = game.ScoreBoard.OrderByDescending(x => x.Value).ThenBy(x => x.Key.NameTag);
ScoreboardList = new ObservableCollection<KeyValuePair<string, int>>(scoreboard);
}
public event PropertyChangedEventHandler? PropertyChanged;
@ -49,4 +43,4 @@ public partial class Scoreboard : ContentView, INotifyPropertyChanged
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -17,12 +17,11 @@
Style="{StaticResource RectangleTab}"
Grid.Column="1"/>
<Label
<Label
Grid.Column="2"
Text="0"
Text="{Binding Score, Source={x:Reference root}}"
Style="{StaticResource ContentTab}"/>
</Grid>
</Grid>
<Rectangle/>
</StackLayout>
</ContentView>

@ -1,38 +1,43 @@
using QwirkleClassLibrary.Games;
using QwirkleClassLibrary.Players;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qwirkle.Views;
public partial class ScoreboardLine : ContentView
{
public ScoreboardLine()
{
InitializeComponent();
BindingContext = this;
}
public static readonly BindableProperty NameplayerProperty =
BindableProperty.Create(nameof(Nameplayer), typeof(string), typeof(ScoreboardLine), default(string), propertyChanged: OnPlayerChanged);
public string Nameplayer
namespace Qwirkle.Views
{
public partial class ScoreboardLine : ContentView
{
get => (string)GetValue(NameplayerProperty);
set => SetValue(NameplayerProperty, value);
}
public static readonly BindableProperty NameplayerProperty =
BindableProperty.Create(nameof(Nameplayer), typeof(string), typeof(ScoreboardLine), default(string), propertyChanged: OnPlayerChanged);
private static void OnPlayerChanged(BindableObject bindable, object oldValue, object newValue)
{
var bin = (ScoreboardLine)bindable;
bin.OnPropertyChanged(nameof(Nameplayer));
public string Nameplayer
{
get => (string)GetValue(NameplayerProperty);
set => SetValue(NameplayerProperty, value);
}
private static void OnPlayerChanged(BindableObject bindable, object oldValue, object newValue)
{
var bin = (ScoreboardLine)bindable;
bin.OnPropertyChanged(nameof(Nameplayer));
}
public static readonly BindableProperty ScoreProperty =
BindableProperty.Create(nameof(Score), typeof(int), typeof(ScoreboardLine), default(int), propertyChanged: OnScoreChanged);
public int Score
{
get => (int)GetValue(ScoreProperty);
set => SetValue(ScoreProperty, value);
}
private static void OnScoreChanged(BindableObject bindable, object oldValue, object newValue)
{
var bin = (ScoreboardLine)bindable;
bin.OnPropertyChanged(nameof(Score));
}
public ScoreboardLine()
{
InitializeComponent();
BindingContext = this;
}
}
}
}

Loading…
Cancel
Save