reglage boutton sup inviter + Debut binding NOurriture

C#
Tony Fages 2 years ago
parent 837dd38642
commit fb5da57e19

@ -45,7 +45,7 @@
<!-- Création de 2 lignes -->
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="800"/>
<RowDefinition Height="900"/>
</Grid.RowDefinitions>
<!-- 1er ligne -->

@ -37,15 +37,14 @@ public partial class MainPage : ContentPage
};
newButton.Clicked += (sender, e) =>
{
// Appeler la méthode qui récupère l'événement associé
// Appel de la méthode qui récupère l'événement associé
SelectEvent(evenement);
var newPage = new Views.Accueil();
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
};
// Ajouter le bouton au ButtonStackLayout
// Ajout du bouton au ButtonStackLayout
ButtonStackLayout.Children.Add(newButton); ;
}
public void SelectEvent(Evenement evenement)
@ -61,49 +60,55 @@ public partial class MainPage : ContentPage
// Acces View Groupe
public void Button_Clicked(object sender, EventArgs e)
{
var newPage = new Views.Groupe();
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
// Acces view Invite
private void InviteView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Invite.Inviter(EventSelect);
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
// Acces view Participant
private void ParticipantView(object sender, EventArgs e)
{
var newPage = new Views.Participations.Nourriture();
if (EventSelect == null) { return; }
var newPage = new Views.Participations.Nourriture(EventSelect);
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
//Acces View Pari
private void PariView(object sender, EventArgs e)
{
//if (EventSelect == null) { return; }
var newPage = new Views.Pari.Parier();
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}
// Acces View Information
private void InfoView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Information.Info(EventSelect);
// Définissez le contenu de la ContentView sur la nouvelle page
changeButton.Content = newPage;
}

@ -44,6 +44,14 @@
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<AndroidResource Remove="Views\Participations\NewFolder\**" />
<Compile Remove="Views\Participations\NewFolder\**" />
<EmbeddedResource Remove="Views\Participations\NewFolder\**" />
<MauiCss Remove="Views\Participations\NewFolder\**" />
<MauiXaml Remove="Views\Participations\NewFolder\**" />
<None Remove="Views\Participations\NewFolder\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
@ -63,6 +71,9 @@
<MauiXaml Update="Views\Pari\Parier.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Participations\NewFolder1\Nourri.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\fleches.png" />
@ -82,7 +93,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Ajout_Paris\" />
<Folder Include="Views\Participations\" />
<Folder Include="Views\Participations\Autre\" />
<Folder Include="Views\Participations\Boisson\" />
<Folder Include="Modeles\" />

@ -4,11 +4,11 @@
x:Class="ParionsCuite.Views.Information.Info">
<VerticalStackLayout HeightRequest="1000">
<Grid HeightRequest="2000" BackgroundColor="red">
<Grid>
<TableView x:Name="tableview">
<TableRoot >
<TableSection Title="Informations" x:Name="tableInfo" >
<TextCell Text="Nom de l'événement" x:Name="NomEvent" Height="40"/>
<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"/>

@ -23,7 +23,7 @@ public partial class Inviter : ContentView
List<Modeles.Inviter> listInvite = EventSelect.ListInviter;
Debug.WriteLine(listInvite);
int len = listInvite.Count;
int len = 1;
foreach (Modeles.Inviter inviter in listInvite) {
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
@ -48,14 +48,16 @@ public partial class Inviter : ContentView
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GrilleInvite.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
Debug.WriteLine("Test test");
}
private void AddInvitelist(object sender, EventArgs e)
@ -63,7 +65,7 @@ public partial class Inviter : ContentView
//restoreListInvite();
string nom = nomEditor.Text;
string prenom = prenomEditor.Text;
if (nom == null || prenom == null) { return; }
if (nom == null || prenom == null || nom == "" || prenom == "") { return; }
Modeles.Inviter invite1 = new Modeles.Inviter(nom, prenom);
EventSelect.ListInviter.Add(invite1);
;
@ -103,7 +105,11 @@ public partial class Inviter : ContentView
//GrilleInvite.HeightRequest = Height + 2;
len = len +1 ;
}
prenomEditor.Text = "";
nomEditor.Text = "";
}
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
@ -118,9 +124,7 @@ public partial class Inviter : ContentView
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
if (rowIndex >= 0 && rowIndex < parentGrid.RowDefinitions.Count)
{
// Récupérer les labels correspondants à la ligne
Label prenomLabel = null;
Label nomLabel = null;
@ -145,12 +149,12 @@ public partial class Inviter : ContentView
string nom = nomLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Inviter inviter = mgr.ReturnListInvite().FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
if (inviter != null)
{
// Supprimer l'invité de la liste
mgr.RemoveInviter(inviter);
// Supprimer l'invité de la liste
EventSelect.ListInviter.Remove(inviter);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(prenomLabel);
@ -159,7 +163,6 @@ public partial class Inviter : ContentView
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
}
}
}

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" ?>
<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*">
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Placeholder="Entrer nourriture" x:Name="FoodInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer quantité" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddFoodlist"/>
</StackLayout>
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" Margin="30" x:Name="GridFood">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+nourritre-->
<Label Text="Nourriture" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,163 @@
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
using System.Diagnostics;
namespace ParionsCuite.Views.Participations.NewFolder1;
public partial class Nourri : ContentView
{
readonly Evenement EventSelect;
public Manageur mgr => (App.Current as App).MyManager;
public Nourri(Evenement EventSelect)
{
this.EventSelect = EventSelect;
InitializeComponent();
//restoreListInvite(EventSelect);
BindingContext = this;
}
public void restoreListInvite(Evenement EventSelect)
{
var listFood = EventSelect.Participation.Nourriture;
Debug.WriteLine(listFood);
int len = 1;
foreach (Modeles.Nourriture food in listFood)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
// AJout Prenom
Label foodLabel = new Label();
foodLabel.Text = food.Nom;
Grid.SetRow(foodLabel, len);
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
// Ajout Nom
Label qteLabel = new Label();
food.Nom = food.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridFood.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
private void AddFoodlist(object sender, EventArgs e)
{
//restoreListInvite();
string food = FoodInput.Text;
string qte = QteInput.Text;
if (food == null || qte == null) { return; }
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
EventSelect.Participation.Nourriture.Add(food1);
int len = 1;
//if (len == 0 ) { len = 1; }
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
// AJout Prenom
Label foodLabel = new Label();
foodLabel.Text = food2.Nom;
Grid.SetRow(foodLabel, len);
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
// Ajout Nom
Label qteLabel = new Label();
food2.Nom = food2.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridFood.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
{
// Récupérer le bouton cliqué
Button button = (Button)sender;
// Récupérer la grille parente du bouton
Grid parentGrid = (Grid)button.Parent;
// Récupérer la ligne parente du bouton
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
Label prenomLabel = null;
Label nomLabel = null;
// Parcourir les enfants de la grille pour trouver les labels de la ligne
foreach (View child in parentGrid.Children)
{
int childRowIndex = Grid.GetRow(child);
if (childRowIndex == rowIndex)
{
if (Grid.GetColumn(child) == 0)
prenomLabel = (Label)child;
else if (Grid.GetColumn(child) == 1)
nomLabel = (Label)child;
}
}
if (prenomLabel != null && nomLabel != null)
{
// Récupérer le prénom et le nom de l'invité à supprimer
string prenom = prenomLabel.Text;
string nom = nomLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
if (inviter != null)
{
// Supprimer l'invité de la liste
EventSelect.ListInviter.Remove(inviter);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(prenomLabel);
parentGrid.Children.Remove(nomLabel);
parentGrid.Children.Remove(button);
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
}
}

@ -2,68 +2,26 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:model="clr-namespace:ParionsCuite.Modeles"
x:Class="ParionsCuite.Views.Participations.Nourriture">
x:Class="ParionsCuite.Views.Participations.Nourriture"
xmlns:nourriture="clr-namespace:ParionsCuite.Views.Participations.NewFolder1"
>
<VerticalStackLayout>
<!--Grid Participation-->
<Grid ColumnDefinitions="*,*,*">
<Button Text="Nourriture" BackgroundColor="Grey" />
<Button Text="Boisson" Grid.Column="1"/>
<Button Text="Autre" Grid.Column="2" />
</Grid>
<!--Grid Pincipale-->
<Grid ColumnDefinitions="5*, 1*, 5*">
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Placeholder="Entrer Nourriture" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AjoutNourriture"/>
</StackLayout>
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" Margin="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+nourritre-->
<Label Text="Nourriture" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<!--Content Grille quantité+nourritre-->
<VerticalStackLayout Grid.Row="1" x:Name="View_Food">
<ListView ItemsSource="{Binding Nourriture}">
<ListView.ItemTemplate>
<DataTemplate>
<HorizontalStackLayout>
<Label Grid.Column="1" Text="{Binding Nom}"/>
<Label Grid.Column="0" Text="{Binding Quantite}"/>
<Label Grid.Column="0" Text="Bidon"/>
</HorizontalStackLayout>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
<Grid ColumnDefinitions="*,*,*" RowDefinitions="*,*" HeightRequest="100" VerticalOptions="Center" BackgroundColor="AliceBlue">
<Button Text="Nourriture" BackgroundColor="Grey" Clicked="NourritureView" />
<Button Text="Boisson" Grid.Column="1" Clicked="BoissonView"/>
<Button Text="Autre" Grid.Column="2" Clicked="AutreView" />
<ContentView x:Name="changeButton" Grid.Row="1" BackgroundColor="AliceBlue" >
</ContentView>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -1,19 +1,43 @@
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
namespace ParionsCuite.Views.Participations;
public partial class Nourriture : ContentView
{
public Manageur Mng => (App.Current as App).MyManager;
public Manageur mgr => (App.Current as App).MyManager;
public Nourriture()
Evenement EventSelect;
public Nourriture(Evenement EventSelect)
{
BindingContext = Mng.Evenement[0].Participation;
InitializeComponent();
InitializeComponent();
this.EventSelect = EventSelect;
}
private void AjoutNourriture(object sender, EventArgs e)
private void NourritureView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
changeButton.Content = newPage;
}
private void BoissonView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
changeButton.Content = newPage;
}
private void AutreView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
changeButton.Content = newPage;
}
}

Loading…
Cancel
Save