Fin de la navigation

master
Céleste BARBOSA 11 months ago
parent 02cbd161a7
commit b8b3153c3a

@ -13,7 +13,7 @@
/// <summary>
/// Le nombre maximum de tour.
/// </summary>
public int TourMaximum { get => 12; }
public int TourMaximum { get => 2; }
/// <summary>
/// La taille maximale d'un code.

@ -73,9 +73,6 @@
<MauiXaml Update="Pages\ConnexionPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Defaite.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Pages\Egaliter.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiSpark.Pages.Defaite"
xmlns:pages="clr-namespace:MauiSpark.Pages"
Title="Defaite">
<VerticalStackLayout >
<FlexLayout Direction="Row" JustifyContent="SpaceAround" AlignContent="Center" VerticalOptions="Center" Margin="10">
<Image Source="defaite.png" MaximumHeightRequest="100" MaximumWidthRequest="100" />
<Frame HorizontalOptions="Center" VerticalOptions="Center" Style="{StaticResource FrameTitrePage}" >
<Label Text="Defaite" Style="{StaticResource TexteTitre}"/>
</Frame>
<Image Source="defaite.png" MaximumHeightRequest="100" MaximumWidthRequest="100"/>
</FlexLayout>
<Frame Margin="20">
<Label HorizontalOptions="Center" Text="{Binding}" Style="{StaticResource TexteFrame}"/>
</Frame>
<Button Text="Menu" VerticalOptions="End" HorizontalOptions="Center"></Button>
</VerticalStackLayout>
</ContentPage>

@ -1,14 +0,0 @@
using CoreLibrary;
using CoreLibrary.Events;
namespace MauiSpark.Pages;
public partial class Defaite : ContentPage
{
public Defaite(Partie p, PartieTermineeEventArgs e)
{
InitializeComponent();
BindingContext = $"Aucun des deux joueurs, {e.Perdants.First().Nom} et {e.Perdants.Last().Nom} n'a trouvé le code secret";
}
}

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiSpark.Pages.Egalite"
xmlns:pages="clr-namespace:MauiSpark.Pages"
Title="Egalite">
<VerticalStackLayout>
<FlexLayout Direction="Row" JustifyContent="SpaceAround" AlignContent="Center" VerticalOptions="Center" Margin="10">
<Image Source="egaliter.jpg" MaximumHeightRequest="100" MaximumWidthRequest="100" />
<Frame HorizontalOptions="Center" VerticalOptions="Center" Style="{StaticResource FrameTitrePage}">
<Label Text="Egaliter" Style="{StaticResource TexteTitre}"/>
</Frame>
<Image Source="egaliter.jpg" MaximumHeightRequest="100" MaximumWidthRequest="100"/>
</FlexLayout>
<Frame Margin="20">
<Label HorizontalOptions="Center" Text="Les deux joueur ont trouvé en même temps" Style="{StaticResource TexteFrame}"/>
</Frame>
<Button Text="Menu" VerticalOptions="End" HorizontalOptions="Center"></Button>
</VerticalStackLayout>
</ContentPage>

@ -1,9 +0,0 @@
namespace MauiSpark.Pages;
public partial class Egalite : ContentPage
{
public Egalite()
{
InitializeComponent();
}
}

@ -1,4 +1,5 @@
using CoreLibrary;
using CoreLibrary.Events;
using CoreLibrary.Regles;
namespace MauiSpark.Pages;
@ -18,6 +19,7 @@ public partial class Mode : ContentPage
partie.DemanderNom += new ConnexionPage().QuandDemanderNom;
partie.NouveauTour += new Plateau().QuandNouveauTour;
partie.PartieTerminee += new Victoire().QuandPartieTerminee;
partie.Jouer();
}

@ -40,26 +40,27 @@ public partial class Plateau : ContentPage
public Plateau()
{
NavigationPage.SetHasNavigationBar(this, false);
NavigationPage.SetHasBackButton(this, true);
NavigationPage.SetBackButtonTitle(this, "Retour");
InitializeComponent();
}
public async void QuandNouveauTour(object? sender, NouveauTourEventArgs e)
{
if (Application.Current != null && Application.Current.MainPage != null && ((NavigationPage)Application.Current.MainPage).CurrentPage != this)
{
IEnumerable<Page> pages = Application.Current.MainPage.Navigation.NavigationStack.Reverse();
if (Application.Current == null || Application.Current.MainPage == null)
return;
foreach(Page page in pages)
{
if (page is Accueil)
break;
if (((NavigationPage)Application.Current!.MainPage).CurrentPage != this)
await Application.Current.MainPage.Navigation.PushAsync(this);
Application.Current.MainPage.Navigation.RemovePage(page);
}
IEnumerable<Page> pages = Application.Current.MainPage.Navigation.NavigationStack.Reverse().Skip(1);
await Application.Current.MainPage.Navigation.PushAsync(this);
foreach (Page page in pages)
{
if (page is Accueil)
break;
Application.Current.MainPage.Navigation.RemovePage(page);
}
code = e.Code;

@ -8,13 +8,13 @@
<FlexLayout Direction="Row" JustifyContent="SpaceAround" AlignContent="Center" VerticalOptions="Center" Margin="10">
<Image Source="trophy.jpg" MaximumHeightRequest="100" MaximumWidthRequest="100" />
<Frame HorizontalOptions="Center" VerticalOptions="Center" Style="{StaticResource FrameTitrePage}">
<Label Text="Victoire" Style="{StaticResource TexteTitre}"></Label>
<Label Text="{Binding [0]}" Style="{StaticResource TexteTitre}"></Label>
</Frame>
<Image Source="trophy.jpg" MaximumHeightRequest="100" MaximumWidthRequest="100"/>
</FlexLayout>
<Frame Margin="20" >
<Label HorizontalOptions="Center" Text="{Binding}" Style="{StaticResource TexteFrame}"/>
<Label HorizontalOptions="Center" Text="{Binding [1]}" Style="{StaticResource TexteFrame}"/>
</Frame>
<Button Text="Menu" VerticalOptions="End" HorizontalOptions="Center"></Button>
<Button Text="Menu" VerticalOptions="End" HorizontalOptions="Center" Clicked="QuandMenuPresse"></Button>
</VerticalStackLayout>
</ContentPage>

@ -1,14 +1,45 @@
using CoreLibrary;
using CoreLibrary.Events;
namespace MauiSpark.Pages;
public partial class Victoire : ContentPage
{
public Victoire(Partie partie, PartieTermineeEventArgs e)
{
InitializeComponent();
BindingContext = $"Le joueur {e.Gagnants.First().Nom} a gagné";
}
using CoreLibrary;
using CoreLibrary.Events;
namespace MauiSpark.Pages;
public partial class Victoire : ContentPage
{
public Victoire()
{
NavigationPage.SetHasNavigationBar(this, false);
InitializeComponent();
}
public async void QuandPartieTerminee(object? sender, PartieTermineeEventArgs e)
{
if (Application.Current == null || Application.Current.MainPage == null)
return;
if (((NavigationPage)Application.Current.MainPage).CurrentPage != this)
await Application.Current.MainPage.Navigation.PushAsync(this);
IEnumerable<Page> pages = Application.Current.MainPage.Navigation.NavigationStack.Reverse().Skip(1);
foreach (Page page in pages)
{
if (page is Accueil)
break;
Application.Current.MainPage.Navigation.RemovePage(page);
}
if(e.Gagnants.Count() == 1)
BindingContext = ("Victoire", $"Le joueur {e.Gagnants.First().Nom} a gagné");
else if(e.Gagnants.Count() > 1)
BindingContext = ("Egalité", $"Les joueurs {string.Join(' ', e.Gagnants)} ont gagné");
else
BindingContext = ("Défaite", "Personne n'a trouvé le code...");
}
public async void QuandMenuPresse(object sender, EventArgs e)
{
await Navigation.PopAsync();
}
}
Loading…
Cancel
Save