DataBinding
Vianney JOURDY 2 years ago
commit cf490830d0

@ -18,7 +18,7 @@ public partial class App : Application
MyManager.Admins.Add(MyAdmin);
MainPage = new AppShell();
//MyManager.Persistance = new DataContract();
MyManager.Persistance = new DataContract();
MyManager.sauvegarder();
}

@ -7,9 +7,15 @@
xmlns:Views="clr-namespace:MangaMap.Views"
Shell.FlyoutBehavior="Disabled"
Shell.NavBarIsVisible="False"
Shell.TabBarIsVisible="False">
Shell.TabBarIsVisible="True">
<TabBar Route="page">
<ShellContent
Title="HomeDisconnect"
ContentTemplate="{DataTemplate Views:homePageDisconnect}"
Route="homePageDisconnect" />
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate Views:homePage}"

@ -1,3 +1,4 @@
<<<<<<< HEAD
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
@ -104,3 +105,114 @@
</ItemGroup>
</Project>
=======
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>MangaMap</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>MangaMap</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.mangamap</ApplicationId>
<ApplicationIdGuid>61196d0c-418f-4fb6-8dc5-c920275e1035</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<AndroidResource Remove="Component\**" />
<Compile Remove="Component\**" />
<EmbeddedResource Remove="Component\**" />
<MauiCss Remove="Component\**" />
<MauiXaml Remove="Component\**" />
<None Remove="Component\**" />
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\logo.png" />
<None Remove="Resources\Images\settings.png" />
<None Remove="Resources\Images\test.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="CustomHeader.xaml.cs">
<DependentUpon>CustomHeader.xaml</DependentUpon>
</Compile>
<Compile Update="Views\signUpPage.xaml.cs">
<DependentUpon>signUpPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<MauiXaml Update="CustomHeader.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Resources\Theme\DarkTheme.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Composants\StyleBouton.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\homePage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\homePageDisconnect.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\listPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\loginPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\settingsPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\signUpPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
>>>>>>> Mathéo

@ -8,23 +8,29 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace MangaMap.Stub
{
public class DataContract : IPersistanceManager
{
public string FileName { get; set; } = "SauvegardeDonnees.xml";
public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
//public string FilePath2 { get; set; } = "C:\\Users\\vjour\\UCA\\MapManga\\MangaMap";
//public string FilePath2 { get; set; } = Path.Combine(Directory.GetCurrentDirectory(), "\\..\\..\\Users");
public (List<Oeuvre>, List<Utilisateur>) chargeDonne()
{
var serializer = new DataContractSerializer(typeof(DataToPersist));
DataToPersist data;
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
if (File.Exists(Path.Combine(FilePath, FileName))) // Vérifiez si le fichier existe
{
data = serializer.ReadObject(s) as DataToPersist;
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
{
data = serializer.ReadObject(s) as DataToPersist;
}
}
else
{
data = new DataToPersist(); // Si le fichier n'existe pas, créez une nouvelle liste
}
return (data.Oeuvres, data.Utilisateurs);
@ -34,29 +40,43 @@ namespace MangaMap.Stub
{
var serializer = new DataContractSerializer(typeof(DataToPersist));
if(!Directory.Exists(FilePath))
DataToPersist data;
if (File.Exists(Path.Combine(FilePath, FileName)))
{
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
{
data = serializer.ReadObject(s) as DataToPersist;
}
}
else
{
Debug.WriteLine("Directory doesn't exist.");
Directory.CreateDirectory(FilePath);
data = new DataToPersist();
}
/*using (Stream s = File.Create(Path.Combine(FilePath, FileName)))
// Vérifier si un utilisateur avec le même nom d'utilisateur existe déjà
var existingUser = data.Utilisateurs.FirstOrDefault(user => user.Pseudo == u.Last().Pseudo);
if (existingUser != null)
{
serializer.WriteObject(s, o); //Version d'enregistrement des données sans indentation.
}*/
// Mettre à jour l'utilisateur existant
existingUser.MotDePasse = u.Last().MotDePasse;
existingUser.Email = u.Last().Email;
DataToPersist data = new DataToPersist();
data.Oeuvres = o;
data.Utilisateurs = u;
}
else
{
// Ajouter le nouvel utilisateur à la liste existante
data.Utilisateurs.Add(u.Last());
}
var settings = new XmlWriterSettings() { Indent = true };
using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName)))
{
using (XmlWriter w = XmlWriter.Create(tw, settings))
{
serializer.WriteObject(w, data); //Version d'enregistrement des données avec indentation.
serializer.WriteObject(w, data); // Enregistrer toutes les données dans le fichier
}
}
}
}
}

@ -13,3 +13,4 @@ public partial class homePage : ContentPage
a2.BindingContext = my_manager;
}
}

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MangaMap"
x:Class="MangaMap.Views.homePageDisconnect"
xmlns:modeles="clr-namespace:MangaMap.Model"
xmlns:views="clr-namespace:MangaMap.Views.Composants">
<ContentPage.BindingContext>
<modeles:Manager/>
</ContentPage.BindingContext>
<Grid RowDefinitions="40, *">
<local:NewContent1 HeightRequest="40" VerticalOptions="Start" Padding="10, 0"/>
<ScrollView
BackgroundColor="#1E1E1E"
Grid.Row="1">
<VerticalStackLayout
Spacing="70"
VerticalOptions="Center">
<SearchBar Placeholder="Recherche"
CancelButtonColor="Orange"
TextColor="Black"
BackgroundColor="White"
HorizontalTextAlignment="Center"
Margin="30"
/>
<ListView x:Name="a2" ItemsSource="{Binding Oeuvres}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ImageButton
Style="{StaticResource ImageAnime}"
BackgroundColor="Red"
Source="{Binding Affiche}"
/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<HorizontalStackLayout
Spacing="100"
HorizontalOptions="Center">
<views:StyleBouton/>
<ImageButton
Style="{StaticResource ImageAnime}"
BackgroundColor="Orange"
Source="test.jpg"
/>
<views:StyleBouton/>
<views:StyleBouton/>
</HorizontalStackLayout>
<HorizontalStackLayout
Spacing="100"
HorizontalOptions="Center">
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
</HorizontalStackLayout>
<HorizontalStackLayout
Spacing="100"
HorizontalOptions="Center">
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
</HorizontalStackLayout>
<HorizontalStackLayout
Spacing="100"
HorizontalOptions="Center">
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
<views:StyleBouton/>
</HorizontalStackLayout>
<ListView x:Name="a1" ItemsSource="{Binding Utilisateurs}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding Pseudo}" TextColor="White" FontSize="Header"/>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ScrollView>
</Grid>
</ContentPage>

@ -0,0 +1,9 @@
namespace MangaMap.Views;
public partial class homePageDisconnect : ContentPage
{
public homePageDisconnect()
{
InitializeComponent();
}
}

@ -1,10 +1,13 @@
namespace MangaMap.Views;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MangaMap.Stub;
using MangaMap.Model;
public partial class loginPage : ContentPage
{
public loginPage()
public loginPage()
{
InitializeComponent();
}
@ -25,18 +28,32 @@ public partial class loginPage : ContentPage
// Vérifier que l'e-mail a la bonne forme
if (!Regex.IsMatch(email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$"))
{
await DisplayAlert("Erreur", "L'e-mail n'est pas valide.", "OK");
await DisplayAlert("Erreur", "L'email n'est pas valide.", "OK");
return;
}
// Vérification du mot de passe
if (password != "monmotdepasse")
// Charger les données à partir de la persistance
IPersistanceManager persistanceManager = new DataContract();
(List<Oeuvre> oeuvres, List<Utilisateur> utilisateurs) = persistanceManager.chargeDonne();
// Vérifier que l'utilisateur existe
Utilisateur utilisateur = utilisateurs.FirstOrDefault(u => u.Email == email && u.MotDePasse == password);
if (utilisateur == null)
{
<<<<<<< HEAD
await DisplayAlert("Erreur", "Le mot de passe entré est incorrect.", "OK");
return;
}
// Redirection vers la page suivante si le mot de passe est correct
=======
await DisplayAlert("Erreur", "L'e-mail ou le mot de passe est incorrect.", "OK");
return;
}
// Rediriger l'utilisateur vers la page principale
>>>>>>> Mathéo
await Navigation.PushAsync(new homePage());
}
}

@ -10,7 +10,7 @@
<StackLayout VerticalOptions="Center" HorizontalOptions="Center" Grid.Row="1">
<Button Text="Deconnexion" Clicked="OnLoginClicked" Margin="0,0,0,30" Style="{StaticResource Bouton}"/>
<Button Text="Deconnexion" Clicked="OnDisconnectClicked" Margin="0,0,0,30" Style="{StaticResource Bouton}"/>
<Button Text="Connexion/Inscription" Clicked="OnLoginClicked" Style="{StaticResource Bouton}"/>

@ -7,6 +7,11 @@ public partial class settingsPage : ContentPage
InitializeComponent();
}
private async void OnDisconnectClicked(object sender, EventArgs e)
{
await Shell.Current.Navigation.PushAsync(new loginPage());
}
private void OnLoginClicked(object sender, EventArgs e)
{
//

@ -62,9 +62,12 @@ public partial class signUpPage : ContentPage
{
Utilisateur util = new Utilisateur(email, pseudo, password, nom, prenom, age);
my_manager.Utilisateurs.Add(util);
my_manager.sauvegarder();
await Navigation.PushAsync(new homePage());
return;
}
}
bool IsPasswordStrong(string password)

Loading…
Cancel
Save