continuer page plateau
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 11 months ago
parent 643a15c879
commit d336cb4e92

@ -1,14 +1,20 @@
using CoreLibrary.Events; using CoreLibrary.Events;
using CoreLibrary.Joueurs; using CoreLibrary.Joueurs;
using CoreLibrary.Persistance; using CoreLibrary.Persistance;
using System.Collections.Generic;
namespace CoreLibrary.Manager namespace CoreLibrary.Manager
{ {
public class Manageur public class Manageur
{ {
public List<Joueur> joueurs; private readonly List<Joueur> joueurs;
public List<Partie> parties; private readonly List<Partie> parties;
private IPersistance persistance; private readonly IPersistance persistance;
private Partie? partie;
public IReadOnlyCollection<Joueur> Joueurs => joueurs;
public IReadOnlyCollection<Partie> Parties => parties;
public Partie? Partie => partie;
public Manageur(IPersistance persistance) public Manageur(IPersistance persistance)
{ {
@ -19,6 +25,8 @@ namespace CoreLibrary.Manager
public void NouvellePartie(Partie partie) public void NouvellePartie(Partie partie)
{ {
this.partie = partie;
parties.Add(partie); parties.Add(partie);
partie.PasserMain += (object? sender, PasserMainEventArgs e) => partie.PasserMain += (object? sender, PasserMainEventArgs e) =>

@ -15,7 +15,8 @@ namespace MauiSpark.Convertisseurs
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{ {
if (value is not Couleur) return Noir; if (value is not Couleur)
return Noir;
switch (value) switch (value)
{ {

@ -12,123 +12,120 @@
<conv:JetonVersTexte x:Key="JetonVersTexte"/> <conv:JetonVersTexte x:Key="JetonVersTexte"/>
</ContentPage.Resources> </ContentPage.Resources>
<Grid RowDefinitions="*" ColumnDefinitions="*, *"> <ContentPage.Content>
<Grid RowDefinitions="*" ColumnDefinitions="*" Margin="50"> <Grid RowDefinitions="*" ColumnDefinitions="*, *">
<Border <Grid RowDefinitions="*" ColumnDefinitions="*" Margin="50">
StrokeThickness="2" <Border
StrokeShape="RoundRectangle 10" HorizontalOptions="FillAndExpand"
HorizontalOptions="Center"> VerticalOptions="FillAndExpand"
<FlexLayout StrokeThickness="2"
Direction="Column" StrokeShape="RoundRectangle 10">
Wrap="Wrap"
JustifyContent="SpaceBetween" <StackLayout BindableLayout.ItemsSource="{Binding Plateau}">
AlignItems="Stretch"
BindableLayout.ItemsSource="{Binding Plateau}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Grid
FlexLayout.Grow="1"
FlexLayout.AlignSelf="Stretch"
RowDefinitions="*, auto"
ColumnDefinitions="*, 5*">
<FlexLayout
VerticalOptions="Center"
Direction="Row"
Wrap="Wrap"
JustifyContent="SpaceAround"
AlignItems="Center"
BindableLayout.ItemsSource="{Binding [1]}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label
Text="*"
TextColor="{Binding ., Converter={StaticResource IndicateurVersCouleurMAUI}}"
VerticalOptions="Center"
HorizontalOptions="Center" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
<FlexLayout
VerticalOptions="Center"
Grid.Column="1"
Direction="Row"
Wrap="Wrap"
JustifyContent="SpaceAround"
AlignItems="Center"
BindableLayout.ItemsSource="{Binding [0]}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding Path=Couleur, Converter={StaticResource conv:CouleurVersCouleurMAUI}}"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
<BoxView Grid.Row="1" Grid.ColumnSpan="2" HeightRequest="1" VerticalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</FlexLayout>
</Border>
</Grid>
<Grid Grid.Column="1" RowDefinitions="*, 2*, *" ColumnDefinitions="*" Margin="50">
<Label Text="{Binding Joueur}" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Center"/>
<Border
HorizontalOptions="FillAndExpand"
Grid.Row="1"
StrokeThickness="2"
StrokeShape="RoundRectangle 10">
<Grid
RowDefinitions="*, auto, *, *"
ColumnDefinitions="*, *, *, *, *, *">
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="X">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="SupprimerDernierJeton"/>
</Label.GestureRecognizers>
</Label>
<FlexLayout
VerticalOptions="Center"
Grid.Column="1"
Grid.ColumnSpan="4"
Direction="Row"
Wrap="Wrap"
JustifyContent="SpaceAround"
AlignItems="Center"
BindableLayout.ItemsSource="{Binding Code.Jetons}">
<BindableLayout.ItemTemplate> <BindableLayout.ItemTemplate>
<DataTemplate> <DataTemplate>
<vues:JetonVue Couleur="{Binding Couleur, Converter={StaticResource conv:CouleurVersCouleurMAUI}}"/> <Grid
</DataTemplate> RowDefinitions="*, auto"
</BindableLayout.ItemTemplate> ColumnDefinitions="*, 3*"
</FlexLayout> VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="5" Text="V">
<Label.GestureRecognizers> <StackLayout
<TapGestureRecognizer Tapped="ValiderCode"/> Orientation="Horizontal"
</Label.GestureRecognizers> BindableLayout.ItemsSource="{Binding [1]}">
</Label>
<BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" VerticalOptions="Center"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/> <BindableLayout.ItemTemplate>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/> <DataTemplate>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/> <Label Text="O"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/> <StackLayout
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/> Orientation="Horizontal"
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/> Grid.Column="1"
</Grid> BindableLayout.ItemsSource="{Binding [0]}">
</Border>
<Label Grid.Row="2" Text="{Binding Numero}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/> <BindableLayout.ItemTemplate>
<DataTemplate>
<vues:JetonVue
Couleur="{Binding Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
<BoxView
Grid.ColumnSpan="2"
Grid.Row="1"
HeightRequest="1"
VerticalOptions="End"/>
</Grid>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</Border>
</Grid>
<Grid Grid.Column="1" RowDefinitions="*, 2*, *" ColumnDefinitions="*" Margin="50">
<Label Text="{Binding Joueur}" FontSize="Large" VerticalOptions="Center" HorizontalOptions="Center"/>
<Border
HorizontalOptions="FillAndExpand"
Grid.Row="1"
StrokeThickness="2"
StrokeShape="RoundRectangle 10">
<Grid
RowDefinitions="*, auto, *, *"
ColumnDefinitions="*, *, *, *, *, *">
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Text="X">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="SupprimerDernierJeton"/>
</Label.GestureRecognizers>
</Label>
<StackLayout
Orientation="Horizontal"
Grid.Column="1"
Grid.ColumnSpan="4"
BindableLayout.ItemsSource="{Binding Code.Jetons}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<vues:JetonVue
Couleur="{Binding Couleur, Converter={StaticResource CouleurVersCouleurMAUI}}"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
<Label FontSize="Medium" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Column="5" Text="V">
<Label.GestureRecognizers>
<TapGestureRecognizer Tapped="ValiderCode"/>
</Label.GestureRecognizers>
</Label>
<BoxView Grid.Row="1" Grid.ColumnSpan="6" HeightRequest="1" VerticalOptions="Center"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Rouge}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"></vues:JetonVue>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Vert}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Bleu}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="2" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Jaune}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Noir}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="2" Grid.Row="3" Grid.ColumnSpan="2"/>
<vues:JetonVue Couleur="{x:Static conv:CouleurVersCouleurMAUI.Blanc}" Code="{Binding Code}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Column="4" Grid.Row="3" Grid.ColumnSpan="2"/>
</Grid>
</Border>
<Label Grid.Row="2" Text="{Binding Numero}" FontSize="Medium" VerticalOptions="Center" HorizontalOptions="Center"/>
</Grid>
<vues:BoutonReglesVue Grid.Column="1" VerticalOptions="Start" HorizontalOptions="End"/>
</Grid> </Grid>
</ContentPage.Content>
<vues:BoutonReglesVue Grid.Column="1" VerticalOptions="Start" HorizontalOptions="End"/>
</Grid>
</ContentPage> </ContentPage>

@ -1,10 +1,7 @@
using CoreLibrary;
using CoreLibrary.Core; using CoreLibrary.Core;
using CoreLibrary.Events; using CoreLibrary.Events;
using CoreLibrary.Exceptions; using CoreLibrary.Exceptions;
using CoreLibrary.Joueurs; using CoreLibrary.Joueurs;
using MauiSpark.Convertisseurs;
using System.Globalization;
namespace MauiSpark.Pages; namespace MauiSpark.Pages;
@ -68,22 +65,6 @@ public partial class PlateauPage : ContentPage
BindingContext = new Tour(e); BindingContext = new Tour(e);
} }
private void CouleurPresee(Object sender, EventArgs e)
{
Label label = (Label)sender;
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(label.TextColor, typeof(Couleur), null, CultureInfo.InvariantCulture);
try
{
if(code != null)
code.AjouterJeton(new Jeton(couleur));
}
catch (CodeCompletException)
{
DisplayAlert("Attention", "La code est plein", "OK");
}
}
private void SupprimerDernierJeton(Object sender, EventArgs e) private void SupprimerDernierJeton(Object sender, EventArgs e)
{ {
try try

@ -15,7 +15,7 @@ public class JoueurClassementNbCoupParPartie
} }
public int Place public int Place
{ {
get => manageur.joueurs get => manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal/(joueur.NbPartiePerdue+joueur.NbPartieGagnee+joueur.NbPartieEgalite)).ToList() .OrderBy(joueur => joueur.NbCoutTotal/(joueur.NbPartiePerdue+joueur.NbPartieGagnee+joueur.NbPartieEgalite)).ToList()
.IndexOf(Joueur) + 1; .IndexOf(Joueur) + 1;
} }
@ -42,7 +42,7 @@ public class JoueurClassementPartieGagnee
public int Place public int Place
{ {
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1; get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartieGagnee).ToList().IndexOf(Joueur) + 1;
} }
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite); public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -67,7 +67,7 @@ public class JoueurClassementPartieEgalite
public int Place public int Place
{ {
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1; get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartieEgalite).ToList().IndexOf(joueur)+1;
} }
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite); public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -92,7 +92,7 @@ public class JoueurClassementPartiePerdue
public int Place public int Place
{ {
get => manageur.joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1; get => manageur.Joueurs.OrderByDescending(joueur => joueur.NbPartiePerdue).ToList().IndexOf(joueur)+1;
} }
public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite); public int NbCoutMoyen => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite);
@ -117,7 +117,7 @@ public class JoueurClassementAlphabet
public int Place public int Place
{ {
get => manageur.joueurs get => manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)).ToList() .OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)).ToList()
.IndexOf(Joueur) + 1; .IndexOf(Joueur) + 1;
} }
@ -140,7 +140,7 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0) if(NbClique % 2 == 0)
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)) .OrderBy(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
.Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur));
@ -148,7 +148,7 @@ public partial class CTableauScore : ContentView
else else
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite)) .OrderByDescending(joueur => joueur.NbCoutTotal / (joueur.NbPartiePerdue + joueur.NbPartieGagnee + joueur.NbPartieEgalite))
.Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementNbCoupParPartie(joueur, MauiProgram.Manageur));
} }
@ -159,14 +159,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0) if(NbClique % 2 == 0)
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartieGagnee) .OrderByDescending(joueur => joueur.NbPartieGagnee)
.Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur));
} }
else else
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartieGagnee) .OrderBy(joueur => joueur.NbPartieGagnee)
.Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartieGagnee(joueur, MauiProgram.Manageur));
} }
@ -178,14 +178,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0) if(NbClique % 2 == 0)
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartieEgalite) .OrderByDescending(joueur => joueur.NbPartieEgalite)
.Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur));
} }
else else
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartieEgalite) .OrderBy(joueur => joueur.NbPartieEgalite)
.Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartieEgalite(joueur, MauiProgram.Manageur));
} }
@ -197,14 +197,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0) if(NbClique % 2 == 0)
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.NbPartiePerdue) .OrderByDescending(joueur => joueur.NbPartiePerdue)
.Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur));
} }
else else
{ {
NbClique++; NbClique++;
; return MauiProgram.Manageur.joueurs ; return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.NbPartiePerdue) .OrderBy(joueur => joueur.NbPartiePerdue)
.Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementPartiePerdue(joueur, MauiProgram.Manageur));
} }
@ -216,14 +216,14 @@ public partial class CTableauScore : ContentView
if(NbClique % 2 == 0) if(NbClique % 2 == 0)
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderBy(joueur => joueur.Nom) .OrderBy(joueur => joueur.Nom)
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur));
} }
else else
{ {
NbClique++; NbClique++;
return MauiProgram.Manageur.joueurs return MauiProgram.Manageur.Joueurs
.OrderByDescending(joueur => joueur.Nom) .OrderByDescending(joueur => joueur.Nom)
.Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur)); .Select(joueur => new JoueurClassementAlphabet(joueur, MauiProgram.Manageur));
} }

@ -6,11 +6,19 @@
<Grid <Grid
x:Name="Grid" x:Name="Grid"
SizeChanged="QuandTailleChangee"> SizeChanged="QuandTailleChangee"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<Ellipse <Ellipse
x:Name="Cercle" x:Name="Cercle"
Fill="{Binding Couleur, Source={x:Reference jetonVue}}"/> Fill="{Binding Couleur, Source={x:Reference jetonVue}}">
<Ellipse.GestureRecognizers>
<TapGestureRecognizer Tapped="JetonPresse"/>
</Ellipse.GestureRecognizers>
</Ellipse>
</Grid> </Grid>
</ContentView> </ContentView>

@ -1,31 +1,66 @@
using Microsoft.Maui.Controls.Shapes; using CoreLibrary.Core;
using CoreLibrary.Exceptions;
namespace MauiSpark.Vues; using MauiSpark.Convertisseurs;
using System.Globalization;
public partial class JetonVue : ContentView
{ namespace MauiSpark.Vues;
public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChangee);
public partial class JetonVue : ContentView
public Color Couleur {
{ public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChangee);
get => (Color)GetValue(CouleurProperty); public static readonly BindableProperty CodeProperty = BindableProperty.Create(nameof(Code), typeof(Code), typeof(JetonVue), null, propertyChanged: QuandCodeChange);
set => SetValue(CouleurProperty, Color.FromRgb(0, 255, 0));
} public Color Couleur
{
public JetonVue() get => (Color)GetValue(CouleurProperty);
{ set => SetValue(CouleurProperty, value);
InitializeComponent(); }
BindingContext = this;
} public Code? Code
{
private void QuandTailleChangee(object sender, EventArgs e) get => (Code?)GetValue(CodeProperty);
{ set => SetValue(CodeProperty, value);
double taille = Math.Min(Grid.Width, Grid.Height) / 2; }
Cercle.WidthRequest = Cercle.HeightRequest = taille;
} public JetonVue()
{
InitializeComponent();
BindingContext = this;
}
private void QuandTailleChangee(object sender, EventArgs e)
{
double taille = Math.Min(Grid.Width, Grid.Height) / 2;
Cercle.WidthRequest = Cercle.HeightRequest = taille;
}
private static void QuandCouleurChangee(BindableObject bindable, object ancienneValeur, object nouvelleValeur) private static void QuandCouleurChangee(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
{ {
((JetonVue)bindable).Cercle.Fill = (Color) nouvelleValeur; if (((Color)nouvelleValeur).Red != 0 || ((Color)nouvelleValeur).Green != 0 || ((Color)nouvelleValeur).Blue != 0)
} {
((JetonVue)bindable).Cercle.Fill = (Color)nouvelleValeur;
}
}
private static void QuandCodeChange(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
{
}
private void JetonPresse(object sender, EventArgs e)
{
if (Cercle == null || !sender.Equals(Cercle) || Code == null || Application.Current == null || Application.Current.MainPage == null)
return;
Couleur couleur = (Couleur)new CouleurVersCouleurMAUI().ConvertBack(Cercle.Fill, typeof(Couleur), null, CultureInfo.InvariantCulture);
try
{
Code.AjouterJeton(new Jeton(couleur));
}
catch (CodeCompletException)
{
Application.Current.MainPage.DisplayAlert("Attention", "La code est plein", "OK");
}
}
} }

@ -2,12 +2,13 @@ namespace MauiSpark.Vues;
public partial class TitreVue : ContentView public partial class TitreVue : ContentView
{ {
public static readonly BindableProperty TextePropriete = BindableProperty.Create(nameof(Texte), typeof(string), typeof(TitreVue), default(string)); public static readonly BindableProperty TexteProperty = BindableProperty.Create(nameof(Texte), typeof(string), typeof(TitreVue), default(string));
public string Texte public string Texte
{ {
get => (string)GetValue(TextePropriete); get => (string)GetValue(TexteProperty);
set => SetValue(TextePropriete, value.ToUpper()); set => SetValue(TexteProperty, value.ToUpper());
} }
public TitreVue() public TitreVue()

Loading…
Cancel
Save