Fin de la page victoire
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
2f571a940d
commit
ce11503157
@ -1,35 +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.Victoire"
|
||||
xmlns:pages="clr-namespace:MauiSpark.Pages"
|
||||
xmlns:vues="clr-namespace:MauiSpark.Vues"
|
||||
Title="Victoire">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="*"
|
||||
RowDefinitions="*, auto, *">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="*, *, *"
|
||||
RowDefinitions="*">
|
||||
|
||||
<vues:ImageResultatVue Image="{Binding [2]}" HorizontalOptions="Start"/>
|
||||
|
||||
<vues:TitreVue Texte="{Binding [0]}" Grid.Column="1"/>
|
||||
|
||||
<vues:ImageResultatVue Image="{Binding [2]}" Grid.Column="2" HorizontalOptions="End"/>
|
||||
</Grid>
|
||||
|
||||
<Frame Grid.Row="1">
|
||||
<Label HorizontalOptions="Center" Text="{Binding [1]}"/>
|
||||
</Frame>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Text="Menu"
|
||||
VerticalOptions="Center"
|
||||
Margin="0, 50"
|
||||
Clicked="QuandMenuPresse"/>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -0,0 +1,42 @@
|
||||
<?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.VictoirePage"
|
||||
xmlns:pages="clr-namespace:MauiSpark.Pages"
|
||||
xmlns:vues="clr-namespace:MauiSpark.Vues"
|
||||
x:Name="victoirePage"
|
||||
Title="VictoirePage">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="*"
|
||||
RowDefinitions="*, auto, *">
|
||||
|
||||
<Grid
|
||||
ColumnDefinitions="*, *, *"
|
||||
RowDefinitions="*">
|
||||
|
||||
<vues:ImageResultatVue Image="{Binding Source={x:Reference victoirePage}, Path=BindingContext.Image}" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
|
||||
<vues:TitreVue Texte="{Binding Source={x:Reference victoirePage}, Path=BindingContext.Titre}" Grid.Column="1" VerticalOptions="Center"/>
|
||||
|
||||
<vues:ImageResultatVue Image="{Binding Source={x:Reference victoirePage}, Path=BindingContext.Image}" Grid.Column="2" HorizontalOptions="Center" VerticalOptions="Center"/>
|
||||
</Grid>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
StrokeThickness="2"
|
||||
StrokeShape="RoundRectangle 10"
|
||||
Margin="20"
|
||||
Padding="20">
|
||||
|
||||
<Label HorizontalOptions="Center" Text="{Binding Texte}"/>
|
||||
</Border>
|
||||
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Text="Menu"
|
||||
VerticalOptions="Center"
|
||||
Margin="0, 50"
|
||||
Clicked="QuandMenuPresse"/>
|
||||
</Grid>
|
||||
</ContentPage>
|
@ -1,48 +1,73 @@
|
||||
using CoreLibrary.Evenements;
|
||||
using CoreLibrary.Joueurs;
|
||||
|
||||
namespace MauiSpark.Pages;
|
||||
|
||||
public partial class Victoire : ContentPage
|
||||
{
|
||||
public Victoire()
|
||||
{
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public async void QuandPartieTerminee(object? sender, PartiePartieTermineeEventArgs 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 AccueilPage)
|
||||
break;
|
||||
|
||||
Application.Current.MainPage.Navigation.RemovePage(page);
|
||||
}
|
||||
|
||||
IReadOnlyList<Joueur> gagnants = e.Gagnants;
|
||||
IReadOnlyList<Joueur> perdants = e.Perdants;
|
||||
|
||||
if (gagnants.Count == 1)
|
||||
BindingContext = ("Victoire", $"Le joueur {gagnants.First().Nom} a gagné", "trophy.jpg");
|
||||
else if (gagnants.Count > 1)
|
||||
BindingContext = ("Egalité", $"Les joueurs {string.Join(' ', gagnants.Select(joueur => joueur.Nom))} ont gagné", "egaliter.jpg");
|
||||
else
|
||||
BindingContext = ("Défaite", "Personne n'a trouvé le code...", "defaite.png");
|
||||
}
|
||||
|
||||
public async void QuandMenuPresse(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PopAsync();
|
||||
}
|
||||
using CoreLibrary.Evenements;
|
||||
using CoreLibrary.Joueurs;
|
||||
|
||||
namespace MauiSpark.Pages;
|
||||
|
||||
|
||||
partial class Message
|
||||
{
|
||||
public string Titre { get; init; } = "";
|
||||
public string Texte { get; init; } = "";
|
||||
public string Image { get; init; } = "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public partial class VictoirePage : ContentPage
|
||||
{
|
||||
public VictoirePage()
|
||||
{
|
||||
NavigationPage.SetHasNavigationBar(this, false);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public async void QuandPartieTerminee(object? sender, PartiePartieTermineeEventArgs 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 AccueilPage)
|
||||
break;
|
||||
|
||||
Application.Current.MainPage.Navigation.RemovePage(page);
|
||||
}
|
||||
|
||||
IReadOnlyList<Joueur> gagnants = e.Gagnants;
|
||||
IReadOnlyList<Joueur> perdants = e.Perdants;
|
||||
|
||||
if (gagnants.Count == 1)
|
||||
BindingContext = new Message()
|
||||
{
|
||||
Titre = "Victoire",
|
||||
Texte = $"Le joueur {gagnants.First().Nom} a gagné",
|
||||
Image = "trophy.jpg"
|
||||
};
|
||||
else if (gagnants.Count > 1)
|
||||
BindingContext = new Message()
|
||||
{
|
||||
Titre = "Egalité",
|
||||
Texte = $"Les joueurs {string.Join(' ', gagnants.Select(joueur => joueur.Nom))} ont gagné",
|
||||
Image = "egalite.jpg"
|
||||
};
|
||||
else
|
||||
BindingContext = new Message()
|
||||
{
|
||||
Titre = "Défaite",
|
||||
Texte = "Personne n'a trouvé le code...",
|
||||
Image = "defaite.png"
|
||||
};
|
||||
}
|
||||
|
||||
public async void QuandMenuPresse(object sender, EventArgs e)
|
||||
{
|
||||
await Navigation.PopAsync();
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Loading…
Reference in new issue