From 2f2451465c7c5b035f33192acb1b518a548613b1 Mon Sep 17 00:00:00 2001 From: Clement LESME Date: Wed, 10 May 2023 09:44:47 +0200 Subject: [PATCH] boutton credits ok, nouveau boutton quitter, chargement/sauvegarde donnee en cours --- CanYouBuildIt/App.xaml.cs | 6 ++-- .../DataContractPers.cs | 28 ++++++++++++++++++ ...IUtilisateur.cs => IPersistanceManager.cs} | 27 +++++++++-------- CanYouBuildIt/Model/Manager.cs | 22 +++++++++++--- CanYouBuildIt/Model/Stub.cs | 29 +++++++++++++++++++ CanYouBuildIt/Model/Utilisateur.cs | 5 ++-- CanYouBuildIt/Views/Acceuil.xaml | 12 ++++++-- CanYouBuildIt/Views/Acceuil.xaml.cs | 8 +++-- CanYouBuildIt/Views/Credits.xaml | 18 +++++++++--- CanYouBuildIt/Views/Credits.xaml.cs | 24 ++++++++++++--- 10 files changed, 147 insertions(+), 32 deletions(-) create mode 100644 CanYouBuildIt/DataContractPersistance/DataContractPers.cs rename CanYouBuildIt/Model/{IUtilisateur.cs => IPersistanceManager.cs} (50%) create mode 100644 CanYouBuildIt/Model/Stub.cs diff --git a/CanYouBuildIt/App.xaml.cs b/CanYouBuildIt/App.xaml.cs index aaba653..705b70a 100644 --- a/CanYouBuildIt/App.xaml.cs +++ b/CanYouBuildIt/App.xaml.cs @@ -4,10 +4,12 @@ namespace CanYouBuildIt; public partial class App : Application { - public Manager Manager { get; private set; } = new Manager(); + public Manager manager { get; private set; } = new Manager(new Stub()); public App() { - Manager.chargeDonne(); + manager.chargeDonne(); + manager.Persi = new DataContractPersistance.DataContractPers(); + manager.Persi.sauvegardeDonnee(manager.listUtil); InitializeComponent(); MainPage = new AppShell(); diff --git a/CanYouBuildIt/DataContractPersistance/DataContractPers.cs b/CanYouBuildIt/DataContractPersistance/DataContractPers.cs new file mode 100644 index 0000000..e4fabc3 --- /dev/null +++ b/CanYouBuildIt/DataContractPersistance/DataContractPers.cs @@ -0,0 +1,28 @@ +using CanYouBuildIt.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace CanYouBuildIt.DataContractPersistance +{ + public class DataContractPers : IPersistanceManager + { + public DataContractPers() { } + + public List chargeDonnee() + { + var serializer = new DataContractSerializer(typeof(Utilisateur)); + List lu = new List(); + return lu; + } + + public bool sauvegardeDonnee(List lu) + { + + return true; + } + } +} diff --git a/CanYouBuildIt/Model/IUtilisateur.cs b/CanYouBuildIt/Model/IPersistanceManager.cs similarity index 50% rename from CanYouBuildIt/Model/IUtilisateur.cs rename to CanYouBuildIt/Model/IPersistanceManager.cs index e057cbe..9d0624a 100644 --- a/CanYouBuildIt/Model/IUtilisateur.cs +++ b/CanYouBuildIt/Model/IPersistanceManager.cs @@ -1,12 +1,15 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CanYouBuildIt.Model -{ - internal class IUtilisateur - { - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CanYouBuildIt.Model +{ + public interface IPersistanceManager + { + public List chargeDonnee(); + + public bool sauvegardeDonnee(List lu); + } +} diff --git a/CanYouBuildIt/Model/Manager.cs b/CanYouBuildIt/Model/Manager.cs index ba4b366..9ba12f0 100644 --- a/CanYouBuildIt/Model/Manager.cs +++ b/CanYouBuildIt/Model/Manager.cs @@ -10,17 +10,31 @@ namespace CanYouBuildIt.Model public class Manager { public List listUtil { get; private set; } + public IPersistanceManager Persi; - public Manager() + public Manager() { listUtil = new List(); } + public Manager(IPersistanceManager pers) + { + listUtil = new List(); + Persi = pers; + } public void chargeDonne() { - Utilisateur gege =new Utilisateur("gerad","gege"); - listUtil.Add(gege); - Console.WriteLine("SJBEVKBV chargeDonnee() + { + List lu = new List(); + Utilisateur n1 = new Utilisateur("Clément", "1234"); + Utilisateur n2 = new Utilisateur("Vivien", "vivien"); + Utilisateur n3 = new Utilisateur("Kevin", "0000"); + lu.Add(n1); + lu.Add(n2); + lu.Add(n3); + return lu; + } + + public bool sauvegardeDonnee(List lu) + { + return true; + } + } +} diff --git a/CanYouBuildIt/Model/Utilisateur.cs b/CanYouBuildIt/Model/Utilisateur.cs index 9689c7e..dc26f36 100644 --- a/CanYouBuildIt/Model/Utilisateur.cs +++ b/CanYouBuildIt/Model/Utilisateur.cs @@ -13,10 +13,11 @@ namespace CanYouBuildIt.Model public List listBuild; - public Utilisateur(string name, string pasword, List listBuild = null) + public Utilisateur(string name, string pass, List listbuild = null) { username = name; - password = pasword; + password = pass; + listBuild = listbuild; } } } diff --git a/CanYouBuildIt/Views/Acceuil.xaml b/CanYouBuildIt/Views/Acceuil.xaml index 4ac402c..d03ca90 100644 --- a/CanYouBuildIt/Views/Acceuil.xaml +++ b/CanYouBuildIt/Views/Acceuil.xaml @@ -79,7 +79,7 @@ TextColor="Snow" Clicked="NavFav"/> - @@ -88,7 +88,15 @@ - + +