From 095539de29563d23001a558141b2cec2487530a1 Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 26 Oct 2015 19:21:21 -0700 Subject: [PATCH] Initial peers page --- windows/WinUI/MainWindow.xaml | 6 +++-- windows/WinUI/MainWindow.xaml.cs | 5 ++++ windows/WinUI/PeersPage.xaml | 19 ++++++++++++++++ windows/WinUI/PeersPage.xaml.cs | 39 ++++++++++++++++++++++++++++++++ windows/WinUI/WinUI.csproj | 7 ++++++ windows/WinUI/ZeroTierPeer.cs | 24 ++++++++++++++++++++ 6 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 windows/WinUI/PeersPage.xaml create mode 100644 windows/WinUI/PeersPage.xaml.cs diff --git a/windows/WinUI/MainWindow.xaml b/windows/WinUI/MainWindow.xaml index ea5d547e3..83b757031 100644 --- a/windows/WinUI/MainWindow.xaml +++ b/windows/WinUI/MainWindow.xaml @@ -99,8 +99,10 @@ - - + + + + diff --git a/windows/WinUI/MainWindow.xaml.cs b/windows/WinUI/MainWindow.xaml.cs index 4e7638b61..e0aeca427 100644 --- a/windows/WinUI/MainWindow.xaml.cs +++ b/windows/WinUI/MainWindow.xaml.cs @@ -73,7 +73,12 @@ namespace WinUI private void updatePeers() { + var peers = handler.GetPeers(); + peersPage.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => + { + peersPage.SetPeers(peers); + })); } private void OnUpdateTimer(object source, ElapsedEventArgs e) diff --git a/windows/WinUI/PeersPage.xaml b/windows/WinUI/PeersPage.xaml new file mode 100644 index 000000000..64c211329 --- /dev/null +++ b/windows/WinUI/PeersPage.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + diff --git a/windows/WinUI/PeersPage.xaml.cs b/windows/WinUI/PeersPage.xaml.cs new file mode 100644 index 000000000..b1dd8adf1 --- /dev/null +++ b/windows/WinUI/PeersPage.xaml.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace WinUI +{ + /// + /// Interaction logic for PeersPage.xaml + /// + public partial class PeersPage : UserControl + { + private List peersList = new List(); + + public PeersPage() + { + InitializeComponent(); + + dataGrid.ItemsSource = peersList; + } + + public void SetPeers(List peerList) + { + this.peersList = peerList; + dataGrid.ItemsSource = this.peersList; + dataGrid.Items.Refresh(); + } + } +} diff --git a/windows/WinUI/WinUI.csproj b/windows/WinUI/WinUI.csproj index c996db8ca..a743408d0 100644 --- a/windows/WinUI/WinUI.csproj +++ b/windows/WinUI/WinUI.csproj @@ -100,6 +100,9 @@ NetworksPage.xaml + + PeersPage.xaml + @@ -125,6 +128,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/windows/WinUI/ZeroTierPeer.cs b/windows/WinUI/ZeroTierPeer.cs index 5377f74a0..3153f7e26 100644 --- a/windows/WinUI/ZeroTierPeer.cs +++ b/windows/WinUI/ZeroTierPeer.cs @@ -30,6 +30,17 @@ namespace WinUI [JsonProperty("version")] public string Version { get; set; } + public string VersionString + { + get + { + if (Version == "-1.-1.-1") + return "-"; + else + return Version; + } + } + [JsonProperty("latency")] public string Latency { get; set; } @@ -38,5 +49,18 @@ namespace WinUI [JsonProperty("paths")] public List Paths { get; set; } + + public string DataPaths + { + get + { + string pathStr = ""; + foreach(ZeroTierPeerPhysicalPath path in Paths) + { + pathStr += path.Address + "\n"; + } + return pathStr; + } + } } }