Merge TestUnitaire To Master #35
Merged
remi.arnal
merged 77 commits from TestUnitaire
into master
2 years ago
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Class1.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,13 +1,63 @@
|
||||
namespace ParionsCuite.Views;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using ParionsCuite.Modeles;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ParionsCuite.Views;
|
||||
/**
|
||||
* @brief Represents a ContentView for creating new events.
|
||||
*
|
||||
* The `Groupe` class provides a form for creating new events. It has a reference to the `Manageur` instance to perform operations on the data.
|
||||
*/
|
||||
public partial class Groupe : ContentView
|
||||
{
|
||||
public Groupe()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/**
|
||||
* @brief Gets the instance of the `Manageur` class used in the application.
|
||||
*/
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief Gets or sets the collection of events.
|
||||
*/
|
||||
public ObservableCollection<Evenement> Evenements { get; set; } = new ObservableCollection<Evenement>();
|
||||
|
||||
void DatePicker_DateSelected(System.Object sender, Microsoft.Maui.Controls.DateChangedEventArgs e)
|
||||
/**
|
||||
* @brief Initializes a new instance of the `Groupe` class.
|
||||
*/
|
||||
public Groupe()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for the button clicked event.
|
||||
*
|
||||
* This method is called when the button for creating a new event is clicked. It retrieves the input values from the form, creates a new event object, adds it to the Manageur instance, and clears the form fields.
|
||||
*
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void Button_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var nomEvent = nomE.Text;
|
||||
var dateEvent = dateE.Text;
|
||||
var lieuEvent = lieuE.Text;
|
||||
var heureEvent = heureE.Text;
|
||||
|
||||
if (!string.IsNullOrEmpty(nomEvent) && !string.IsNullOrEmpty(dateEvent) && !string.IsNullOrEmpty(lieuEvent) && !string.IsNullOrEmpty(heureEvent))
|
||||
{
|
||||
var newEvent = new Evenement(nomEvent, dateEvent, lieuEvent, heureEvent);
|
||||
|
||||
mgr.Ajout_evenement(newEvent);
|
||||
|
||||
nomE.Text = "";
|
||||
dateE.Text = "";
|
||||
lieuE.Text = "";
|
||||
heureE.Text = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("Creation Event Error PLease Check!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,51 @@
|
||||
namespace ParionsCuite.Views.Information;
|
||||
using ParionsCuite.Modeles;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ParionsCuite.Views.Information;
|
||||
/**
|
||||
* @brief The Info class is a partial class derived from ContentView.
|
||||
*/
|
||||
public partial class Info : ContentView
|
||||
{
|
||||
public Info()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief The mgr property returns the application's manager instance.
|
||||
*/
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the Info class.
|
||||
* @param EventSelect The selected event.
|
||||
*/
|
||||
public Info(Evenement EventSelect)
|
||||
{
|
||||
InitializeComponent();
|
||||
MiseAJourInfo(EventSelect);
|
||||
|
||||
this.BindingContext = EventSelect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The m field stores an instance of the Manageur class.
|
||||
*/
|
||||
public Manageur m = new Manageur();
|
||||
|
||||
/**
|
||||
* @brief The DefaultCellHeight constant defines the default height of a cell.
|
||||
*/
|
||||
public const int DefaultCellHeight = 40;
|
||||
|
||||
/**
|
||||
* @brief Updates the information for the selected event.
|
||||
* @param EventSelect The selected event.
|
||||
*/
|
||||
public void MiseAJourInfo(Evenement EventSelect)
|
||||
{
|
||||
int i = EventSelect.ListInviter.Count();
|
||||
NbInvite.Detail = i.ToString();
|
||||
int v = EventSelect.ListParier.Count();
|
||||
NbPari.Detail = v.ToString();
|
||||
AdresseEvent.Detail = EventSelect.Lieu;
|
||||
HoraireEvent.Detail = EventSelect.Heure;
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,189 @@
|
||||
using ParionsCuite.Modeles;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
namespace ParionsCuite.Views.Invite;
|
||||
|
||||
/**
|
||||
* @brief The Inviter class is a partial class derived from ContentView.
|
||||
*/
|
||||
public partial class Inviter : ContentView
|
||||
{
|
||||
public Inviter()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/**
|
||||
* @brief The mgr property returns the application's manager instance.
|
||||
*/
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief The EventSelect field stores the selected event.
|
||||
*/
|
||||
private readonly Evenement EventSelect;
|
||||
|
||||
/**
|
||||
* @brief Gets or sets the Inviters object.
|
||||
*/
|
||||
public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter();
|
||||
|
||||
void ColumnDefinition_SizeChanged(System.Object sender, System.EventArgs e)
|
||||
/**
|
||||
* @brief Initializes a new instance of the Inviter class.
|
||||
* @param EventSelect The selected event.
|
||||
*/
|
||||
public Inviter(Evenement EventSelect)
|
||||
{
|
||||
this.EventSelect = EventSelect;
|
||||
InitializeComponent();
|
||||
restoreListInvite(EventSelect);
|
||||
BindingContext = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores the list of invitees for the selected event.
|
||||
* @param EventSelect The selected event.
|
||||
*/
|
||||
public void restoreListInvite(Evenement EventSelect)
|
||||
{
|
||||
List<Modeles.Inviter> listInvite = EventSelect.ListInviter;
|
||||
Debug.WriteLine(listInvite);
|
||||
int len = 1;
|
||||
foreach (Modeles.Inviter inviter in listInvite)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GrilleInvite.RowDefinitions.Add(row);
|
||||
|
||||
// Ajout Prenom
|
||||
Label prenomLabel = new Label();
|
||||
prenomLabel.Text = inviter.Prenom;
|
||||
Grid.SetRow(prenomLabel, len);
|
||||
Grid.SetColumn(prenomLabel, 0);
|
||||
GrilleInvite.Children.Add(prenomLabel);
|
||||
|
||||
// Ajout Nom
|
||||
Label nomLabel = new Label();
|
||||
nomLabel.Text = inviter.Nom;
|
||||
Grid.SetRow(nomLabel, len);
|
||||
Grid.SetColumn(nomLabel, 1);
|
||||
GrilleInvite.Children.Add(nomLabel);
|
||||
|
||||
// Ajout Bouton
|
||||
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");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Handles the event when the add invite list button is clicked.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void AddInvitelist(object sender, EventArgs e)
|
||||
{
|
||||
string nom = nomEditor.Text;
|
||||
string prenom = prenomEditor.Text;
|
||||
if (nom == null || prenom == null || nom == "" || prenom == "") { return; }
|
||||
Modeles.Inviter invite1 = new Modeles.Inviter(nom, prenom);
|
||||
EventSelect.ListInviter.Add(invite1);
|
||||
|
||||
int len = 1;
|
||||
Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(EventSelect.ListInviter));
|
||||
foreach (Modeles.Inviter inviter in EventSelect.ListInviter)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GrilleInvite.RowDefinitions.Add(row);
|
||||
|
||||
// Ajout Prenom
|
||||
Label prenomLabel = new Label();
|
||||
prenomLabel.Text = inviter.Prenom;
|
||||
Grid.SetRow(prenomLabel, len);
|
||||
Grid.SetColumn(prenomLabel, 0);
|
||||
GrilleInvite.Children.Add(prenomLabel);
|
||||
|
||||
// Ajout Nom
|
||||
Label nomLabel = new Label();
|
||||
nomLabel.Text = inviter.Nom;
|
||||
Grid.SetRow(nomLabel, len);
|
||||
Grid.SetColumn(nomLabel, 1);
|
||||
GrilleInvite.Children.Add(nomLabel);
|
||||
|
||||
// Ajout Bouton
|
||||
Button buttonMoins = new Button();
|
||||
buttonMoins.Text = "-";
|
||||
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
||||
Grid.SetRow(buttonMoins, len);
|
||||
Grid.SetColumn(buttonMoins, 2);
|
||||
GrilleInvite.Children.Add(buttonMoins);
|
||||
|
||||
len++;
|
||||
}
|
||||
|
||||
prenomEditor.Text = "";
|
||||
nomEditor.Text = "";
|
||||
mgr.Save_Data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles the event when the delete button is clicked.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
mgr.Save_Data();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?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.Pari.InfoPAri">
|
||||
<VerticalStackLayout>
|
||||
<!--P1 vs P2-->
|
||||
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*" >
|
||||
<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" 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" Text="{Binding But}" x:Name="butPari" />
|
||||
<EntryCell Label="Enjeux du Pari" Text="{Binding Enjeu}" 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>
|
@ -0,0 +1,97 @@
|
||||
using ParionsCuite.Modeles;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ParionsCuite.Views.Pari;
|
||||
|
||||
/**
|
||||
* @brief Represents a ContentView for displaying information about a specific bet (Pari).
|
||||
*/
|
||||
public partial class InfoPAri : ContentView
|
||||
{
|
||||
readonly Modeles.Parier PariSelect;
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the InfoPAri class.
|
||||
* @param PariSelect The selected bet (Pari).
|
||||
*/
|
||||
public InfoPAri(Modeles.Parier PariSelect)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.PariSelect = PariSelect;
|
||||
this.BindingContext = PariSelect;
|
||||
MiseAJourInfo(PariSelect);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the information displayed for the selected bet (Pari).
|
||||
* @param PariSelect The selected bet (Pari).
|
||||
*/
|
||||
private void MiseAJourInfo(Modeles.Parier PariSelect)
|
||||
{
|
||||
Parieur1.Text = PariSelect.i1.Prenom;
|
||||
Parieur2.Text = PariSelect.i2.Prenom;
|
||||
ValuePari.IsToggled = mgr.Value1;
|
||||
j1.IsToggled = mgr.Value2;
|
||||
j2.IsToggled = mgr.Value3;
|
||||
Debug.WriteLine("Value " + mgr.Value2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Handles the event when the toggle switch for ValuePari is toggled.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles the event when the toggle switch for j1 is toggled.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles the event when the toggle switch for j2 is toggled.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,46 +1,30 @@
|
||||
<?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.Pari.Parier">
|
||||
x:Class="ParionsCuite.Views.Pari.Parier"
|
||||
xmlns:AjoutINfo="clr-namespace:ParionsCuite.Views.Pari">
|
||||
<VerticalStackLayout>
|
||||
<!--Grid menu-->
|
||||
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
|
||||
<Button Text="Invité" />
|
||||
<Button Text="Participant" Grid.Column="1"/>
|
||||
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
|
||||
<Button Text="Information" Grid.Column="3" />
|
||||
|
||||
<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 Margin="20" ColumnDefinitions="*,*,*,*">
|
||||
<Button Text="Pari 1" BackgroundColor="Grey" />
|
||||
<Button Text="Pari 2" Grid.Column="1"/>
|
||||
<Button Text="Pari 3" Grid.Column="2" />
|
||||
<Button Text="Ajouter Pari" Grid.Column="3" Margin="50,0,0,0"/>
|
||||
</Grid>
|
||||
|
||||
<!--P1 vs P2-->
|
||||
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*">
|
||||
<Button Text="Parieur 1" Margin="40,0,0,0"/>
|
||||
<Button Text="+" Grid.Column="1"/>
|
||||
<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"/>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentView x:Name="changeButton" >
|
||||
</ContentView>
|
||||
</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" />
|
||||
</TableSection>
|
||||
</TableRoot>
|
||||
</TableView>
|
||||
|
||||
</VerticalStackLayout>
|
||||
</ContentView>
|
||||
|
@ -1,9 +1,103 @@
|
||||
namespace ParionsCuite.Views.Pari;
|
||||
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;
|
||||
/**
|
||||
* @brief Represents a ContentView for managing bets (Parier) related to a specific event (Evenement).
|
||||
*/
|
||||
public partial class Parier : ContentView
|
||||
{
|
||||
public Parier()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
readonly Evenement EventSelect;
|
||||
Parier PariSelect { get; set; }
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the Parier class.
|
||||
* @param EventSelect The selected event (Evenement).
|
||||
*/
|
||||
public Parier(Evenement EventSelect)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.EventSelect = EventSelect;
|
||||
restorePari(EventSelect);
|
||||
|
||||
EventSelect.PariAdd += OnPariAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores the display of bets (Parier) for the selected event (Evenement).
|
||||
* @param EventSelect The selected event (Evenement).
|
||||
*/
|
||||
private void restorePari(Evenement EventSelect)
|
||||
{
|
||||
int len = 0;
|
||||
Debug.WriteLine("Taille Liste Pari" + EventSelect.ListParier);
|
||||
foreach (Modeles.Parier pari in EventSelect.ListParier)
|
||||
{
|
||||
Debug.WriteLine("But du Pari" + pari.i2.Prenom);
|
||||
|
||||
ColumnDefinition column = new ColumnDefinition();
|
||||
GridPari.ColumnDefinitions.Insert(len, column);
|
||||
|
||||
Button button = new Button();
|
||||
button.Text = "Pari " + (len + 1);
|
||||
Grid.SetRow(button, 0);
|
||||
Grid.SetColumn(button, len);
|
||||
GridPari.Children.Add(button);
|
||||
len++;
|
||||
|
||||
button.Clicked += (sender, e) =>
|
||||
{
|
||||
var newPage = new Views.Pari.InfoPAri(pari);
|
||||
changeButton.Content = newPage;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for the PariAdd event of the selected event (Evenement).
|
||||
* @param obj The added bet (Modeles.Parier) object.
|
||||
*/
|
||||
private void OnPariAdded(Modeles.Parier obj)
|
||||
{
|
||||
int pariCount = GridPari.ColumnDefinitions.Count - 1;
|
||||
|
||||
ColumnDefinition column = new ColumnDefinition();
|
||||
GridPari.ColumnDefinitions.Insert(pariCount + 1, column);
|
||||
|
||||
Button button = new Button();
|
||||
button.Text = "Pari " + (pariCount + 1);
|
||||
Grid.SetRow(button, 0);
|
||||
Grid.SetColumn(button, pariCount + 1);
|
||||
GridPari.Children.Add(button);
|
||||
|
||||
button.Clicked += (sender, e) =>
|
||||
{
|
||||
Debug.WriteLine(obj.But);
|
||||
var newPage = new Views.Pari.InfoPAri(obj);
|
||||
changeButton.Content = newPage;
|
||||
};
|
||||
|
||||
mgr.Save_Data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for the SwitchView button.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void SwitchView(object sender, EventArgs e)
|
||||
{
|
||||
var newPage = new Views.Ajout_Paris.Ajouts_Pari(EventSelect);
|
||||
changeButton.Content = newPage;
|
||||
}
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
<?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.Boisson.Boissons">
|
||||
<VerticalStackLayout>
|
||||
<!--Grid menu-->
|
||||
<Grid Margin="20">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Text="Invité" />
|
||||
<Button Text="Participant" Grid.Column="1"/>
|
||||
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
|
||||
<Button Text="Information" Grid.Column="3" />
|
||||
</Grid>
|
||||
|
||||
<!--Grid Participation-->
|
||||
<Grid ColumnDefinitions="*,*,*">
|
||||
<Button Text="Nourriture" />
|
||||
<Button Text="Boisson" Grid.Column="1" BackgroundColor="Grey"/>
|
||||
<Button Text="Autre" Grid.Column="2" />
|
||||
</Grid>
|
||||
|
||||
<!--Grid Pincipale-->
|
||||
<Grid ColumnDefinitions="*,*,*">
|
||||
|
||||
<!--Input des boissons et quantité-->
|
||||
<StackLayout Grid.Column="0" >
|
||||
<Entry Text="Entrer boisson" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Entry Text="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
|
||||
</StackLayout>
|
||||
|
||||
<!--Grid quantité et boisson + 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é+boisson-->
|
||||
<Label Text="Boisson" 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é+boisson-->
|
||||
<Label Text="Vodka" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
||||
<Label Text="2" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
||||
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
</ContentView>
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?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.Boisson.Drink">
|
||||
|
||||
<VerticalStackLayout>
|
||||
<Grid ColumnDefinitions="5*, 1*, 5*">
|
||||
|
||||
<!--Input des nourritures et quantité-->
|
||||
<StackLayout Grid.Column="0" >
|
||||
<Entry Placeholder="Entrer Boisson" x:Name="DrinkInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Entry Placeholder="Entrer quantité" Keyboard="Numeric" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddDrinklist"/>
|
||||
</StackLayout>
|
||||
|
||||
<!--Grid quantité et nourrite + output -->
|
||||
<Grid Grid.Column="2" x:Name="GridDrink">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto" x:Name="sup"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--Header Grille quantité+nourritre-->
|
||||
<Label Text="Boisson" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||
<Label Text="Quantité" Grid.Column="1" 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,198 @@
|
||||
using ParionsCuite.Modeles;
|
||||
using ParionsCuite.Views.Participations;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ParionsCuite.Views.Participations.Boisson;
|
||||
|
||||
/**
|
||||
* @brief Represents the view for managing drinks in an event.
|
||||
*
|
||||
* This class is a ContentView that displays the list of drinks for a specific event.
|
||||
*/
|
||||
public partial class Drink : ContentView
|
||||
{
|
||||
readonly Evenement EventSelect;
|
||||
|
||||
/**
|
||||
* @brief Gets the instance of the Manageur class from the application's current instance.
|
||||
*/
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the Drink class.
|
||||
*
|
||||
* @param EventSelect The selected event for which the drink list is displayed.
|
||||
*/
|
||||
public Drink(Evenement EventSelect)
|
||||
{
|
||||
this.EventSelect = EventSelect;
|
||||
InitializeComponent();
|
||||
restoreListBoisson(EventSelect);
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores the list of drinks for the specified event and updates the UI to display the drinks.
|
||||
*
|
||||
* @param EventSelect The event for which the drink list is restored.
|
||||
*/
|
||||
public void restoreListBoisson(Evenement EventSelect)
|
||||
{
|
||||
List<Modeles.Boisson> listDrink = EventSelect.Participation.Boissons;
|
||||
Debug.WriteLine("TEst " + listDrink.Count());
|
||||
int len = 1;
|
||||
foreach (Modeles.Boisson food in listDrink)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GridDrink.RowDefinitions.Add(row);
|
||||
|
||||
// AJout Nourriture
|
||||
Label DrinkLabel = new Label();
|
||||
DrinkLabel.Text = food.Nom;
|
||||
Grid.SetRow(DrinkLabel, len);
|
||||
Grid.SetColumn(DrinkLabel, 0);
|
||||
GridDrink.Children.Add(DrinkLabel);
|
||||
|
||||
// Ajout Quantite
|
||||
Label qteLabel = new Label();
|
||||
qteLabel.Text = food.Quantite.ToString();
|
||||
Grid.SetRow(qteLabel, len);
|
||||
Grid.SetColumn(qteLabel, 1);
|
||||
GridDrink.Children.Add(qteLabel);
|
||||
|
||||
// Ajout Bouton
|
||||
Button buttonMoins = new Button();
|
||||
buttonMoins.Text = "-";
|
||||
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
||||
Grid.SetRow(buttonMoins, len);
|
||||
Grid.SetColumn(buttonMoins, 2);
|
||||
GridDrink.Children.Add(buttonMoins);
|
||||
|
||||
len++;
|
||||
Debug.WriteLine("Test test");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Event handler for adding a new drink to the list.
|
||||
*
|
||||
* This method is triggered when the "Add" button is clicked. It retrieves the drink name and quantity from the input fields,
|
||||
* creates a new instance of the Modeles.Boisson class, adds it to the drink list of the selected event, and updates the UI to display the new drink.
|
||||
*
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void AddDrinklist(object sender, EventArgs e)
|
||||
{
|
||||
string drink = DrinkInput.Text;
|
||||
string qte = QteInput.Text;
|
||||
if (int.TryParse(qte, out int value))
|
||||
{
|
||||
if (drink == null || qte == null) { return; }
|
||||
Modeles.Boisson drink1 = new Modeles.Boisson(drink, Int32.Parse(qte));
|
||||
EventSelect.Participation.Boissons.Add(drink1);
|
||||
int len = 1;
|
||||
foreach (Modeles.Boisson food2 in EventSelect.Participation.Boissons)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GridDrink.RowDefinitions.Add(row);
|
||||
|
||||
// AJout Nourriture
|
||||
Label DrinkLabel = new Label();
|
||||
DrinkLabel.Text = food2.Nom;
|
||||
Grid.SetRow(DrinkLabel, len);
|
||||
Grid.SetColumn(DrinkLabel, 0);
|
||||
GridDrink.Children.Add(DrinkLabel);
|
||||
|
||||
// Ajout Quantite
|
||||
Label qteLabel = new Label();
|
||||
qteLabel.Text = food2.Quantite.ToString();
|
||||
Grid.SetRow(qteLabel, len);
|
||||
Grid.SetColumn(qteLabel, 1);
|
||||
GridDrink.Children.Add(qteLabel);
|
||||
|
||||
// Ajout Bouton
|
||||
Button buttonMoins = new Button();
|
||||
buttonMoins.Text = "-";
|
||||
buttonMoins.Clicked += BoutonSupprimer_Clicked;
|
||||
Grid.SetRow(buttonMoins, len);
|
||||
Grid.SetColumn(buttonMoins, 2);
|
||||
GridDrink.Children.Add(buttonMoins);
|
||||
|
||||
len++;
|
||||
Debug.WriteLine("Test test");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
mgr.Save_Data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for removing a drink from the list.
|
||||
*
|
||||
* This method is triggered when the "-" button next to a drink is clicked. It retrieves the selected drink's name and quantity,
|
||||
* searches for the corresponding Modeles.Boisson object in the drink list of the selected event, removes it from the list,
|
||||
* and updates the UI to reflect the changes.
|
||||
*
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
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 DrinkLabel = null;
|
||||
Label qteLabel = 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)
|
||||
DrinkLabel = (Label)child;
|
||||
else if (Grid.GetColumn(child) == 1)
|
||||
qteLabel = (Label)child;
|
||||
}
|
||||
}
|
||||
|
||||
if (DrinkLabel != null && qteLabel != null)
|
||||
{
|
||||
// Récupérer le prénom et le nom de l'invité à supprimer
|
||||
string nom = DrinkLabel.Text;
|
||||
string qte = qteLabel.Text;
|
||||
|
||||
// Rechercher l'invité correspondant dans la liste
|
||||
Modeles.Boisson drink = EventSelect.Participation.Boissons.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
||||
|
||||
if (drink != null)
|
||||
{
|
||||
// Supprimer l'invité de la liste
|
||||
EventSelect.Participation.Boissons.Remove(drink);
|
||||
|
||||
// Supprimer les éléments de la ligne de la grille
|
||||
parentGrid.Children.Remove(DrinkLabel);
|
||||
parentGrid.Children.Remove(qteLabel);
|
||||
parentGrid.Children.Remove(button);
|
||||
parentGrid.RowDefinitions.RemoveAt(rowIndex);
|
||||
}
|
||||
}
|
||||
mgr.Save_Data();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?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é" Keyboard="Numeric" 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" x:Name="GridFood">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto" x:Name="sup"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--Header Grille quantité+nourritre-->
|
||||
<Label Text="Nourriture" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
|
||||
<Label Text="{Binding Nom}" Grid.Column="1" Grid.Row="1" FontSize="Large"/>
|
||||
<Label Text="{Binding Quantite}" Grid.Row="1" FontSize="Large"/>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
</ContentView>
|
@ -0,0 +1,164 @@
|
||||
using ParionsCuite.Modeles;
|
||||
using ParionsCuite.Views.Participations;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ParionsCuite.Views.Participations.NewFolder1;
|
||||
/**
|
||||
* @brief Represents a ContentView for managing food items (Nourriture) related to a specific event (Evenement).
|
||||
*/
|
||||
public partial class Nourri : ContentView
|
||||
{
|
||||
readonly Evenement EventSelect;
|
||||
|
||||
public Manageur mgr => (App.Current as App).MyManager;
|
||||
|
||||
/**
|
||||
* @brief Initializes a new instance of the Nourri class.
|
||||
* @param EventSelect The selected event (Evenement).
|
||||
*/
|
||||
public Nourri(Evenement EventSelect)
|
||||
{
|
||||
this.EventSelect = EventSelect;
|
||||
InitializeComponent();
|
||||
restoreListFood(EventSelect);
|
||||
BindingContext = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores the display of food items (Nourriture) for the selected event (Evenement).
|
||||
* @param EventSelect The selected event (Evenement).
|
||||
*/
|
||||
public void restoreListFood(Evenement EventSelect)
|
||||
{
|
||||
List<Modeles.Nourriture> listFood = EventSelect.Participation.Nourriture;
|
||||
Debug.WriteLine("TEst " + listFood.Count());
|
||||
int len = 1;
|
||||
foreach (Modeles.Nourriture food in listFood)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GridFood.RowDefinitions.Add(row);
|
||||
|
||||
Label foodLabel = new Label();
|
||||
foodLabel.Text = food.Nom.ToString();
|
||||
Debug.WriteLine(foodLabel);
|
||||
Grid.SetRow(foodLabel, len);
|
||||
Grid.SetColumn(foodLabel, 0);
|
||||
GridFood.Children.Add(foodLabel);
|
||||
|
||||
Label qteLabel = new Label();
|
||||
qteLabel.Text = food.Quantite.ToString();
|
||||
Grid.SetRow(qteLabel, len);
|
||||
Grid.SetColumn(qteLabel, 1);
|
||||
GridFood.Children.Add(qteLabel);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for the AddFoodlist button.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void AddFoodlist(object sender, EventArgs e)
|
||||
{
|
||||
string food = FoodInput.Text;
|
||||
string qte = QteInput.Text;
|
||||
if (int.TryParse(qte, out int value))
|
||||
{
|
||||
if (food == null || qte == null) { return; }
|
||||
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
|
||||
EventSelect.Participation.Nourriture.Add(food1);
|
||||
int len = 1;
|
||||
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
|
||||
{
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = new GridLength(45);
|
||||
GridFood.RowDefinitions.Add(row);
|
||||
|
||||
Label foodLabel = new Label();
|
||||
foodLabel.Text = food2.Nom;
|
||||
Grid.SetRow(foodLabel, len);
|
||||
Grid.SetColumn(foodLabel, 0);
|
||||
GridFood.Children.Add(foodLabel);
|
||||
|
||||
Label qteLabel = new Label();
|
||||
qteLabel.Text = food2.Quantite.ToString();
|
||||
Grid.SetRow(qteLabel, len);
|
||||
Grid.SetColumn(qteLabel, 1);
|
||||
GridFood.Children.Add(qteLabel);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
mgr.Save_Data();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event handler for the BoutonSupprimer_Clicked event.
|
||||
* @param sender The object that raised the event.
|
||||
* @param e The event arguments.
|
||||
*/
|
||||
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
Button button = (Button)sender;
|
||||
Grid parentGrid = (Grid)button.Parent;
|
||||
int rowIndex = Grid.GetRow(button);
|
||||
|
||||
Label foodLabel = null;
|
||||
Label qteLabel = null;
|
||||
|
||||
foreach (View child in parentGrid.Children)
|
||||
{
|
||||
int childRowIndex = Grid.GetRow(child);
|
||||
|
||||
if (childRowIndex == rowIndex)
|
||||
{
|
||||
if (Grid.GetColumn(child) == 0)
|
||||
foodLabel = (Label)child;
|
||||
else if (Grid.GetColumn(child) == 1)
|
||||
qteLabel = (Label)child;
|
||||
}
|
||||
}
|
||||
|
||||
if (foodLabel != null && qteLabel != null)
|
||||
{
|
||||
string nom = foodLabel.Text;
|
||||
string qte = qteLabel.Text;
|
||||
|
||||
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
|
||||
|
||||
if (nourriture != null)
|
||||
{
|
||||
EventSelect.Participation.Nourriture.Remove(nourriture);
|
||||
|
||||
parentGrid.Children.Remove(foodLabel);
|
||||
parentGrid.Children.Remove(qteLabel);
|
||||
parentGrid.Children.Remove(button);
|
||||
parentGrid.RowDefinitions.RemoveAt(rowIndex);
|
||||
}
|
||||
}
|
||||
mgr.Save_Data();
|
||||
}
|
||||
}
|
@ -1,58 +1,45 @@
|
||||
<?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.Nourriture">
|
||||
xmlns:model="clr-namespace:ParionsCuite.Modeles"
|
||||
x:Class="ParionsCuite.Views.Participations.Nourriture"
|
||||
xmlns:nourriture="clr-namespace:ParionsCuite.Views.Participations.NewFolder1"
|
||||
>
|
||||
|
||||
<VerticalStackLayout>
|
||||
|
||||
<!--Grid menu-->
|
||||
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
|
||||
<Button Text="Invité" />
|
||||
<Button Text="Participant" Grid.Column="1"/>
|
||||
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
|
||||
<Button Text="Information" Grid.Column="3" />
|
||||
</Grid>
|
||||
|
||||
<!--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 Text="Entrer nourriture" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Entry Text="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
|
||||
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
|
||||
</StackLayout>
|
||||
|
||||
<!--Grid quantité et nourrite + output -->
|
||||
<Grid Grid.Column="2" Margin="30">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="300"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="2*" />
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Text="Nourriture" BackgroundColor="Grey" Clicked="NourritureView" />
|
||||
<Button Text="Boisson" Grid.Column="1" Clicked="BoissonView"/>
|
||||
<Button Text="Autre" Grid.Column="2" Clicked="AutreView" />
|
||||
</Grid>
|
||||
<!--Grid Participation-->
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentView x:Name="changeButton" >
|
||||
</ContentView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!--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-->
|
||||
<Label Text="Pizza" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
||||
<Label Text="2" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
|
||||
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
</ContentView>
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
using ParionsCuite.Modeles;
|
||||
|
||||
namespace TestParionsCuite
|
||||
{
|
||||
public class TestAutre
|
||||
{
|
||||
[Fact]
|
||||
public void TestAutreConstructor()
|
||||
{
|
||||
// Arrange
|
||||
string nom = "chaise";
|
||||
int quantite = 15;
|
||||
|
||||
// Act
|
||||
Autre autre = new Autre(nom, quantite);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(nom, autre.Nom);
|
||||
Assert.Equal(quantite, autre.Quantite);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestAutreToString()
|
||||
{
|
||||
// Arrange
|
||||
Autre autre = new Autre("chaise", 15);
|
||||
string expectedToString = "nom : chaise \n";
|
||||
|
||||
// Act
|
||||
string actualToString = autre.ToString();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedToString, actualToString);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
using ParionsCuite.Modeles;
|
||||
|
||||
namespace TestParionsCuite
|
||||
{
|
||||
public class TestManageur
|
||||
{
|
||||
[Fact]
|
||||
public void TestAjoutEvenement()
|
||||
{
|
||||
// Arrange
|
||||
Manageur manageur = new Manageur();
|
||||
Evenement evenement = new Evenement("EventName", "2023-06-10", "EventLocation", "EventTime", null);
|
||||
|
||||
// Act
|
||||
bool result = manageur.Ajout_evenement(evenement);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
Assert.Contains(evenement, manageur.Evenement);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSupprimerEvenement()
|
||||
{
|
||||
// Arrange
|
||||
Manageur manageur = new Manageur();
|
||||
Evenement evenement = new Evenement("EventName", "2023-06-10", "EventLocation", "EventTime", null);
|
||||
manageur.Ajout_evenement(evenement);
|
||||
|
||||
// Act
|
||||
bool result = manageur.Supprimer_evenement(evenement);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
Assert.DoesNotContain(evenement, manageur.Evenement);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAddInvite()
|
||||
{
|
||||
// Arrange
|
||||
Manageur manageur = new Manageur();
|
||||
Inviter invite1 = new Inviter("John");
|
||||
Inviter invite2 = new Inviter("Jane");
|
||||
|
||||
// Act
|
||||
manageur.AddInvite(invite1);
|
||||
manageur.AddInvite(invite2);
|
||||
|
||||
// Assert
|
||||
Assert.Contains(invite1, manageur.Invites);
|
||||
Assert.Contains(invite2, manageur.Invites);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestRemoveInviter()
|
||||
{
|
||||
// Arrange
|
||||
Manageur manageur = new Manageur();
|
||||
Inviter invite1 = new Inviter("John");
|
||||
Inviter invite2 = new Inviter("Jane");
|
||||
manageur.AddInvite(invite1);
|
||||
manageur.AddInvite(invite2);
|
||||
|
||||
// Act
|
||||
manageur.RemoveInviter(invite1);
|
||||
|
||||
// Assert
|
||||
Assert.DoesNotContain(invite1, manageur.Invites);
|
||||
Assert.Contains(invite2, manageur.Invites);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestLenListInvite()
|
||||
{
|
||||
// Arrange
|
||||
Manageur manageur = new Manageur();
|
||||
Inviter invite1 = new Inviter("John");
|
||||
Inviter invite2 = new Inviter("Jane");
|
||||
manageur.AddInvite(invite1);
|
||||
manageur.AddInvite(invite2);
|
||||
|
||||
// Act
|
||||
int len = manageur.LenListInvite(manageur.Invites);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(2, len);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<SSDTUnitTestPath Condition="'$(SSDTUnitTestPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB</SSDTUnitTestPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SSDTPath Condition="'$(SSDTPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC</SSDTPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Modeles\Modeles.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup Condition="$(VisualStudioVersion) == '17.0'">
|
||||
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />
|
||||
</Project>
|
@ -0,0 +1 @@
|
||||
global using Xunit;
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<add name="Microsoft SqlClient Data Provider"
|
||||
invariant="Microsoft.Data.SqlClient"
|
||||
description="Microsoft SqlClient Data Provider for SqlServer"
|
||||
type="Microsoft.Data.SqlClient.SqlClientFactory, Microsoft.Data.SqlClient" />
|
||||
</DbProviderFactories>
|
||||
</system.data>
|
||||
</configuration>
|
Loading…
Reference in new issue