Initial peers page

This commit is contained in:
Grant Limberg 2015-10-26 19:21:21 -07:00
parent c4c67e591b
commit 095539de29
6 changed files with 98 additions and 2 deletions

View File

@ -99,7 +99,9 @@
</Grid>
</TabItem>
<TabItem x:Name="Peers" Header="Peers" Background="#FF234447" Foreground="White">
<Grid Background="#FFE5E5E5"/>
<Grid Background="#FFE5E5E5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<local:PeersPage x:Name="peersPage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></local:PeersPage>
</Grid>
</TabItem>
</TabControl>
</DockPanel>

View File

@ -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)

View File

@ -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>

View File

@ -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();
}
}
}

View File

@ -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>

View File

@ -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;
}
}
}
}