You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mastermind/Sources/MauiSpark/Pages/ConnexionPage.xaml.cs

57 lines
1.4 KiB

using CoreLibrary.Evenements;
using CoreLibrary.Joueurs;
namespace MauiSpark.Pages;
public partial class ConnexionPage : ContentPage
{
private int? indice;
private Joueur? joueurDemande;
public ConnexionPage()
{
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
}
public async void QuandDemanderNom(Object? sender, PartieDemanderJoueurEventArgs e)
{
if(Application.Current != null && Application.Current.MainPage != null && ((NavigationPage)Application.Current.MainPage).CurrentPage != this)
await Application.Current.MainPage.Navigation.PushAsync(this);
Nom.Text = "";
indice = e.Indice;
joueurDemande = e.JoueurDemande;
BindingContext = $"Joueur {e.Indice}";
}
private void QuandSeConnecterPresse(Object sender, EventArgs e)
{
if (joueurDemande == null || indice == null)
return;
Joueur joueur;
if (string.IsNullOrEmpty(Nom.Text))
{
joueur = new Joueur($"Joueur {indice.Value}");
}
else
{
joueur = MauiProgram.Manageur.DemanderJoueur(Nom.Text);
}
joueurDemande.SeConnecter(joueur);
}
private void QuandRobotPresse(object sender, EventArgs e)
{
if (joueurDemande == null || indice == null)
return;
Robot robot = new Robot();
joueurDemande.SeConnecter(robot);
}
}