diff options
-rw-r--r-- | windows/WinUI/MainWindow.xaml | 4 | ||||
-rw-r--r-- | windows/WinUI/MainWindow.xaml.cs | 22 | ||||
-rw-r--r-- | windows/WinUI/NetworkInfoView.xaml.cs | 32 | ||||
-rw-r--r-- | windows/WinUI/WinUI.csproj | 2 | ||||
-rw-r--r-- | windows/WinUI/ZeroTierNetwork.cs | 56 | ||||
-rw-r--r-- | windows/WinUI/ZeroTierPeer.cs | 42 | ||||
-rw-r--r-- | windows/WinUI/ZeroTierPeerPhysicalPath.cs | 27 | ||||
-rw-r--r-- | windows/WinUI/ZeroTierStatus.cs | 36 |
8 files changed, 175 insertions, 46 deletions
diff --git a/windows/WinUI/MainWindow.xaml b/windows/WinUI/MainWindow.xaml index d3b4d47f..ed03a968 100644 --- a/windows/WinUI/MainWindow.xaml +++ b/windows/WinUI/MainWindow.xaml @@ -80,10 +80,10 @@ <StatusBarItem Grid.Column="2" x:Name="versionString" Content="1.0.5" Foreground="White" Margin="0"/> <StatusBarItem Grid.Column="3" x:Name="blank" Content="" Height="43" Foreground="White" Margin="6,0,-6,-9"/> <StatusBarItem Grid.Column="4"> - <TextBox x:Name="joinNetworkID" Height="23" TextWrapping="Wrap" Width="120" HorizontalAlignment="Right" RenderTransformOrigin="1.168,0.478" ToolTip="Enter Network ID"/> + <TextBox x:Name="joinNetworkID" Height="23" TextWrapping="Wrap" Width="120" HorizontalAlignment="Right" RenderTransformOrigin="1.168,0.478" ToolTip="Enter Network ID" TextChanged="joinNetworkID_TextChanged"/> </StatusBarItem> <StatusBarItem Grid.Column="5" x:Name="statusBarButton" Foreground="White" RenderTransformOrigin="0.789,0.442"> - <Button x:Name="joinButton" Content="Join" Background="#FFFFB354" Width="77.423"/> + <Button x:Name="joinButton" Content="Join" Background="#FFFFB354" Width="77.423" Click="joinButton_Click"/> </StatusBarItem> </StatusBar> <TabControl> diff --git a/windows/WinUI/MainWindow.xaml.cs b/windows/WinUI/MainWindow.xaml.cs index 8e2d7993..8398d62c 100644 --- a/windows/WinUI/MainWindow.xaml.cs +++ b/windows/WinUI/MainWindow.xaml.cs @@ -32,18 +32,30 @@ namespace WinUI private void updateStatus() { - var status = handler.getStatus(); + var status = handler.GetStatus(); - this.networkId.Content = status.address; - this.versionString.Content = status.version; - this.onlineStatus.Content = (status.online ? "ONLINE" : "OFFLINE"); + this.networkId.Content = status.Address; + this.versionString.Content = status.Version; + this.onlineStatus.Content = (status.Online ? "ONLINE" : "OFFLINE"); } private void updateNetworks() { - var networks = handler.getNetworks(); + var networks = handler.GetNetworks(); networksPage.setNetworks(networks); } + + private void joinButton_Click(object sender, RoutedEventArgs e) + { + + } + + private void joinNetworkID_TextChanged(object sender, TextChangedEventArgs e) + { + + } + + } } diff --git a/windows/WinUI/NetworkInfoView.xaml.cs b/windows/WinUI/NetworkInfoView.xaml.cs index c941e64e..cbc268ca 100644 --- a/windows/WinUI/NetworkInfoView.xaml.cs +++ b/windows/WinUI/NetworkInfoView.xaml.cs @@ -27,35 +27,35 @@ namespace WinUI InitializeComponent(); this.network = network; - updateNetworkData(); + UpdateNetworkData(); } - private void updateNetworkData() + private void UpdateNetworkData() { - this.networkId.Text = network.nwid; - this.networkName.Text = network.name; - this.networkStatus.Text = network.status; - this.networkType.Text = network.type; - this.macAddress.Text = network.mac; - this.mtu.Text = network.mtu.ToString(); - this.broadcastEnabled.Text = (network.broadcastEnabled ? "ENABLED" : "DISABLED"); - this.bridgingEnabled.Text = (network.bridge ? "ENABLED" : "DISABLED"); - this.deviceName.Text = network.portDeviceName; + this.networkId.Text = network.NetworkId; + this.networkName.Text = network.NetworkName; + this.networkStatus.Text = network.NetworkStatus; + this.networkType.Text = network.NetworkType; + this.macAddress.Text = network.MacAddress; + this.mtu.Text = network.MTU.ToString(); + this.broadcastEnabled.Text = (network.BroadcastEnabled ? "ENABLED" : "DISABLED"); + this.bridgingEnabled.Text = (network.Bridge ? "ENABLED" : "DISABLED"); + this.deviceName.Text = network.DeviceName; string iplist = ""; - for (int i = 0; i < network.assignedAddresses.Length; ++i) + for (int i = 0; i < network.AssignedAddresses.Length; ++i) { - iplist += network.assignedAddresses[i]; - if (i < (network.assignedAddresses.Length - 1)) + iplist += network.AssignedAddresses[i]; + if (i < (network.AssignedAddresses.Length - 1)) iplist += "\n"; } this.managedIps.Text = iplist; } - public bool hasNetwork(ZeroTierNetwork network) + public bool HasNetwork(ZeroTierNetwork network) { - if (this.network.nwid.Equals(network.nwid)) + if (this.network.NetworkId.Equals(network.NetworkId)) return true; return false; diff --git a/windows/WinUI/WinUI.csproj b/windows/WinUI/WinUI.csproj index 855e8fa5..c996db8c 100644 --- a/windows/WinUI/WinUI.csproj +++ b/windows/WinUI/WinUI.csproj @@ -100,6 +100,8 @@ <Compile Include="NetworksPage.xaml.cs"> <DependentUpon>NetworksPage.xaml</DependentUpon> </Compile> + <Compile Include="ZeroTierPeerPhysicalPath.cs" /> + <Compile Include="ZeroTierPeer.cs" /> <Compile Include="ZeroTierNetwork.cs" /> <Compile Include="ZeroTierStatus.cs" /> <Page Include="MainWindow.xaml"> diff --git a/windows/WinUI/ZeroTierNetwork.cs b/windows/WinUI/ZeroTierNetwork.cs index 2dec53d2..cce65441 100644 --- a/windows/WinUI/ZeroTierNetwork.cs +++ b/windows/WinUI/ZeroTierNetwork.cs @@ -3,24 +3,52 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; namespace WinUI { public class ZeroTierNetwork { - public string nwid; - public string mac; - public string name; - public string status; - public string type; - public int mtu; - public bool dhcp; - public bool bridge; - public bool broadcastEnabled; - public int portError; - public int netconfRevision; - public string[] multicastSubscriptions; - public string[] assignedAddresses; - public string portDeviceName; + [JsonProperty("nwid")] + public string NetworkId { get; set; } + + [JsonProperty("mac")] + public string MacAddress { get; set; } + + [JsonProperty("name")] + public string NetworkName { get; set; } + + [JsonProperty("status")] + public string NetworkStatus { get; set; } + + [JsonProperty("type")] + public string NetworkType { get; set; } + + [JsonProperty("mtu")] + public int MTU { get; set; } + + [JsonProperty("dhcp")] + public bool DHCP { get; set; } + + [JsonProperty("bridge")] + public bool Bridge { get; set ; } + + [JsonProperty("broadcastEnabled")] + public bool BroadcastEnabled { get ; set; } + + [JsonProperty("portError")] + public int PortError { get; set; } + + [JsonProperty("netconfRevision")] + public int NetconfRevision { get; set; } + + [JsonProperty("multicastSubscriptions")] + public string[] MulticastSubscriptions { get; set; } + + [JsonProperty("assignedAddresses")] + public string[] AssignedAddresses { get; set; } + + [JsonProperty("portDeviceName")] + public string DeviceName { get; set; } } } diff --git a/windows/WinUI/ZeroTierPeer.cs b/windows/WinUI/ZeroTierPeer.cs new file mode 100644 index 00000000..ba925a6f --- /dev/null +++ b/windows/WinUI/ZeroTierPeer.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace WinUI +{ + public class ZeroTierPeer + { + [JsonProperty("address")] + public string Address { get; set; } + + [JsonProperty("lastUnicastFrame")] + public int LastUnicastFrame { get; set; } + + [JsonProperty("lastMulticastFrame")] + public int LastMulticastFrame { get; set; } + + [JsonProperty("versionMajor")] + public int VersionMajor { get; set; } + + [JsonProperty("versionMinor")] + public int VersionMinor { get; set; } + + [JsonProperty("versionRev")] + public int Versionrev { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } + + [JsonProperty("latency")] + public string Latency { get; set; } + + [JsonProperty("role")] + public string Role { get; set; } + + [JsonProperty("paths")] + public List<ZeroTierPeerPhysicalPath> Paths { get; set; } + } +} diff --git a/windows/WinUI/ZeroTierPeerPhysicalPath.cs b/windows/WinUI/ZeroTierPeerPhysicalPath.cs new file mode 100644 index 00000000..51bb3d5b --- /dev/null +++ b/windows/WinUI/ZeroTierPeerPhysicalPath.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace WinUI +{ + public class ZeroTierPeerPhysicalPath + { + [JsonProperty("address")] + public string Address { get; set; } + + [JsonProperty("lastSend")] + public int LastSend { get; set; } + + [JsonProperty("lastReceive")] + public int LastReceive { get; set; } + + [JsonProperty("fixed")] + public bool Fixed { get; set; } + + [JsonProperty("preferred")] + public bool Preferred { get; set; } + } +} diff --git a/windows/WinUI/ZeroTierStatus.cs b/windows/WinUI/ZeroTierStatus.cs index 9eafdb26..2851d017 100644 --- a/windows/WinUI/ZeroTierStatus.cs +++ b/windows/WinUI/ZeroTierStatus.cs @@ -3,19 +3,37 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Newtonsoft.Json; namespace WinUI { public class ZeroTierStatus { - public string address; - public string publicIdentity; - public bool online; - public bool tcpFallbackActive; - public int versionMajor; - public int versionMinor; - public int versionRev; - public string version; - public UInt64 clock; + [JsonProperty("address")] + public string Address { get; set; } + + [JsonProperty("publicIdentity")] + public string PublicIdentity { get; set; } + + [JsonProperty("online")] + public bool Online { get; set; } + + [JsonProperty("tcpFallbackActive")] + public bool TcpFallbackActive { get; set; } + + [JsonProperty("versionMajor")] + public int VersionMajor { get; set; } + + [JsonProperty("versionMinor")] + public int VersionMinor { get; set; } + + [JsonProperty("versionRev")] + public int VersionRev { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } + + [JsonProperty("clock")] + public UInt64 Clock { get; set; } } } |