C#-ifying stuff

This commit is contained in:
Grant Limberg 2015-10-23 15:36:42 -07:00
parent fe6960888a
commit 62059a91aa
8 changed files with 175 additions and 46 deletions

View File

@ -80,10 +80,10 @@
<StatusBarItem Grid.Column="2" x:Name="versionString" Content="1.0.5" Foreground="White" Margin="0"/> <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="3" x:Name="blank" Content="" Height="43" Foreground="White" Margin="6,0,-6,-9"/>
<StatusBarItem Grid.Column="4"> <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>
<StatusBarItem Grid.Column="5" x:Name="statusBarButton" Foreground="White" RenderTransformOrigin="0.789,0.442"> <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> </StatusBarItem>
</StatusBar> </StatusBar>
<TabControl> <TabControl>

View File

@ -32,18 +32,30 @@ namespace WinUI
private void updateStatus() private void updateStatus()
{ {
var status = handler.getStatus(); var status = handler.GetStatus();
this.networkId.Content = status.address; this.networkId.Content = status.Address;
this.versionString.Content = status.version; this.versionString.Content = status.Version;
this.onlineStatus.Content = (status.online ? "ONLINE" : "OFFLINE"); this.onlineStatus.Content = (status.Online ? "ONLINE" : "OFFLINE");
} }
private void updateNetworks() private void updateNetworks()
{ {
var networks = handler.getNetworks(); var networks = handler.GetNetworks();
networksPage.setNetworks(networks); networksPage.setNetworks(networks);
} }
private void joinButton_Click(object sender, RoutedEventArgs e)
{
}
private void joinNetworkID_TextChanged(object sender, TextChangedEventArgs e)
{
}
} }
} }

View File

@ -27,35 +27,35 @@ namespace WinUI
InitializeComponent(); InitializeComponent();
this.network = network; this.network = network;
updateNetworkData(); UpdateNetworkData();
} }
private void updateNetworkData() private void UpdateNetworkData()
{ {
this.networkId.Text = network.nwid; this.networkId.Text = network.NetworkId;
this.networkName.Text = network.name; this.networkName.Text = network.NetworkName;
this.networkStatus.Text = network.status; this.networkStatus.Text = network.NetworkStatus;
this.networkType.Text = network.type; this.networkType.Text = network.NetworkType;
this.macAddress.Text = network.mac; this.macAddress.Text = network.MacAddress;
this.mtu.Text = network.mtu.ToString(); this.mtu.Text = network.MTU.ToString();
this.broadcastEnabled.Text = (network.broadcastEnabled ? "ENABLED" : "DISABLED"); this.broadcastEnabled.Text = (network.BroadcastEnabled ? "ENABLED" : "DISABLED");
this.bridgingEnabled.Text = (network.bridge ? "ENABLED" : "DISABLED"); this.bridgingEnabled.Text = (network.Bridge ? "ENABLED" : "DISABLED");
this.deviceName.Text = network.portDeviceName; this.deviceName.Text = network.DeviceName;
string iplist = ""; string iplist = "";
for (int i = 0; i < network.assignedAddresses.Length; ++i) for (int i = 0; i < network.AssignedAddresses.Length; ++i)
{ {
iplist += network.assignedAddresses[i]; iplist += network.AssignedAddresses[i];
if (i < (network.assignedAddresses.Length - 1)) if (i < (network.AssignedAddresses.Length - 1))
iplist += "\n"; iplist += "\n";
} }
this.managedIps.Text = iplist; 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 true;
return false; return false;

View File

@ -100,6 +100,8 @@
<Compile Include="NetworksPage.xaml.cs"> <Compile Include="NetworksPage.xaml.cs">
<DependentUpon>NetworksPage.xaml</DependentUpon> <DependentUpon>NetworksPage.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="ZeroTierPeerPhysicalPath.cs" />
<Compile Include="ZeroTierPeer.cs" />
<Compile Include="ZeroTierNetwork.cs" /> <Compile Include="ZeroTierNetwork.cs" />
<Compile Include="ZeroTierStatus.cs" /> <Compile Include="ZeroTierStatus.cs" />
<Page Include="MainWindow.xaml"> <Page Include="MainWindow.xaml">

View File

@ -3,24 +3,52 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WinUI namespace WinUI
{ {
public class ZeroTierNetwork public class ZeroTierNetwork
{ {
public string nwid; [JsonProperty("nwid")]
public string mac; public string NetworkId { get; set; }
public string name;
public string status; [JsonProperty("mac")]
public string type; public string MacAddress { get; set; }
public int mtu;
public bool dhcp; [JsonProperty("name")]
public bool bridge; public string NetworkName { get; set; }
public bool broadcastEnabled;
public int portError; [JsonProperty("status")]
public int netconfRevision; public string NetworkStatus { get; set; }
public string[] multicastSubscriptions;
public string[] assignedAddresses; [JsonProperty("type")]
public string portDeviceName; 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; }
} }
} }

View File

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

View File

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

View File

@ -3,19 +3,37 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
namespace WinUI namespace WinUI
{ {
public class ZeroTierStatus public class ZeroTierStatus
{ {
public string address; [JsonProperty("address")]
public string publicIdentity; public string Address { get; set; }
public bool online;
public bool tcpFallbackActive; [JsonProperty("publicIdentity")]
public int versionMajor; public string PublicIdentity { get; set; }
public int versionMinor;
public int versionRev; [JsonProperty("online")]
public string version; public bool Online { get; set; }
public UInt64 clock;
[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; }
} }
} }