parent
dcfd36f02e
commit
a3656fb6ca
@ -0,0 +1,14 @@
|
|||||||
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="LOLAPP.View.Login"
|
||||||
|
Title="Login">
|
||||||
|
<StackLayout>
|
||||||
|
<Label Text="Username" />
|
||||||
|
<Entry x:Name="usernameEntry" />
|
||||||
|
<Label Text="Password" />
|
||||||
|
<Entry x:Name="passwordEntry" IsPassword="True" />
|
||||||
|
<Button Text="Login" Clicked="LoginUtilisateur_Clicked" />
|
||||||
|
<Button Text="Logout" Clicked="LogoutUtilisateur_Clicked" />
|
||||||
|
<Button Text="Suprimer" Clicked="SupprimerUtilisateur_Clicked" />
|
||||||
|
</StackLayout>
|
||||||
|
</ContentPage>
|
@ -0,0 +1,93 @@
|
|||||||
|
using Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace LOLAPP.View;
|
||||||
|
|
||||||
|
public partial class Login : ContentPage
|
||||||
|
{
|
||||||
|
public Manager Mgr => (App.Current as App).MyManager;
|
||||||
|
public Login()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
BindingContext = Mgr;
|
||||||
|
}
|
||||||
|
private void LoginUtilisateur_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string username = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
// Vérifier si l'utilisateur existe et les informations de connexion sont valides
|
||||||
|
Utilisateur utilisateur = Mgr._utilisateur.FirstOrDefault(u => u.Username == username && u.Password == password);
|
||||||
|
if (utilisateur != null && Mgr.UtilisateurConnecte == null)
|
||||||
|
{
|
||||||
|
// Connexion réussie
|
||||||
|
Mgr.UtilisateurConnecte = utilisateur;
|
||||||
|
DisplayAlert("Succès", "Connexion réussie", "OK");
|
||||||
|
}
|
||||||
|
else if (Mgr.UtilisateurConnecte != null)
|
||||||
|
{
|
||||||
|
// Utilisateur non connecté
|
||||||
|
DisplayAlert("Erreur", "Vous êtes déjà connecter", "OK");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Informations de connexion incorrectes
|
||||||
|
DisplayAlert("Erreur", "Nom d'utilisateur ou mot de passe incorrect", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
usernameEntry.Text = "";
|
||||||
|
passwordEntry.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LogoutUtilisateur_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string username = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
// Vérifier si l'utilisateur existe et les informations de connexion sont valides
|
||||||
|
Utilisateur utilisateur = Mgr._utilisateur.FirstOrDefault(u => u.Username == username && u.Password == password);
|
||||||
|
if (utilisateur != null && Mgr.UtilisateurConnecte!= null)
|
||||||
|
{
|
||||||
|
// Connexion réussie
|
||||||
|
Mgr.UtilisateurConnecte = null;
|
||||||
|
DisplayAlert("Succès", "Déconnexion réussie", "OK");
|
||||||
|
}
|
||||||
|
else if(Mgr.UtilisateurConnecte == null)
|
||||||
|
{
|
||||||
|
// Utilisateur non connecté
|
||||||
|
DisplayAlert("Erreur", "Vous n'êtes pas connecter", "OK");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Informations de connexion incorrectes
|
||||||
|
DisplayAlert("Erreur", "Nom d'utilisateur ou mot de passe incorrect", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
usernameEntry.Text = "";
|
||||||
|
passwordEntry.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SupprimerUtilisateur_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string username = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
// Recherche de l'utilisateur dans la liste
|
||||||
|
Utilisateur utilisateur = Mgr._utilisateur.FirstOrDefault(u => u.Username == username && u.Password == password);
|
||||||
|
if (utilisateur != null)
|
||||||
|
{
|
||||||
|
// Suppression de l'utilisateur
|
||||||
|
Mgr.RemoveUtilisateur(utilisateur);
|
||||||
|
Mgr.Sauvdon();
|
||||||
|
DisplayAlert("Succès", "Utilisateur supprimé avec succès", "OK");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Utilisateur non trouvé
|
||||||
|
DisplayAlert("Erreur", "Nom d'utilisateur ou mot de passe incorrect", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
usernameEntry.Text = "";
|
||||||
|
passwordEntry.Text = "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,37 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="LOLAPP.View.Main"
|
x:Class="LOLAPP.View.Main"
|
||||||
|
|
||||||
Title="Main">
|
Title="Main">
|
||||||
<StackLayout>
|
<!-- Barre de navigation -->
|
||||||
<!-- Barre de navigation -->
|
<!-- Image à gauche (redirection vers cette page) -->
|
||||||
<StackLayout Orientation="Horizontal" Background="LightGray">
|
<!-- Bouton "Strat" à droite de l'image (redirection vers la page "strat") -->
|
||||||
<!-- Image à gauche (redirection vers cette page) -->
|
<!-- Bouton "Register" -->
|
||||||
<ImageButton Source="CheminVersVotreImage"/>
|
<!-- Bouton "Login" -->
|
||||||
|
<ScrollView>
|
||||||
<!-- Bouton "Strat" à droite de l'image (redirection vers la page "strat") -->
|
|
||||||
<Button Clicked="StratClick" Text="Strat" />
|
|
||||||
|
|
||||||
<!-- Bouton "Register" -->
|
|
||||||
<Button Clicked="RegisterClick" Text="Register"/>
|
|
||||||
|
|
||||||
<!-- Bouton "Login" -->
|
|
||||||
<Button Clicked="LoginClick" Text="Login"/>
|
|
||||||
</StackLayout>
|
|
||||||
|
|
||||||
<!-- Grille d'images avec fenêtres contextuelles -->
|
|
||||||
<HorizontalStackLayout>
|
<HorizontalStackLayout>
|
||||||
<ListView>
|
<!-- Grille d'images avec fenêtres contextuelles -->
|
||||||
<ListView.ItemTemplate>
|
<Grid HorizontalOptions="Start">
|
||||||
<DataTemplate>
|
<Grid.RowDefinitions>
|
||||||
<Image Source="{Binding Image}" Margin="5" />
|
<RowDefinition Height="300" />
|
||||||
</DataTemplate>
|
<RowDefinition Height="300"/>
|
||||||
</ListView.ItemTemplate>
|
</Grid.RowDefinitions>
|
||||||
</ListView>
|
<Grid.ColumnDefinitions>
|
||||||
</HorizontalStackLayout>
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
<ColumnDefinition Width="300" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
</StackLayout>
|
<Image Grid.Row="0" Grid.Column="0" Source="{Binding _champions[0].Image}" >
|
||||||
</ContentPage>
|
<Image.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ImageTapped" />
|
||||||
|
</Image.GestureRecognizers>
|
||||||
|
</Image>
|
||||||
|
<Image Grid.Row="0" Grid.Column="1" Source="{Binding _champions[1].Image}" >
|
||||||
|
<Image.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ImageTapped" />
|
||||||
|
</Image.GestureRecognizers>
|
||||||
|
</Image>
|
||||||
|
<Image Grid.Row="0" Grid.Column="2" Source="{Binding _champions[2].Image}" >
|
||||||
|
<Image.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ImageTapped" />
|
||||||
|
</Image.GestureRecognizers>
|
||||||
|
</Image>
|
||||||
|
<Image Grid.Row="1" Grid.Column="0" Source="{Binding _champions[3].Image}" >
|
||||||
|
<Image.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ImageTapped" />
|
||||||
|
</Image.GestureRecognizers>
|
||||||
|
</Image>
|
||||||
|
<Image Grid.Row="1" Grid.Column="1" Source="{Binding _champions[4].Image}" >
|
||||||
|
<Image.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Tapped="ImageTapped" />
|
||||||
|
</Image.GestureRecognizers>
|
||||||
|
</Image>
|
||||||
|
</Grid>
|
||||||
|
<!-- Ajoutez d'autres images pour les champions suivants -->
|
||||||
|
<StackLayout WidthRequest="530" BackgroundColor="DarkGrey">
|
||||||
|
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
|
||||||
|
<Label x:Name="championNameLabel" FontSize="20" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="championTitreLabel" FontSize="16" HorizontalOptions="Center" />
|
||||||
|
<Image x:Name="abilityimage1" Margin="1" HeightRequest="50" WidthRequest="50"/>
|
||||||
|
<Label x:Name="abilityname1" FontSize="17" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="abilitydesc1" FontSize="14" HorizontalOptions="Center" />
|
||||||
|
<Image x:Name="abilityimage2" Margin="1" HeightRequest="50" WidthRequest="50"/>
|
||||||
|
<Label x:Name="abilityname2" FontSize="17" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="abilitydesc2" FontSize="14" HorizontalOptions="Center" />
|
||||||
|
<Image x:Name="abilityimage3" Margin="1" HeightRequest="50" WidthRequest="50"/>
|
||||||
|
<Label x:Name="abilityname3" FontSize="17" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="abilitydesc3" FontSize="14" HorizontalOptions="Center" />
|
||||||
|
<Image x:Name="abilityimage4" Margin="1" HeightRequest="50" WidthRequest="50"/>
|
||||||
|
<Label x:Name="abilityname4" FontSize="17" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="abilitydesc4" FontSize="14" HorizontalOptions="Center" />
|
||||||
|
<Image x:Name="abilityimage5" Margin="1" HeightRequest="50" WidthRequest="50"/>
|
||||||
|
<Label x:Name="abilityname5" FontSize="17" HorizontalOptions="Center" />
|
||||||
|
<Label x:Name="abilitydesc5" FontSize="14" HorizontalOptions="Center" />
|
||||||
|
</StackLayout>
|
||||||
|
</StackLayout>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
</ScrollView>
|
||||||
|
</ContentPage>
|
||||||
|
@ -1,23 +1,57 @@
|
|||||||
using LOLAPP.Modele;
|
using Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace LOLAPP.View;
|
namespace LOLAPP.View;
|
||||||
|
|
||||||
public partial class Main : ContentPage
|
public partial class Main : ContentPage
|
||||||
{
|
{
|
||||||
|
public Manager Mgr => (App.Current as App).MyManager;
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
{
|
{
|
||||||
Manager CManager = new Manager();
|
|
||||||
BindingContext = CManager._champions;
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
BindingContext = Mgr;
|
||||||
private void StratClick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterClick(object sender, EventArgs e)
|
private void ImageTapped(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Champion champ= null;
|
||||||
|
var image = (Image)sender;
|
||||||
|
foreach (var champion in Mgr._champions)
|
||||||
|
{
|
||||||
|
//Debug.WriteLine(image.Source.ToString());
|
||||||
|
if ("File: " + champion.Image == image.Source.ToString())
|
||||||
|
{
|
||||||
|
//Debug.WriteLine(champion.Image + " 2");
|
||||||
|
champ = champion;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//var champion = manager._champions.FirstOrDefault(c => c.Image == image.Source.ToString()); ;
|
||||||
|
if (champ != null)
|
||||||
|
{
|
||||||
|
//Debug.WriteLine(champ.Name + " 3");
|
||||||
|
// Mettre à jour les labels des détails du champion
|
||||||
|
championNameLabel.Text = champ.Name;
|
||||||
|
championTitreLabel.Text = champ.Titre;
|
||||||
|
//Debug.WriteLine(champ.Abilities[0].Image);
|
||||||
|
abilityimage1.Source = champ.Abilities[0].Image;
|
||||||
|
abilityname1.Text = champ.Abilities[0].Name;
|
||||||
|
abilitydesc1.Text = champ.Abilities[0].Description;
|
||||||
|
abilityimage2.Source = champ.Abilities[1].Image;
|
||||||
|
abilityname2.Text = champ.Abilities[1].Name;
|
||||||
|
abilitydesc2.Text = champ.Abilities[1].Description;
|
||||||
|
abilityimage3.Source = champ.Abilities[2].Image;
|
||||||
|
abilityname3.Text = champ.Abilities[2].Name;
|
||||||
|
abilitydesc3.Text = champ.Abilities[2].Description;
|
||||||
|
abilityimage4.Source = champ.Abilities[3].Image;
|
||||||
|
abilityname4.Text = champ.Abilities[3].Name;
|
||||||
|
//Debug.WriteLine(champ.Abilities[3].Image);
|
||||||
|
abilitydesc4.Text = champ.Abilities[3].Description;
|
||||||
|
abilityimage5.Source = champ.Abilities[4].Image;
|
||||||
|
abilityname5.Text = champ.Abilities[4].Name;
|
||||||
|
abilitydesc5.Text = champ.Abilities[4].Description;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginClick(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="LOLAPP.View.Register"
|
x:Class="LOLAPP.View.Register"
|
||||||
Title="Register">
|
Title="Register">
|
||||||
<VerticalStackLayout>
|
<StackLayout>
|
||||||
<Label
|
<Label Text="Username" />
|
||||||
Text="Welcome to .NET MAUI!"
|
<Entry x:Name="usernameEntry" />
|
||||||
VerticalOptions="Center"
|
<Label Text="Password" />
|
||||||
HorizontalOptions="Center" />
|
<Entry x:Name="passwordEntry" IsPassword="True" />
|
||||||
</VerticalStackLayout>
|
<Button Text="Enregistrer" Clicked="EnregistrerUtilisateur_Clicked" />
|
||||||
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
@ -1,9 +1,35 @@
|
|||||||
|
using Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace LOLAPP.View;
|
namespace LOLAPP.View;
|
||||||
|
|
||||||
public partial class Register : ContentPage
|
public partial class Register : ContentPage
|
||||||
{
|
{
|
||||||
public Register()
|
public Manager Mgr => (App.Current as App).MyManager;
|
||||||
|
|
||||||
|
public Register()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
BindingContext= Mgr;
|
||||||
}
|
}
|
||||||
|
private void EnregistrerUtilisateur_Clicked(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string username = usernameEntry.Text;
|
||||||
|
string password = passwordEntry.Text;
|
||||||
|
|
||||||
|
if (Mgr._utilisateur.Any(u => u.Username == username))
|
||||||
|
{
|
||||||
|
DisplayAlert("Erreur", "Cet utilisateur existe déjà", "OK");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utilisateur utilisateur = new Utilisateur(username, password);
|
||||||
|
Mgr.AddUtilisateur(utilisateur);
|
||||||
|
Mgr.Sauvdon();
|
||||||
|
|
||||||
|
DisplayAlert("Succès", "Utilisateur enregistré avec succès", "OK");
|
||||||
|
|
||||||
|
usernameEntry.Text = "";
|
||||||
|
passwordEntry.Text = "";
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,12 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="LOLAPP.View.Strat"
|
x:Class="LOLAPP.View.Strat"
|
||||||
Title="Strat">
|
Title="Strat">
|
||||||
<VerticalStackLayout>
|
<StackLayout BackgroundColor="DarkGrey">
|
||||||
<Label
|
<Grid>
|
||||||
Text="Welcome to .NET MAUI!"
|
<Grid.ColumnDefinitions>
|
||||||
VerticalOptions="Center"
|
<ColumnDefinition Width="*" />
|
||||||
HorizontalOptions="Center" />
|
<ColumnDefinition Width="*" />
|
||||||
</VerticalStackLayout>
|
</Grid.ColumnDefinitions>
|
||||||
|
<ListView x:Name="stratListView"
|
||||||
|
Grid.Column="0"
|
||||||
|
ItemsSource="{Binding StratList}"
|
||||||
|
/>
|
||||||
|
<!-- SelectedItemChanged="StratListView_OnItemSelected"-->
|
||||||
|
<StackLayout x:Name="detailsLayout"
|
||||||
|
Grid.Column="1">
|
||||||
|
<Label x:Name="nameLabel"
|
||||||
|
FontSize="Large" />
|
||||||
|
<StackLayout x:Name="championsLayout"
|
||||||
|
Orientation="Horizontal" />
|
||||||
|
<Label x:Name="descriptionLabel" />
|
||||||
|
</StackLayout>
|
||||||
|
</Grid>
|
||||||
|
</StackLayout>
|
||||||
</ContentPage>
|
</ContentPage>
|
@ -1,9 +1,46 @@
|
|||||||
namespace LOLAPP.View;
|
using Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
public partial class Strat : ContentPage
|
namespace LOLAPP.View
|
||||||
{
|
{
|
||||||
public Strat()
|
public partial class Strat : ContentPage
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
public List<Strategie> StratList { get; set; }
|
||||||
}
|
public Manager Mgr => (App.Current as App).MyManager;
|
||||||
|
public Strat()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Initialisez la liste des stratégies
|
||||||
|
StratList = Mgr.UtilisateurConnecte._strat;
|
||||||
|
|
||||||
|
// Liez la liste des stratégies à la ListView
|
||||||
|
// stratListView.ItemsSource = StratList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private void StratListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.SelectedItem is Strategie selectedStrat)
|
||||||
|
{
|
||||||
|
UpdateDetails(selectedStrat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDetails(Strategie strat)
|
||||||
|
{
|
||||||
|
nameLabel.Text = strat.Name;
|
||||||
|
|
||||||
|
championsLayout.Children.Clear();
|
||||||
|
foreach (var champion in strat.Champions.Take(5))
|
||||||
|
{
|
||||||
|
var image = new Image
|
||||||
|
{
|
||||||
|
Source = champion.Image
|
||||||
|
};
|
||||||
|
championsLayout.Children.Add(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
descriptionLabel.Text = strat.Description;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Models\Models.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in new issue