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.
94 lines
2.9 KiB
94 lines
2.9 KiB
using System;
|
|
using Microsoft.Maui.Controls;
|
|
using Microsoft.Maui.Platform;
|
|
using Microsoft.VisualBasic;
|
|
using ParionsCuite.Modeles;
|
|
using ParionsCuite.Views.Information;
|
|
using ParionsCuite.Views.Invite;
|
|
using ParionsCuite;
|
|
using ParionsCuite.Views.Participations.Autre;
|
|
using System.Diagnostics;
|
|
|
|
namespace ParionsCuite.Views.Pari;
|
|
|
|
public partial class Parier : ContentView
|
|
{
|
|
public Manageur mgr => (App.Current as App).MyManager;
|
|
|
|
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)
|
|
{
|
|
int pariCount = GridPari.ColumnDefinitions.Count - 1; // Compter le nombre de colonnes déjà présentes (-1 pour ignorer la première colonne)
|
|
|
|
ColumnDefinition column = new ColumnDefinition();
|
|
GridPari.ColumnDefinitions.Insert(pariCount + 1, column);
|
|
|
|
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);
|
|
|
|
// 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);
|
|
|
|
changeButton.Content = newPage;
|
|
|
|
};
|
|
mgr.Save_Data();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SwitchView(object sender, EventArgs e)
|
|
{
|
|
var newPage = new Views.Ajout_Paris.Ajouts_Pari(EventSelect);
|
|
|
|
changeButton.Content = newPage;
|
|
|
|
}
|
|
|
|
|
|
} |