ProjetThe/ProjetTheAlone/ViewModel/RepaModel.cs

53 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using ProjetTheAlone.Classes;
using System.Collections.ObjectModel;
namespace ProjetTheAlone.ViewModel
{
public class RepaModel : INotifyPropertyChanged
{
private string quand;
private ObservableCollection<C_T_plat> listPlat = new ObservableCollection<C_T_plat>();
public ObservableCollection<C_T_plat> ListPlat { get => listPlat; set { listPlat = value; OnPropertyChanged("ListPlat"); OnPropertyChanged("Plat1"); OnPropertyChanged("Plat2"); OnPropertyChanged("Plat3"); } }
private C_T_plat plat1, plat2, plat3;
public C_T_plat Plat1 { get => plat1; set { plat1 = value; OnPropertyChanged("Plat1"); } }
public C_T_plat Plat2 { get => plat2; set { plat2 = value; OnPropertyChanged("Plat2"); } }
public C_T_plat Plat3 { get => plat3; set { plat3 = value; OnPropertyChanged("Plat3"); } }
public string Quand { get => quand; set { quand = value; OnPropertyChanged("Quand"); } }
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
public RepaModel()
{
}
public RepaModel(DateTime d)
{
ListPlat = new ObservableCollection<C_T_plat>(new Gestion.G_T_repa(Config.Settings1.Default.schCon).Lire(d) as List<C_T_plat>);
Plat1 = (ListPlat.Count > 0) ? ListPlat[0] : new C_T_plat("NULL", Outil.toNullableByteArray.Convert(Outil.picToByteArray.Convert(@".\desert.jpg")), null);
Plat2 = (ListPlat.Count > 1) ? ListPlat[1] : new C_T_plat("NULL", Outil.toNullableByteArray.Convert(Outil.picToByteArray.Convert(@".\desert.jpg")), null);
Plat3 = (ListPlat.Count > 2) ? ListPlat[2] : new C_T_plat("NULL", Outil.toNullableByteArray.Convert(Outil.picToByteArray.Convert(@".\desert.jpg")), null);
Quand = d.ToString();
}
public RepaModel(ObservableCollection<C_T_plat> ListPlat, string quand)
{
this.ListPlat = ListPlat;
this.Quand = quand;
}
}
}