diff --git a/MangaMap/Model/Oeuvre.cs b/MangaMap/Model/Oeuvre.cs
index 56eec70..e8823e1 100644
--- a/MangaMap/Model/Oeuvre.cs
+++ b/MangaMap/Model/Oeuvre.cs
@@ -4,12 +4,20 @@ using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
+using System.ComponentModel;
+using System.Xml.Linq;
+using System.Runtime.CompilerServices;
namespace MangaMap.Model
{
[DataContract]
- public class Oeuvre
+ public class Oeuvre : INotifyPropertyChanged
{
+ public event PropertyChangedEventHandler? PropertyChanged;
+
+ void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+
[DataMember]
public string Nom { get; private set; }
[DataMember]
@@ -18,8 +26,20 @@ namespace MangaMap.Model
public string Type { get; private set; }
[DataMember]
public string Description { get; private set; }
+
[DataMember]
- public int Note { get; private set; }
+ public int Note {
+ get => note;
+ set
+ {
+ if (note == value)
+ return;
+ note = value;
+ OnPropertyChanged();
+ }
+ }
+ private int note;
+
[DataMember]
public int NbEpisodes { get; private set; }
[DataMember]
diff --git a/MangaMap/Views/Composants/ListOeuvre.xaml b/MangaMap/Views/Composants/ListOeuvre.xaml
index dfb576e..56041c8 100644
--- a/MangaMap/Views/Composants/ListOeuvre.xaml
+++ b/MangaMap/Views/Composants/ListOeuvre.xaml
@@ -34,7 +34,7 @@
-
+
diff --git a/MangaMap/Views/FicheAnime.xaml.cs b/MangaMap/Views/FicheAnime.xaml.cs
index 12f0705..2adcb56 100644
--- a/MangaMap/Views/FicheAnime.xaml.cs
+++ b/MangaMap/Views/FicheAnime.xaml.cs
@@ -1,20 +1,18 @@
namespace MangaMap.Views;
+
using Model;
using System.ComponentModel;
using System.Diagnostics;
+using System.Drawing;
using System.Windows.Input;
using System.Xml.Linq;
public partial class ficheAnime : ContentPage, INotifyPropertyChanged
{
-
-
public Manager my_manager => (App.Current as App).MyManager;
public Oeuvre AnimeModel { get; set; }
- public ICommand StarCommand => new Command(count => SetNote(uint.Parse(count)));
-
public ficheAnime()
{
InitializeComponent();
@@ -30,7 +28,8 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
InitializeComponent();
BindingContext = this;
-
+
+ SetNote();
}
public async void AjouterListe(object sender, EventArgs e)
@@ -81,22 +80,59 @@ public partial class ficheAnime : ContentPage, INotifyPropertyChanged
}
- private void SetNote(float note)
+ private void SetNote()
{
- note = (int)note;
- var starImages = star.Children.OfType().Reverse().ToList();
- foreach (var img in starImages)
+ stars.Children.Clear();
+
+ for (int i = 0; i < 5; i++)
{
- if (note > 0)
+ if (i < AnimeModel.Note)
{
- img.Opacity = 1;
- note--;
+ ImageButton imageButton = new ImageButton
+ {
+ Source = "star_full.png",
+ WidthRequest = 50,
+ HeightRequest = 50,
+ AutomationId = i.ToString(),
+ Margin = 10,
+ };
+
+ imageButton.Clicked += StarClicked;
+
+ Grid.SetRow(imageButton, 0);
+ Grid.SetColumn(imageButton, i);
+ stars.Children.Add(imageButton);
}
else
{
- img.Opacity = 0;
+ ImageButton imageButton = new ImageButton
+ {
+ Source = "star_empty.png",
+ WidthRequest = 50,
+ HeightRequest = 50,
+ AutomationId = i.ToString(),
+ Margin = 10,
+ };
+
+ imageButton.Clicked += StarClicked;
+
+ Grid.SetRow(imageButton, 0);
+ Grid.SetColumn(imageButton, i);
+ stars.Children.Add(imageButton);
}
}
}
+ private async void StarClicked(object sender, EventArgs e)
+ {
+ var button = (ImageButton)sender;
+ var idAutomation = button.AutomationId;
+
+ if (int.TryParse(idAutomation, out int id))
+ {
+ AnimeModel.Note = id+1;
+ my_manager.sauvegarder();
+ SetNote();
+ }
+ }
}
\ No newline at end of file
diff --git a/MangaMap/Views/ficheAnime.xaml b/MangaMap/Views/ficheAnime.xaml
index 664c521..dfee294 100644
--- a/MangaMap/Views/ficheAnime.xaml
+++ b/MangaMap/Views/ficheAnime.xaml
@@ -26,13 +26,8 @@
-
-
-
-
-
-
-
+
+