A UWP dashboard which provides live updates for the 'Personal Flash in Real-Time (Andy)' and 'Personal Flash in Real-Time (Tony)' artworks -- part of the 'Return to Ritherdon' project by Nicola Ellis. Documentation can be found at
https://git.abbether.net/return-to-ritherdon/rtr-docs/src/branch/master/eyes-and-ears
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.5 KiB
67 lines
2.5 KiB
using EyesAndEars.UWP.Services; |
|
using EyesAndEars.UWP.ViewModels; |
|
using System; |
|
using System.Threading; |
|
using Windows.ApplicationModel; |
|
using Windows.UI.Xaml; |
|
using Windows.UI.Xaml.Controls; |
|
|
|
namespace EyesAndEars.UWP { |
|
|
|
public sealed partial class MainPage : Page { |
|
|
|
MainPageVM _vm = new MainPageVM(); |
|
DispatcherTimer _dispatcherTimer = new DispatcherTimer(); |
|
|
|
public MainPage() { |
|
InitializeComponent(); |
|
IntialiseDataContext(); |
|
SetVersionNumber(); |
|
IntialiseRefreshTime(); |
|
} |
|
|
|
void SetVersionNumber() { |
|
var package = Package.Current; |
|
var packageId = package.Id; |
|
var version = packageId.Version; |
|
VersionNumber.Text = $"Ver: {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; |
|
} |
|
|
|
async void IntialiseDataContext() { |
|
_vm.BaseURL = await DataServices.GetBaseURLAsync(); |
|
_vm.Device1 = DataServices.CreateFallBackDevice(1); |
|
_vm.Device2 = DataServices.CreateFallBackDevice(2); |
|
_vm.Device3 = DataServices.CreateFallBackDevice(3); |
|
_vm.Device4 = DataServices.CreateFallBackDevice(4); |
|
_vm.Device5 = DataServices.CreateFallBackDevice(5); |
|
_vm.Device6 = DataServices.CreateFallBackDevice(6); |
|
DataContext = _vm; |
|
} |
|
|
|
void IntialiseRefreshTime() { |
|
// TimeSpan Intervals: Days, Hours, Minutes, Seconds, Milliseconds. |
|
_dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1, 0); |
|
_dispatcherTimer.Tick += UpdateViewModel; |
|
_dispatcherTimer.Start(); |
|
} |
|
|
|
async void UpdateViewModel(object sender, object e) { |
|
var url = _vm.BaseURL; |
|
if (!string.IsNullOrEmpty(url)) { |
|
_vm.Device1 = await DataServices.UpdateDevice(url, 1); |
|
_vm.Device2 = await DataServices.UpdateDevice(url, 2); |
|
_vm.Device3 = await DataServices.UpdateDevice(url, 3); |
|
_vm.Device4 = await DataServices.UpdateDevice(url, 4); |
|
_vm.Device5 = await DataServices.UpdateDevice(url, 5); |
|
_vm.Device6 = await DataServices.UpdateDevice(url, 6); |
|
} |
|
} |
|
|
|
void RefreshButton_Click(object sender, RoutedEventArgs e) => |
|
IntialiseDataContext(); |
|
|
|
async void SaveURLButton_Click(object sender, RoutedEventArgs e) { |
|
await DataServices.SaveBaseURLAsync(WebAddressBox.Text); |
|
} |
|
} |
|
}
|
|
|