diff --git a/MVVM/.vs/MVVM/DesignTimeBuild/.dtbcache.v2 b/MVVM/.vs/MVVM/DesignTimeBuild/.dtbcache.v2 index 8334a232..cc894555 100644 Binary files a/MVVM/.vs/MVVM/DesignTimeBuild/.dtbcache.v2 and b/MVVM/.vs/MVVM/DesignTimeBuild/.dtbcache.v2 differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/0db91482-f61b-4814-8649-1a90ca157933.vsidx b/MVVM/.vs/MVVM/FileContentIndex/0db91482-f61b-4814-8649-1a90ca157933.vsidx new file mode 100644 index 00000000..2a7d0f77 Binary files /dev/null and b/MVVM/.vs/MVVM/FileContentIndex/0db91482-f61b-4814-8649-1a90ca157933.vsidx differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/1b3fdc2a-046e-49c1-aae8-210e68f58830.vsidx b/MVVM/.vs/MVVM/FileContentIndex/1b3fdc2a-046e-49c1-aae8-210e68f58830.vsidx deleted file mode 100644 index 514c029c..00000000 Binary files a/MVVM/.vs/MVVM/FileContentIndex/1b3fdc2a-046e-49c1-aae8-210e68f58830.vsidx and /dev/null differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/3d850498-08fb-4f19-bfdb-eb40b67861bc.vsidx b/MVVM/.vs/MVVM/FileContentIndex/3d850498-08fb-4f19-bfdb-eb40b67861bc.vsidx new file mode 100644 index 00000000..6aaf6125 Binary files /dev/null and b/MVVM/.vs/MVVM/FileContentIndex/3d850498-08fb-4f19-bfdb-eb40b67861bc.vsidx differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/4dd6867a-0428-4404-be7c-9058d5bd6d82.vsidx b/MVVM/.vs/MVVM/FileContentIndex/4dd6867a-0428-4404-be7c-9058d5bd6d82.vsidx new file mode 100644 index 00000000..6c0c41ad Binary files /dev/null and b/MVVM/.vs/MVVM/FileContentIndex/4dd6867a-0428-4404-be7c-9058d5bd6d82.vsidx differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/4ecebbe7-76f3-4bee-857c-364534082fe9.vsidx b/MVVM/.vs/MVVM/FileContentIndex/4ecebbe7-76f3-4bee-857c-364534082fe9.vsidx deleted file mode 100644 index 39ec8b09..00000000 Binary files a/MVVM/.vs/MVVM/FileContentIndex/4ecebbe7-76f3-4bee-857c-364534082fe9.vsidx and /dev/null differ diff --git a/MVVM/.vs/MVVM/FileContentIndex/c9fe4f59-ac24-4cc3-90bf-a303d665c8d7.vsidx b/MVVM/.vs/MVVM/FileContentIndex/c9fe4f59-ac24-4cc3-90bf-a303d665c8d7.vsidx deleted file mode 100644 index a225c8a8..00000000 Binary files a/MVVM/.vs/MVVM/FileContentIndex/c9fe4f59-ac24-4cc3-90bf-a303d665c8d7.vsidx and /dev/null differ diff --git a/MVVM/.vs/MVVM/v17/.futdcache.v2 b/MVVM/.vs/MVVM/v17/.futdcache.v2 index a2f13ab8..30caf83c 100644 Binary files a/MVVM/.vs/MVVM/v17/.futdcache.v2 and b/MVVM/.vs/MVVM/v17/.futdcache.v2 differ diff --git a/MVVM/.vs/MVVM/v17/.suo b/MVVM/.vs/MVVM/v17/.suo index 0809513a..fcade76c 100644 Binary files a/MVVM/.vs/MVVM/v17/.suo and b/MVVM/.vs/MVVM/v17/.suo differ diff --git a/MVVM/.vs/ProjectEvaluation/mvvm.metadata.v7.bin b/MVVM/.vs/ProjectEvaluation/mvvm.metadata.v7.bin index 1e5a3beb..ac32e33f 100644 Binary files a/MVVM/.vs/ProjectEvaluation/mvvm.metadata.v7.bin and b/MVVM/.vs/ProjectEvaluation/mvvm.metadata.v7.bin differ diff --git a/MVVM/.vs/ProjectEvaluation/mvvm.projects.v7.bin b/MVVM/.vs/ProjectEvaluation/mvvm.projects.v7.bin index f62c8bb5..dbdf0de0 100644 Binary files a/MVVM/.vs/ProjectEvaluation/mvvm.projects.v7.bin and b/MVVM/.vs/ProjectEvaluation/mvvm.projects.v7.bin differ diff --git a/MVVM/MVVM/MVVM.csproj.user b/MVVM/MVVM/MVVM.csproj.user index 606cc6df..5e16a87c 100644 --- a/MVVM/MVVM/MVVM.csproj.user +++ b/MVVM/MVVM/MVVM.csproj.user @@ -3,7 +3,7 @@ False net7.0-android - Samsung SM-A705FN (Android 11.0 - API 30) + Émulateur Android PhysicalDevice diff --git a/MVVM/MVVM/Pages/MyLibraryPage.xaml.cs b/MVVM/MVVM/Pages/MyLibraryPage.xaml.cs index da91112e..f57c4bc9 100644 --- a/MVVM/MVVM/Pages/MyLibraryPage.xaml.cs +++ b/MVVM/MVVM/Pages/MyLibraryPage.xaml.cs @@ -4,10 +4,11 @@ namespace MVVM.Pages; public partial class MyLibraryPage : ContentPage { - public NavigationViewModel navigationViewModel { get; set;} = new NavigationViewModel(); + public NavigateAndLoadBooks navigationViewModel { get; set;} - public MyLibraryPage() + public MyLibraryPage(NavigateAndLoadBooks navigateAndLoadBooks) { + this.navigationViewModel = navigateAndLoadBooks; InitializeComponent(); BindingContext = this; } diff --git a/MVVM/MVVM/ViewModel/NavigateAndLoadBooks.cs b/MVVM/MVVM/ViewModel/NavigateAndLoadBooks.cs new file mode 100644 index 00000000..12544d4d --- /dev/null +++ b/MVVM/MVVM/ViewModel/NavigateAndLoadBooks.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Wrapper; + +namespace MVVM.VmApplicatif +{ + public class NavigateAndLoadBooks + { + NavigationViewModel NavigateViewModel { get; set; } + BookViewModel BookViewModel { get; set; } + + + public NavigateAndLoadBooks(NavigationViewModel navigateViewModel, BookViewModel bookViewModel) + { + this.NavigateViewModel = navigateViewModel; + this.BookViewModel = bookViewModel; + } + } +} diff --git a/MVVM/ToolKit/BaseViewModel.cs b/MVVM/ToolKit/BaseViewModel.cs index 1dbddac8..bbd5a606 100644 --- a/MVVM/ToolKit/BaseViewModel.cs +++ b/MVVM/ToolKit/BaseViewModel.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; namespace ToolKit { @@ -12,10 +13,25 @@ namespace ToolKit { public event PropertyChangedEventHandler? PropertyChanged; - protected void NotifyPropertyChange([CallerMemberName] string name = null ) + + private void NotifyPropertyChange(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + + protected virtual void setProperty(T member, T value, Action action, [CallerMemberName] string propertyName = "") { - OnPropertyChanged(); + if (EqualityComparer.Default.Equals(member, value)) { return; } + member = value; + action(); + NotifyPropertyChange(propertyName); } + protected virtual void setProperty(ref T member, T value, [CallerMemberName] string propertyName = "") + { + if (EqualityComparer.Default.Equals(member, value)) { return; } + member = value; + NotifyPropertyChange(propertyName); + } } } diff --git a/MVVM/Wrapper/BookViewModel.cs b/MVVM/Wrapper/BookViewModel.cs index 7f961c0d..714b7427 100644 --- a/MVVM/Wrapper/BookViewModel.cs +++ b/MVVM/Wrapper/BookViewModel.cs @@ -1,6 +1,7 @@ using Model; using Model.Group; using System.Collections.ObjectModel; +using System.Reflection.Metadata.Ecma335; using System.Xml.Linq; using ToolKit; @@ -10,95 +11,58 @@ namespace Wrapper { ILibraryManager LibraryManager { get; set; } - private string _valeurTmp { get; set; } - public string ValeurTmp + /* + public ReadOnlyObservableCollection Books { get; set; } + private ReadOnlyObservableCollection books { - get => _valeurTmp; + get => Books; set { - if (string.Equals(_valeurTmp, value)) return; - _valeurTmp = value; - NotifyPropertyChange(); + if (value == null) { return; } + setProperty(books, value); } - } + }*/ - public ObservableCollection listeGroupLivre { get; set; } = new ObservableCollection(); public BookViewModel(ILibraryManager _libraryManager) { this.LibraryManager = _libraryManager; - getLivre(); } - - public void getBooks() - { - //LibraryManager.GetBooksByAuthor(); + public int Index { + get { return index; } + private set + { + setProperty(ref index, value); + } + } + private int index; - private void getLivre() - { - /* - LibraryManager. - listeGroupLivre.Clear(); - foreach (var item in LibraryManager.GetBooksByAuthor) + public int Count + { + get { return count; } + private set { - listeGroupLivre.Add(item); - }*/ - - - /* - listeGroupLivre.Add(new GroupeLivre("Eiichirō Oda", - new List { - new Livre { Auteur = "Eiichirō Oda", - Titre = "One piece tome 1", - Note ="5", - Statut = "Lu", - Image = "onepiece1"}, - new Livre { Auteur = "Eiichirō Oda", - Titre = "One piece tome 2", - Note = "4", - Statut = "Lu", - Image = "onepiece2", - Separateur = false}})); - + setProperty(ref count, value); + } + } + private int count; - listeGroupLivre.Add(new GroupeLivre("Tite Kubo", - new List - { - new Livre { Auteur = "Tite Kubo", - Titre = "Bleach tome 1", - Note = "3", - Statut = "Lu", - Image = "bleach1", - Separateur = false} - })); - listeGroupLivre.Add(new GroupeLivre("Masashi Kishimoto", new List { - new Livre { Auteur = "Masashi Kishimoto", - Titre = "Naruto tome 1", - Note = "5", - Statut = "Lu", - Image = "naruto1"}, - new Livre { Auteur = "Masashi Kishimoto", - Titre = "Naruto tome 2", - Note = "2", - Statut = "Lu", - Image = "naruto2"}, - new Livre - { - Auteur = "Masashi Kishimoto", - Titre = "Naruto tome 3", - Note = "3", - Statut = "Lu", - Image = "naruto3", - Separateur = false - }}));*/ + public int NbBook + { + get { return nbBook; } + private set + { + setProperty(ref nbBook, value); + } } + private int nbBook; } } \ No newline at end of file