-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSampleViewModel.cs
82 lines (72 loc) · 2.26 KB
/
SampleViewModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
namespace Lside_Mixture.ViewModels
{
using System;
using System.ComponentModel;
using Lside_Mixture.Models;
using Lside_Mixture.Services;
using Microsoft.Extensions.DependencyInjection;
public class SampleViewModel : BindableBase
{
private readonly ISimService simservice = App.Current.Services.GetService<ISimService>();
public SampleViewModel()
{
simservice.SampleModel.PropertyChanged += this.ModelPropertyChanged;
}
public string Name
{
get { return name; }
set { SetProperty(ref name, value, "Name"); }
}
public int Altitude
{
get { return altitude; }
set { SetProperty(ref altitude, value, "Altitude"); }
}
public int RPM
{
get { return rpm; }
set { SetProperty(ref rpm, value, "RPM"); }
}
public int EGT
{
get { return egt; }
set { SetProperty(ref egt, value, "EGT"); }
}
public int Throttle
{
get { return throttle; }
set { SetProperty(ref throttle, value, "Throttle"); }
}
public int Mixture
{
get { return mixture; }
set { SetProperty(ref mixture, value, "Mixture"); }
}
public void update(PlaneInfoResponse planeInfo)
{
this.Name = planeInfo.Title;
this.Altitude = Convert.ToInt32(planeInfo.Altitude);
this.RPM = Convert.ToInt32(planeInfo.RPM);
this.EGT = Convert.ToInt32(planeInfo.EGT);
this.Throttle = Convert.ToInt32(planeInfo.Throttle);
this.Mixture = Convert.ToInt32(planeInfo.Mixture);
}
private void ModelPropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "PlaneInfoResponse":
{
this.update(((SampleModel)sender).planeInfoResponse);
}
break;
}
}
private string name;
private int altitude;
private int rpm;
private int egt;
private int throttle;
private int mixture;
}
}