-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataDisplayActivity.cs
90 lines (71 loc) · 2.3 KB
/
DataDisplayActivity.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
83
84
85
86
87
88
89
using AndroidX.Wear.Widget;
using Nauti_Control_Wear.Adapters;
using Nauti_Control_Wear.Models;
using Nauti_Control_Wear.ViewController;
using Nauti_Control_Wear.ViewModels;
namespace Nauti_Control_Wear;
[Activity(Label = "@string/datadisplay_activity")]
public class DataDisplayActivity : Activity, IDataDisplayVC
{
DataDisplayActivityVM? _vm;
TextView? _windSpeed;
TextView? _windAngle;
TextView? _depth;
TextView? _sog;
TextView? _stw;
TextView? _cog;
TextView? _hdg;
/// <summary>
/// Update Data Display
/// </summary>
/// <param name="data"></param>
public void UpdateDataDisplay(BoatData data)
{
RunOnUiThread(() =>
{
_windSpeed.Text = string.Format("{0} kts", data.AWS);
_windAngle.Text = string.Format("{0} °", data.AWA);
_depth.Text = string.Format("{0} M", data.DPT);
_sog.Text = string.Format("{0} kts", data.SOG);
_stw.Text = string.Format("{0} kts", data.STW);
_cog.Text = string.Format("{0} °", data.COG);
_hdg.Text = string.Format("{0} °", data.HDG);
}
);
}
/// <summary>
/// On Create
/// </summary>
/// <param name="savedInstanceState">Saved Instance</param>
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.data_display);
GetControlReferences();
SetupVM();
}
/// <summary>
/// Setup ViewModel
/// </summary>
private void SetupVM()
{
_vm = new DataDisplayActivityVM(this);
if (BluetoothDeviceVM.ConnectedInstance != null)
{
UpdateDataDisplay(BluetoothDeviceVM.ConnectedInstance.Data);
}
}
/// <summary>
/// Gets Control References
/// </summary>
private void GetControlReferences()
{
_windSpeed = FindViewById<TextView>(Resource.Id.windspeed);
_windAngle = FindViewById<TextView>(Resource.Id.windangle);
_depth = FindViewById<TextView>(Resource.Id.depth);
_sog = FindViewById<TextView>(Resource.Id.sog);
_stw = FindViewById<TextView>(Resource.Id.stw);
_cog = FindViewById<TextView>(Resource.Id.cog);
_hdg = FindViewById<TextView>(Resource.Id.hdg);
}
}