master
Enzo 2 years ago
parent 8143826786
commit 3e74322c14

Binary file not shown.

Binary file not shown.

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen> <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
<ActiveDebugFramework>net7.0-android</ActiveDebugFramework> <ActiveDebugFramework>net7.0-android</ActiveDebugFramework>
<ActiveDebugProfile>Samsung SM-A705FN (Android 11.0 - API 30)</ActiveDebugProfile> <ActiveDebugProfile>Émulateur Android</ActiveDebugProfile>
<SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup> <SelectedPlatformGroup>PhysicalDevice</SelectedPlatformGroup>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'"> <PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'">

@ -4,10 +4,11 @@ namespace MVVM.Pages;
public partial class MyLibraryPage : ContentPage 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(); InitializeComponent();
BindingContext = this; BindingContext = this;
} }

@ -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;
}
}
}

@ -5,6 +5,7 @@ using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Xml.Linq;
namespace ToolKit namespace ToolKit
{ {
@ -12,10 +13,25 @@ namespace ToolKit
{ {
public event PropertyChangedEventHandler? PropertyChanged; 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>(T member, T value, Action action, [CallerMemberName] string propertyName = "")
{ {
OnPropertyChanged(); if (EqualityComparer<T>.Default.Equals(member, value)) { return; }
member = value;
action();
NotifyPropertyChange(propertyName);
} }
protected virtual void setProperty<T>(ref T member, T value, [CallerMemberName] string propertyName = "")
{
if (EqualityComparer<T>.Default.Equals(member, value)) { return; }
member = value;
NotifyPropertyChange(propertyName);
}
} }
} }

@ -1,6 +1,7 @@
using Model; using Model;
using Model.Group; using Model.Group;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Reflection.Metadata.Ecma335;
using System.Xml.Linq; using System.Xml.Linq;
using ToolKit; using ToolKit;
@ -10,95 +11,58 @@ namespace Wrapper
{ {
ILibraryManager LibraryManager { get; set; } ILibraryManager LibraryManager { get; set; }
private string _valeurTmp { get; set; } /*
public string ValeurTmp public ReadOnlyObservableCollection<Book> Books { get; set; }
private ReadOnlyObservableCollection<Book> books
{ {
get => _valeurTmp; get => Books;
set set
{ {
if (string.Equals(_valeurTmp, value)) return; if (value == null) { return; }
_valeurTmp = value; setProperty(books, value);
NotifyPropertyChange();
} }
} }*/
public ObservableCollection<GroupeLivre> listeGroupLivre { get; set; } = new ObservableCollection<GroupeLivre>();
public BookViewModel(ILibraryManager _libraryManager) public BookViewModel(ILibraryManager _libraryManager)
{ {
this.LibraryManager = _libraryManager; this.LibraryManager = _libraryManager;
getLivre();
} }
public int Index {
public void getBooks() get { return index; }
{ private set
//LibraryManager.GetBooksByAuthor(); {
setProperty(ref index, value);
}
} }
private int index;
private void getLivre()
{
/*
LibraryManager.
listeGroupLivre.Clear(); public int Count
foreach (var item in LibraryManager.GetBooksByAuthor) {
get { return count; }
private set
{ {
listeGroupLivre.Add(item); setProperty(ref count, value);
}*/ }
/*
listeGroupLivre.Add(new GroupeLivre("Eiichirō Oda",
new List<Livre> {
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}}));
}
private int count;
listeGroupLivre.Add(new GroupeLivre("Tite Kubo",
new List<Livre>
{
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<Livre> { public int NbBook
new Livre { Auteur = "Masashi Kishimoto", {
Titre = "Naruto tome 1", get { return nbBook; }
Note = "5", private set
Statut = "Lu", {
Image = "naruto1"}, setProperty(ref nbBook, value);
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
}}));*/
} }
private int nbBook;
} }
} }
Loading…
Cancel
Save