sicpaconnexions / SICPA_Connexions / ViewModel / AnimalViewModel.cs @ 03682d21
Historique | Voir | Annoter | Télécharger (2,598 ko)
1 |
using SICPA_Connexions.Model; |
---|---|
2 |
using SICPA_Connexions.View; |
3 |
using SICPA_Connexions.ViewModel.Base; |
4 |
using System; |
5 |
using System.Collections.Generic; |
6 |
using System.Collections.ObjectModel; |
7 |
using System.Linq; |
8 |
using System.Text; |
9 |
using System.Threading.Tasks; |
10 |
using System.Windows.Input; |
11 |
|
12 |
namespace SICPA_Connexions.ViewModel |
13 |
{ |
14 |
public class AnimalViewModel : BaseViewModel |
15 |
{ |
16 |
#region Attributs |
17 |
private string numRfid; |
18 |
private int poids; |
19 |
#endregion |
20 |
|
21 |
#region Commandes |
22 |
public ICommand LectureBLECommand { get; private set; } |
23 |
#endregion |
24 |
|
25 |
#region Propriétés |
26 |
public string NumRfid |
27 |
{ |
28 |
get { return numRfid; } |
29 |
set |
30 |
{ |
31 |
if (numRfid != value) |
32 |
{ |
33 |
numRfid = value; |
34 |
OnPropertyChanged(nameof(NumRfid)); |
35 |
} |
36 |
} |
37 |
} |
38 |
|
39 |
public int Poids |
40 |
{ |
41 |
get { return poids; } |
42 |
set |
43 |
{ |
44 |
if (poids != value) |
45 |
{ |
46 |
poids = value; |
47 |
OnPropertyChanged(nameof(Poids)); |
48 |
} |
49 |
} |
50 |
} |
51 |
|
52 |
|
53 |
#endregion |
54 |
|
55 |
#region Constructeurs |
56 |
public AnimalViewModel() |
57 |
{ |
58 |
LectureBLECommand = new Command(async () => await LectureBLE(), CheckDeviceConnected); |
59 |
} |
60 |
#endregion |
61 |
|
62 |
#region Méthodes |
63 |
private async Task LectureBLE() |
64 |
{ |
65 |
IsBusy = true; |
66 |
if (GlobalApplication.GestionnaireBLE.DeviceConnected != null) |
67 |
{ |
68 |
await GlobalApplication.GestionnaireBLE.LectureTag(GlobalApplication.GestionnaireBLE.DeviceConnected); |
69 |
} |
70 |
IsBusy = false; |
71 |
} |
72 |
|
73 |
private void HandleRetourBleModifiee(object sender, EventArgs e) |
74 |
{ |
75 |
if (GlobalApplication.GestionnaireBLE != null) |
76 |
{ |
77 |
NumRfid = GlobalApplication.GestionnaireBLE.RetourBLE; |
78 |
} |
79 |
} |
80 |
|
81 |
private bool CheckDeviceConnected() |
82 |
{ |
83 |
return (GlobalApplication.GestionnaireBLE != null && GlobalApplication.GestionnaireBLE.DeviceConnected != null); |
84 |
} |
85 |
|
86 |
public void ActualisePage() |
87 |
{ |
88 |
((Command)LectureBLECommand).ChangeCanExecute(); |
89 |
if (GlobalApplication.GestionnaireBLE != null) |
90 |
{ |
91 |
GlobalApplication.GestionnaireBLE.RetourBlEMofifiee += HandleRetourBleModifiee; |
92 |
} |
93 |
} |
94 |
|
95 |
#endregion |
96 |
|
97 |
} |
98 |
} |