Supprimer 'Qwirkle/cm7/cm7_codebehind.cs'
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
52f95f7cb8
commit
bd9aad6ccb
@ -1,80 +0,0 @@
|
|||||||
// Code Behind for PlayerPage
|
|
||||||
|
|
||||||
public partial class PlayerPage : ContentPage
|
|
||||||
{
|
|
||||||
public Manager Mgr { get; set; } = new Manager(new Stub());
|
|
||||||
|
|
||||||
public int PlayerIndex { get; set; } = 0;
|
|
||||||
|
|
||||||
public RankedPlayer RankedPlayer { get; set; }
|
|
||||||
|
|
||||||
public PlayerPage()
|
|
||||||
{
|
|
||||||
Mgr.LoadPlayers();
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
RankedPlayer = new RankedPlayer(Mgr.Players.ElementAt(2), Mgr);
|
|
||||||
BindingContext = RankedPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ButtonClicked(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
PlayerIndex++;
|
|
||||||
RankedPlayer.Player = Mgr.Players.ElementAt(PlayerIndex); // Source's property changed, not the source itself
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class RankedPlayer : INotifyPropertyChanged
|
|
||||||
{
|
|
||||||
public RankedPlayer(Player player, Manager mgr)
|
|
||||||
{
|
|
||||||
Mgr = mgr;
|
|
||||||
Player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Manager Mgr { get; set; }
|
|
||||||
|
|
||||||
public Player thePlayer
|
|
||||||
{
|
|
||||||
get => thePlayer;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if(value == thePlayer) return;
|
|
||||||
thePlayer = value;
|
|
||||||
OnPropertyChanged("ThePlayer");
|
|
||||||
OnPropertyChanged(nameof(Rank));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Player thePlayer;
|
|
||||||
|
|
||||||
public int Rank => Mgr.Players.OrderingByDescending(p => p.Points).ToList().IndexOf(Player) + 1;
|
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
|
||||||
|
|
||||||
public void OnPropertyChanged(string propertyName)
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===============================
|
|
||||||
|
|
||||||
// Code behind for Players Page
|
|
||||||
|
|
||||||
public partial class PlayersPage : ContentPage
|
|
||||||
{
|
|
||||||
public Manager Mgr { get; set; } = new Manager(new Stub());
|
|
||||||
|
|
||||||
public PlayersPage()
|
|
||||||
{
|
|
||||||
Mgr.LoadPlayers();
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
|
|
||||||
BindingContext = Mgr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===============================
|
|
Loading…
Reference in new issue