From df74dd6e41007b55ca879967092ab59af4c3a279 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Wed, 4 Nov 2015 20:03:25 -0800 Subject: [PATCH] make the peers page prettier --- windows/WinUI/APIHandler.cs | 2 +- windows/WinUI/MainWindow.xaml | 16 ++++++++++++++++ windows/WinUI/PeersPage.xaml | 11 +++++++++-- windows/WinUI/ZeroTierPeer.cs | 36 +++++++++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/windows/WinUI/APIHandler.cs b/windows/WinUI/APIHandler.cs index ada7369a9..2968c963a 100644 --- a/windows/WinUI/APIHandler.cs +++ b/windows/WinUI/APIHandler.cs @@ -181,7 +181,7 @@ namespace WinUI using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var responseText = streamReader.ReadToEnd(); - + //Console.WriteLine(responseText); List peerList = null; try { diff --git a/windows/WinUI/MainWindow.xaml b/windows/WinUI/MainWindow.xaml index b5365a371..660cbd9b8 100644 --- a/windows/WinUI/MainWindow.xaml +++ b/windows/WinUI/MainWindow.xaml @@ -19,7 +19,23 @@ + + + + + @@ -13,7 +20,7 @@ - + diff --git a/windows/WinUI/ZeroTierPeer.cs b/windows/WinUI/ZeroTierPeer.cs index 3153f7e26..06a8896ba 100644 --- a/windows/WinUI/ZeroTierPeer.cs +++ b/windows/WinUI/ZeroTierPeer.cs @@ -12,11 +12,43 @@ namespace WinUI [JsonProperty("address")] public string Address { get; set; } + private Int64 _lastUnicast; [JsonProperty("lastUnicastFrame")] - public UInt64 LastUnicastFrame { get; set; } + public Int64 LastUnicastFrame + { + get + { + if (_lastUnicast == 0) + return 0; + TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); + Int64 millisecondsSinceEpoch = (Int64)t.TotalMilliseconds; + return (millisecondsSinceEpoch - _lastUnicast) / 1000; + } + set + { + _lastUnicast = value; + } + } + + private Int64 _lastMulticast; [JsonProperty("lastMulticastFrame")] - public UInt64 LastMulticastFrame { get; set; } + public Int64 LastMulticastFrame + { + get + { + if (_lastMulticast == 0) + return 0; + + TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1); + Int64 millisecondsSinceEpoch = (Int64)t.TotalMilliseconds; + return (millisecondsSinceEpoch - _lastMulticast) / 1000; + } + set + { + _lastMulticast = value; + } + } [JsonProperty("versionMajor")] public int VersionMajor { get; set; }