Parti Pari Fini

C# BackUp
Tony Fages 2 years ago
parent 98001a4f60
commit 1da7e42027

@ -19,6 +19,9 @@ namespace ParionsCuite.Modeles
private ObservableCollection<Evenement> evenement;
public bool Value1;
public bool Value2;
public bool Value3;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public ObservableCollection<Evenement> Evenement

@ -12,15 +12,9 @@ public partial class Ajouts_Pari : ContentView
{
InitializeComponent();
this.EventSelect = EventSelect;
EventSelect.PariAdd += OnPariAdded;
}
private void OnPariAdded(Parier Parier)
{
Debug.WriteLine("Test");
}
private void NewPari(object sender, EventArgs e)
{
string parieur1 = Parieur1.Text;
@ -28,9 +22,9 @@ public partial class Ajouts_Pari : ContentView
string but = ButPari.Text;
string enjeux = EnjeuxPari.Text;
Inviter NewParieur1 = new Inviter(parieur1);
Inviter NewParieur2 = new Inviter(parieur1);
Inviter NewParieur2 = new Inviter(parieur2);
Modeles.Parier newPari = new Parier(NewParieur1, NewParieur2, but, enjeux);
EventSelect.ListParier.Add(newPari);
//EventSelect.ListParier.Add(newPari);
EventSelect.Ajout_Pari(newPari);
Debug.WriteLine("Taille Liste : " + EventSelect.ListParier.Count());

@ -4,11 +4,11 @@
x:Class="ParionsCuite.Views.Information.Info">
<VerticalStackLayout HeightRequest="1000">
<Grid>
<TableView x:Name="tableview">
<Grid BindingContext="{Binding Source={x:Reference Name=NomEvent}, Path=BindingContext}">
<TableView x:Name="tableview" >
<TableRoot >
<TableSection Title="Informations" x:Name="tableInfo" >
<TextCell Text="Nom de l'événement" x:Name="NomEvent"/>
<TextCell Text="Nom de l'événement" x:Name="NomEvent" />
<TextCell Text="Date de l'événement" x:Name="DateEvent"/>
<TextCell Text="Nombres d'invité" x:Name="NbInvite"/>
<TextCell Text="Nombres de paris" x:Name="NbPari"/>

@ -12,7 +12,8 @@ public partial class Info : ContentView
{
InitializeComponent();
MiseAJourInfo(EventSelect);
BindingContext = this;
this.BindingContext = EventSelect;
}
@ -28,7 +29,7 @@ public partial class Info : ContentView
int v = EventSelect.ListParier.Count();
NbPari.Detail = v.ToString();
AdresseEvent.Detail = EventSelect.Lieu;
HoraireEvent.Detail = v.ToString();
HoraireEvent.Detail = EventSelect.Heure;
}

@ -4,26 +4,39 @@
x:Class="ParionsCuite.Views.Pari.InfoPAri">
<VerticalStackLayout>
<!--P1 vs P2-->
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*">
<Button Text="Parieur 1" Margin="40,0,0,0"/>
<Button Text="+" Grid.Column="1"/>
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*" BindingContext="{Binding EventSelect}">
<Button x:Name="Parieur1" Margin="40,0,0,0"/>
<Label Text="Contre" Grid.Column="2" HorizontalOptions="Center" FontAttributes="Bold" FontSize="Title"/>
<Button Text="Parieur 2" Grid.Column="3" />
<Button Text="+" Grid.Column="4"/>
<Button Text="Supprimer Pari" Grid.Column="5" Margin="50,0,0,0"/>
<Button Text="Parieur 2" x:Name="Parieur2" Grid.Column="3" />
</Grid>
<!--Info Pari-->
<TableView RowHeight="70" Margin="30,0,0,0" HorizontalOptions="Start" WidthRequest="1000">
<TableRoot>
<TableSection>
<EntryCell Label="But du Pari"/>
<EntryCell Label="Enjeux du Pari"/>
<SwitchCell Text="Pari terminé" On="False" />
<SwitchCell Text="Joueur(s) 1 gagnant" On="True" />
<SwitchCell Text="Joueur(s) 2 gagnant" On="True" />
<EntryCell Label="But du Pari" x:Name="butPari" />
<EntryCell Label="Enjeux du Pari" x:Name="enjeuxPari" />
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Pari terminé" VerticalOptions="Center" />
<Switch x:Name="ValuePari" Toggled="ValuePari_Toggled" />
</StackLayout>
</ViewCell>
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Joueur(s) 1 gagnant" VerticalOptions="Center" />
<Switch x:Name="j1" Toggled="j1_Toggled" IsEnabled="{Binding Source={x:Reference ValuePari}, Path=IsToggled}" />
</StackLayout>
</ViewCell>
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Joueur(s) 2 gagnant" VerticalOptions="Center" />
<Switch x:Name="j2" Toggled="j2_Toggled" IsEnabled="{Binding Source={x:Reference ValuePari}, Path=IsToggled}" />
</StackLayout>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,81 @@
using ParionsCuite.Modeles;
using System.Diagnostics;
namespace ParionsCuite.Views.Pari;
public partial class InfoPAri : ContentView
{
public InfoPAri()
readonly Modeles.Parier PariSelect;
public Manageur mgr => (App.Current as App).MyManager;
public InfoPAri(Modeles.Parier PariSelect)
{
InitializeComponent();
this.PariSelect = PariSelect;
this.BindingContext = this;
MiseAJourInfo(PariSelect);
}
private void MiseAJourInfo(Modeles.Parier PariSelect)
{
//Debug.WriteLine("Pari Selectionner " + PariSelect);
Parieur1.Text = PariSelect.i1.Prenom;
Parieur2.Text = PariSelect.i2.Prenom;
butPari.Text = PariSelect.But;
enjeuxPari.Text = PariSelect.Enjeu;
ValuePari.IsToggled = mgr.Value1;
j1.IsToggled = mgr.Value2;
j2.IsToggled = mgr.Value3;
Debug.WriteLine("Value " + mgr.Value2);
}
private void ValuePari_Toggled(object sender, ToggledEventArgs e)
{
if (!ValuePari.IsToggled)
{
j1.IsToggled = false;
j2.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
private void j1_Toggled(object sender, ToggledEventArgs e)
{
if (j1.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled)
{
j1.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
private void j2_Toggled(object sender, ToggledEventArgs e)
{
if (j2.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled)
{
j2.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
}

@ -4,12 +4,19 @@
x:Class="ParionsCuite.Views.Pari.Parier"
xmlns:AjoutINfo="clr-namespace:ParionsCuite.Views.Pari">
<VerticalStackLayout>
<!--Grid Pari-->
<Grid ColumnDefinitions="auto" x:Name="GridPari">
<Button Text="Ajouter Pari" Grid.Column="1" Clicked="SwitchView"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Button Text="Ajouter Pari" Grid.Column="0" Clicked="SwitchView"/>
<Grid Grid.Column="1" ColumnDefinitions="auto" x:Name="GridPari">
</Grid>
</Grid>
<!--Grid Pari-->
<Grid Grid.Row="1">
<Grid.RowDefinitions>

@ -14,34 +14,70 @@ namespace ParionsCuite.Views.Pari;
public partial class Parier : ContentView
{
readonly Evenement EventSelect;
Parier PariSelect { get; set; }
public Parier(Evenement EventSelect)
{
InitializeComponent();
this.EventSelect = EventSelect;
restorePari(EventSelect);
EventSelect.PariAdd += OnPariAdded;
}
private void restorePari(Evenement EventSelect)
{
//if (EventSelect.ListParier.Count() == 0) { return; }
int len = 0;
Debug.WriteLine("Taille Liste Pari" + EventSelect.ListParier);
foreach(Modeles.Parier pari in EventSelect.ListParier)
{
ColumnDefinition column = new ColumnDefinition();
GridPari.ColumnDefinitions.Insert(len, column);
Button button = new Button();
button.Text = "Pari " + (len + 1); // Nommer le bouton en fonction du numéro de pari
Grid.SetRow(button, 0);
Grid.SetColumn(button, len); // Utiliser le numéro de colonne pour positionner le bouton dans la grille
GridPari.Children.Add(button);
len++;
// Ajout du gestionnaire de pari au bouton
button.Clicked += (sender, e) =>
{
// Appel de la méthode qui récupère le pari associé
var newPage = new Views.Pari.InfoPAri(pari);
changeButton.Content = newPage;
};
}
}
private void OnPariAdded(Modeles.Parier obj)
{
// Créer une nouvelle colonne pour la grille
ColumnDefinition column = new ColumnDefinition();
column.Width = new GridLength(1, GridUnitType.Star);
int pariCount = GridPari.ColumnDefinitions.Count - 1; // Compter le nombre de colonnes déjà présentes (-1 pour ignorer la première colonne)
// Ajouter la colonne à la grille
GridPari.ColumnDefinitions.Add(column);
ColumnDefinition column = new ColumnDefinition();
GridPari.ColumnDefinitions.Insert(pariCount + 1, column);
// Créer un élément visuel pour la nouvelle colonne (par exemple, un bouton)
Button newButton = new Button();
newButton.Text = EventSelect.ListParier[0].But;
Button button = new Button();
button.Text = "Pari " + (pariCount + 1); // Nommer le bouton en fonction du numéro de pari
Grid.SetRow(button, 0);
Grid.SetColumn(button, pariCount + 1); // Utiliser le numéro de colonne pour positionner le bouton dans la grille
GridPari.Children.Add(button);
// Placer le nouvel élément dans la grille en utilisant la nouvelle colonne
Grid.SetColumn(newButton, GridPari.ColumnDefinitions.Count); // L'index de la colonne est basé sur 0
// Ajout du gestionnaire de pari au bouton
button.Clicked += (sender, e) =>
{
// Appel de la méthode qui récupère le pari associé
Debug.WriteLine(obj.But);
var newPage = new Views.Pari.InfoPAri(obj);
// Ajouter l'élément à la grille
GridPari.Children.Add(newButton);
changeButton.Content = newPage;
};
}
private void SwitchView(object sender, EventArgs e)
{
var newPage = new Views.Ajout_Paris.Ajouts_Pari(EventSelect);

@ -2,7 +2,7 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.NewFolder1.Nourri">
<VerticalStackLayout>
<Grid ColumnDefinitions="5*, 1*, 5*">

Loading…
Cancel
Save