From 3af4ba130791f91c7d92d4aba64a6add52101f79 Mon Sep 17 00:00:00 2001 From: Anthony RICHARD Date: Tue, 16 May 2023 19:29:26 +0200 Subject: [PATCH] test binding, affichage de la gamelist --- Sources/Stim.Model/Game.cs | 7 ++- Sources/Stim.Model/Manager.cs | 7 ++- Sources/Stim.Model/Persistable.cs | 23 ------- Sources/Stim/MainPage.xaml | 99 +++++++++++++------------------ Sources/Stim/MainPage.xaml.cs | 7 +++ Sources/Stim/Stim.csproj | 5 ++ 6 files changed, 64 insertions(+), 84 deletions(-) delete mode 100644 Sources/Stim.Model/Persistable.cs diff --git a/Sources/Stim.Model/Game.cs b/Sources/Stim.Model/Game.cs index 879f53e..fc8e0e8 100644 --- a/Sources/Stim.Model/Game.cs +++ b/Sources/Stim.Model/Game.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Model { - public class Game + public class Game : INotifyPropertyChanged { public string Name { @@ -43,7 +44,7 @@ namespace Model public string[] Tags { - get { return tags; } + get => tags; set { if (value == null || value.Length != 3) return; @@ -52,6 +53,8 @@ namespace Model } private string[]? tags; + public event PropertyChangedEventHandler? PropertyChanged; + public List Reviews { get; private init; } public Game(string name, string description, int year, string[] tags) diff --git a/Sources/Stim.Model/Manager.cs b/Sources/Stim.Model/Manager.cs index d07a691..d74e375 100644 --- a/Sources/Stim.Model/Manager.cs +++ b/Sources/Stim.Model/Manager.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -8,13 +9,15 @@ namespace Model { public class Manager { - public List Games = new(); + public ObservableCollection Games { get; set; } = new(); private IPersistance _persistance; public Manager(IPersistance persistance) { _persistance = persistance; - Games = _persistance.LoadGame(); + Games.Add(new("test", "description", 2010, new string[3] { "1", "2", "3" })); + Games.Add(new("test2", "description", 2010, new string[3] { "1", "2", "3" })); + Games.Add(new("test2", "description", 2010, new string[3] { "1", "2", "3" })); } } } diff --git a/Sources/Stim.Model/Persistable.cs b/Sources/Stim.Model/Persistable.cs deleted file mode 100644 index 79e9606..0000000 --- a/Sources/Stim.Model/Persistable.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace Model -{ - public interface Persistable - { - public void Load() - { - Console.WriteLine("Todo"); - //To do - } - public void Save(List gamesList) - { - Console.WriteLine("Todo"); - //To do - } - } -} diff --git a/Sources/Stim/MainPage.xaml b/Sources/Stim/MainPage.xaml index e1dbcbd..8762bba 100644 --- a/Sources/Stim/MainPage.xaml +++ b/Sources/Stim/MainPage.xaml @@ -14,75 +14,60 @@ - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - diff --git a/Sources/Stim/MainPage.xaml.cs b/Sources/Stim/MainPage.xaml.cs index de82315..5e2b7c8 100644 --- a/Sources/Stim/MainPage.xaml.cs +++ b/Sources/Stim/MainPage.xaml.cs @@ -1,10 +1,17 @@ namespace Stim; +using Model; +using StimPersistance; public partial class MainPage : ContentPage { + public IPersistance persistance = new Persistance(); + public Manager Manager; + public MainPage() { InitializeComponent(); + Manager = new(persistance); + BindingContext = Manager; } private async void Button_Clicked(object sender, EventArgs e) diff --git a/Sources/Stim/Stim.csproj b/Sources/Stim/Stim.csproj index fcd0544..4ea8ed9 100644 --- a/Sources/Stim/Stim.csproj +++ b/Sources/Stim/Stim.csproj @@ -50,6 +50,11 @@ + + + + + MSBuild:Compile