ProjetThe/ProjetTheAlone/ViewModel/VM_DashBoard.cs

60 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace ProjetTheAlone.ViewModel
{
public class VM_DashBoard : TextDefilant
{
int tick = 0;
public StringCollection Alerte
{
get
{
if (Config.Settings1.Default.alerte != null)
return Config.Settings1.Default.alerte;
else
return new StringCollection();
}
set
{
Config.Settings1.Default.alerte = value;
OnPropertyChanged("Alerte");
}
}
public VM_DashBoard(TextBlock tb, string text, int timeMs) : base (tb,text, timeMs)
{
updateAlert();
base.Tick += new TickHandler(onTick);
}
public void updateAlert()
{
string alert = "ALERTE : ";
foreach (string s in Alerte)
alert += $"{s};;";
var anifBen = new Gestion.G_T_beneficiaire(Config.Settings1.Default.schCon).AnnifDuJour();
if (anifBen.Count > 0)
{
alert += "ANNIVERSAIRE DE :";
foreach (Classes.C_T_beneficiaire b in anifBen)
alert += $" {b.B_prenom} {b.B_nom} ;;";
}
base.TextAfficher = alert;
}
public void onTick(object o, EventArgs e)
{
if(++tick > base.TextAfficher.Length)
{
tick = 0;
updateAlert();
}
}
}
}