diff options
author | Grant Limberg <glimberg@gmail.com> | 2015-10-26 19:21:21 -0700 |
---|---|---|
committer | Grant Limberg <glimberg@gmail.com> | 2015-10-26 19:21:21 -0700 |
commit | 095539de29563d23001a558141b2cec2487530a1 (patch) | |
tree | bc9d9cc77d76c0a83913d0d2b55c9f618a601b65 | |
parent | c4c67e591bbe3cb55d6f282a9267b913c9e3f841 (diff) | |
download | infinitytier-095539de29563d23001a558141b2cec2487530a1.tar.gz infinitytier-095539de29563d23001a558141b2cec2487530a1.zip |
Initial peers page
-rw-r--r-- | windows/WinUI/MainWindow.xaml | 6 | ||||
-rw-r--r-- | windows/WinUI/MainWindow.xaml.cs | 5 | ||||
-rw-r--r-- | windows/WinUI/PeersPage.xaml | 19 | ||||
-rw-r--r-- | windows/WinUI/PeersPage.xaml.cs | 39 | ||||
-rw-r--r-- | windows/WinUI/WinUI.csproj | 7 | ||||
-rw-r--r-- | windows/WinUI/ZeroTierPeer.cs | 24 |
6 files changed, 98 insertions, 2 deletions
diff --git a/windows/WinUI/MainWindow.xaml b/windows/WinUI/MainWindow.xaml index ea5d547e..83b75703 100644 --- a/windows/WinUI/MainWindow.xaml +++ b/windows/WinUI/MainWindow.xaml @@ -99,8 +99,10 @@ </Grid> </TabItem> <TabItem x:Name="Peers" Header="Peers" Background="#FF234447" Foreground="White"> - <Grid Background="#FFE5E5E5"/> - </TabItem> + <Grid Background="#FFE5E5E5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> + <local:PeersPage x:Name="peersPage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></local:PeersPage> + </Grid> + </TabItem> </TabControl> </DockPanel> </Window> diff --git a/windows/WinUI/MainWindow.xaml.cs b/windows/WinUI/MainWindow.xaml.cs index 4e7638b6..e0aeca42 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 00000000..64c21132 --- /dev/null +++ b/windows/WinUI/PeersPage.xaml @@ -0,0 +1,19 @@ +<UserControl x:Class="WinUI.PeersPage" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + mc:Ignorable="d" + d:DesignHeight="300" d:DesignWidth="300" Background="White" Foreground="Black"> + <DataGrid x:Name="dataGrid" AutoGenerateColumns="False" CanUserResizeColumns="True" Margin="0,0,0,0" CanUserReorderColumns="False"> + <DataGrid.Columns> + <DataGridTextColumn Header="Address" Binding="{Binding Address}"/> + <DataGridTextColumn Header="Version" Binding="{Binding VersionString}"/> + <DataGridTextColumn Header="Latency" Binding="{Binding Latency}"/> + <DataGridTextColumn Header="Data Paths" Binding="{Binding DataPaths}"/> + <DataGridTextColumn Header="Last Unicast" Binding="{Binding LastUnicastFrame}"/> + <DataGridTextColumn Header="Last Multicast" Binding="{Binding LastMulticastFrame}"/> + <DataGridTextColumn Header="Role" Binding="{Binding Role}"/> + </DataGrid.Columns> + </DataGrid> +</UserControl> diff --git a/windows/WinUI/PeersPage.xaml.cs b/windows/WinUI/PeersPage.xaml.cs new file mode 100644 index 00000000..b1dd8adf --- /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 +{ + /// <summary> + /// Interaction logic for PeersPage.xaml + /// </summary> + public partial class PeersPage : UserControl + { + private List<ZeroTierPeer> peersList = new List<ZeroTierPeer>(); + + public PeersPage() + { + InitializeComponent(); + + dataGrid.ItemsSource = peersList; + } + + public void SetPeers(List<ZeroTierPeer> peerList) + { + this.peersList = peerList; + dataGrid.ItemsSource = this.peersList; + dataGrid.Items.Refresh(); + } + } +} diff --git a/windows/WinUI/WinUI.csproj b/windows/WinUI/WinUI.csproj index c996db8c..a743408d 100644 --- a/windows/WinUI/WinUI.csproj +++ b/windows/WinUI/WinUI.csproj @@ -100,6 +100,9 @@ <Compile Include="NetworksPage.xaml.cs"> <DependentUpon>NetworksPage.xaml</DependentUpon> </Compile> + <Compile Include="PeersPage.xaml.cs"> + <DependentUpon>PeersPage.xaml</DependentUpon> + </Compile> <Compile Include="ZeroTierPeerPhysicalPath.cs" /> <Compile Include="ZeroTierPeer.cs" /> <Compile Include="ZeroTierNetwork.cs" /> @@ -125,6 +128,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="PeersPage.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Simple Styles.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/windows/WinUI/ZeroTierPeer.cs b/windows/WinUI/ZeroTierPeer.cs index 5377f74a..3153f7e2 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<ZeroTierPeerPhysicalPath> Paths { get; set; } + + public string DataPaths + { + get + { + string pathStr = ""; + foreach(ZeroTierPeerPhysicalPath path in Paths) + { + pathStr += path.Address + "\n"; + } + return pathStr; + } + } } } |