can now leave networks

This commit is contained in:
Grant Limberg 2015-10-26 19:53:03 -07:00
parent 300a951730
commit 87496e9f4a
5 changed files with 33 additions and 14 deletions

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WinUI" xmlns:local="clr-namespace:WinUI"
mc:Ignorable="d" x:Class="WinUI.MainWindow" mc:Ignorable="d" x:Class="WinUI.MainWindow"
Title="ZeroTier One" Height="495" Width="705" Icon="ZeroTierIcon.ico"> Title="ZeroTier One" Height="500" Width="700" Icon="ZeroTierIcon.ico">
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>

View File

@ -33,6 +33,8 @@ namespace WinUI
{ {
InitializeComponent(); InitializeComponent();
networksPage.SetAPIHandler(handler);
updateStatus(); updateStatus();
updateNetworks(); updateNetworks();
updatePeers(); updatePeers();

View File

@ -8,6 +8,7 @@
<Grid Background="#FFFFFFFF" Margin="5,0,5,1"> <Grid Background="#FFFFFFFF" Margin="5,0,5,1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="10"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -23,7 +24,7 @@
<RowDefinition Height="auto"/> <RowDefinition Height="auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"> <Grid Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
@ -42,21 +43,21 @@
<TextBlock TextWrapping="Wrap" Text="Device" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="7" Foreground="#FF000000"/> <TextBlock TextWrapping="Wrap" Text="Device" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="7" Foreground="#FF000000"/>
<TextBlock TextWrapping="Wrap" Text="Managed IPs" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="8" Foreground="#FF000000"/> <TextBlock TextWrapping="Wrap" Text="Managed IPs" HorizontalAlignment="Right" Grid.Column="0" Grid.Row="8" Foreground="#FF000000"/>
<TextBlock x:Name="networkStatus" TextWrapping="Wrap" HorizontalAlignment="Right" Text="OK" TextAlignment="Right" Grid.Column="1" Grid.Row="1" Foreground="#FF000000"/> <TextBlock x:Name="networkStatus" TextWrapping="Wrap" HorizontalAlignment="Right" Text="OK" TextAlignment="Right" Grid.Column="2" Grid.Row="1" Foreground="#FF000000"/>
<TextBlock x:Name="networkType" TextWrapping="Wrap" Text="PUBLIC" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="2" Foreground="#FF000000"/> <TextBlock x:Name="networkType" TextWrapping="Wrap" Text="PUBLIC" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="2" Foreground="#FF000000"/>
<TextBlock x:Name="macAddress" TextWrapping="Wrap" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="3" Foreground="#FF000000"><Span><Run Text="02:83:4a:1e:4b:3a"/></Span></TextBlock> <TextBlock x:Name="macAddress" TextWrapping="Wrap" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="3" Foreground="#FF000000"><Span><Run Text="02:83:4a:1e:4b:3a"/></Span></TextBlock>
<TextBlock x:Name="mtu" TextWrapping="Wrap" Text="2800" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="4" Foreground="#FF000000"/> <TextBlock x:Name="mtu" TextWrapping="Wrap" Text="2800" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="4" Foreground="#FF000000"/>
<TextBlock x:Name="broadcastEnabled" TextWrapping="Wrap" Text="ENABLED" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="5" Foreground="#FF000000"/> <TextBlock x:Name="broadcastEnabled" TextWrapping="Wrap" Text="ENABLED" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="5" Foreground="#FF000000"/>
<TextBlock x:Name="bridgingEnabled" TextWrapping="Wrap" Text="DISABLED" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="6" Foreground="#FF000000"/> <TextBlock x:Name="bridgingEnabled" TextWrapping="Wrap" Text="DISABLED" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="6" Foreground="#FF000000"/>
<TextBlock x:Name="deviceName" TextWrapping="Wrap" HorizontalAlignment="Right" Grid.Column="1" Grid.Row="7" Foreground="#FF000000"><Span><Run Text="ethernet_32771"/></Span></TextBlock> <TextBlock x:Name="deviceName" TextWrapping="Wrap" HorizontalAlignment="Right" Grid.Column="2" Grid.Row="7" Foreground="#FF000000"><Span><Run Text="ethernet_32771"/></Span></TextBlock>
<TextBlock x:Name="managedIps" TextWrapping="Wrap" HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="1" Grid.Row="8" Foreground="#FF000000"><Span><Run Text="28.2.169.248/7 "/></Span><LineBreak/><Span><Run Text="fd80:56c2:e21c:0000:0199:9383:4a02:a9f8/88"/></Span></TextBlock> <TextBlock x:Name="managedIps" TextWrapping="Wrap" HorizontalAlignment="Right" TextAlignment="Right" Grid.Column="2" Grid.Row="8" Foreground="#FF000000"><Span><Run Text="28.2.169.248/7 "/></Span><LineBreak/><Span><Run Text="fd80:56c2:e21c:0000:0199:9383:4a02:a9f8/88"/></Span></TextBlock>
<Grid Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="2" Background="#FFFFFFFF"> <Grid Grid.Column="0" Grid.Row="9" Grid.ColumnSpan="3" Background="#FFFFFFFF">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button /> <Button />
<Button x:Name="leaveButton" Content="Leave" HorizontalAlignment="Right" VerticalAlignment="Top" Width="75" Background="#FFFFB354"/> <Button x:Name="leaveButton" Content="Leave" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="75" Background="#FFFFB354" Click="leaveButton_Click"/>
</Grid> </Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -20,11 +20,14 @@ namespace WinUI
/// </summary> /// </summary>
public partial class NetworkInfoView : UserControl public partial class NetworkInfoView : UserControl
{ {
ZeroTierNetwork network; private APIHandler handler;
private ZeroTierNetwork network;
public NetworkInfoView(ZeroTierNetwork network) public NetworkInfoView(APIHandler handler, ZeroTierNetwork network)
{ {
InitializeComponent(); InitializeComponent();
this.handler = handler;
this.network = network; this.network = network;
UpdateNetworkData(); UpdateNetworkData();
@ -60,5 +63,10 @@ namespace WinUI
return false; return false;
} }
private void leaveButton_Click(object sender, RoutedEventArgs e)
{
handler.LeaveNetwork(network.NetworkId);
}
} }
} }

View File

@ -20,11 +20,18 @@ namespace WinUI
/// </summary> /// </summary>
public partial class NetworksPage : UserControl public partial class NetworksPage : UserControl
{ {
private APIHandler handler;
public NetworksPage() public NetworksPage()
{ {
InitializeComponent(); InitializeComponent();
} }
public void SetAPIHandler(APIHandler handler)
{
this.handler = handler;
}
public void setNetworks(List<ZeroTierNetwork> networks) public void setNetworks(List<ZeroTierNetwork> networks)
{ {
this.wrapPanel.Children.Clear(); this.wrapPanel.Children.Clear();
@ -33,6 +40,7 @@ namespace WinUI
{ {
this.wrapPanel.Children.Add( this.wrapPanel.Children.Add(
new NetworkInfoView( new NetworkInfoView(
handler,
networks.ElementAt<ZeroTierNetwork>(i))); networks.ElementAt<ZeroTierNetwork>(i)));
} }
} }