|
|
|
@ -1,13 +1,15 @@
|
|
|
|
|
using Microsoft.Maui.Controls.Shapes;
|
|
|
|
|
|
|
|
|
|
namespace MauiSpark.Vues;
|
|
|
|
|
|
|
|
|
|
public partial class JetonVue : ContentView
|
|
|
|
|
{
|
|
|
|
|
public static readonly BindableProperty CouleurPropriete = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChange);
|
|
|
|
|
public static readonly BindableProperty CouleurProperty = BindableProperty.Create(nameof(Couleur), typeof(Color), typeof(JetonVue), default(Color), propertyChanged: QuandCouleurChangee);
|
|
|
|
|
|
|
|
|
|
public Color? Couleur
|
|
|
|
|
public Color Couleur
|
|
|
|
|
{
|
|
|
|
|
get => (Color?)GetValue(CouleurPropriete);
|
|
|
|
|
set => SetValue(CouleurPropriete, value);
|
|
|
|
|
get => (Color)GetValue(CouleurProperty);
|
|
|
|
|
set => SetValue(CouleurProperty, Color.FromRgb(0, 255, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JetonVue()
|
|
|
|
@ -22,26 +24,8 @@ public partial class JetonVue : ContentView
|
|
|
|
|
Cercle.WidthRequest = Cercle.HeightRequest = taille;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void QuandCouleurChange(BindableObject bindable, object oldValue, object newValue)
|
|
|
|
|
{
|
|
|
|
|
var view = bindable as JetonVue;
|
|
|
|
|
if (view != null)
|
|
|
|
|
{
|
|
|
|
|
view.UpdateCouleur();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateCouleur()
|
|
|
|
|
{
|
|
|
|
|
// Gérer la couleur null
|
|
|
|
|
if (Couleur == null)
|
|
|
|
|
{
|
|
|
|
|
// Définir une couleur par défaut si null
|
|
|
|
|
BackgroundColor = Colors.Transparent; // Ou toute autre couleur par défaut
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BackgroundColor = Couleur;
|
|
|
|
|
}
|
|
|
|
|
private static void QuandCouleurChangee(BindableObject bindable, object ancienneValeur, object nouvelleValeur)
|
|
|
|
|
{
|
|
|
|
|
((JetonVue)bindable).Cercle.Fill = (Color) nouvelleValeur;
|
|
|
|
|
}
|
|
|
|
|
}
|