summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2018-06-28 15:24:45 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2018-06-28 15:24:45 -0700
commit4e6151ebd97cbc145d6997f377b3db28d51c6bfc (patch)
tree3402a25c7322672e72b31db4c0f6a38ce2878527
parentfc225401a5890b07c3f9848219f6e4bf41b8b0a7 (diff)
downloadinfinitytier-4e6151ebd97cbc145d6997f377b3db28d51c6bfc.tar.gz
infinitytier-4e6151ebd97cbc145d6997f377b3db28d51c6bfc.zip
Added "Create and Join Network" menu item to windows system tray UI
-rw-r--r--windows/WinUI/ToolbarItem.xaml5
-rw-r--r--windows/WinUI/ToolbarItem.xaml.cs42
2 files changed, 41 insertions, 6 deletions
diff --git a/windows/WinUI/ToolbarItem.xaml b/windows/WinUI/ToolbarItem.xaml
index 85e4122a..9517455c 100644
--- a/windows/WinUI/ToolbarItem.xaml
+++ b/windows/WinUI/ToolbarItem.xaml
@@ -43,7 +43,10 @@
<Separator/>
<MenuItem Header="ZeroTier Central"
Click="ToolbarItem_CentralClicked"/>
-
+ <MenuItem Header="Create and Join Network"
+ Click="ToolbarItem_NewNetwork"
+ x:Name="newNetworkItem"/>
+ <Separator/>
<MenuItem Header="About..."
Click="ToolbarItem_AboutClicked"/>
<MenuItem Header="Preferences..."
diff --git a/windows/WinUI/ToolbarItem.xaml.cs b/windows/WinUI/ToolbarItem.xaml.cs
index c16de3c3..2a0d717b 100644
--- a/windows/WinUI/ToolbarItem.xaml.cs
+++ b/windows/WinUI/ToolbarItem.xaml.cs
@@ -120,17 +120,21 @@ namespace WinUI
if (shouldShowOnboardProcess)
{
// TODO: Show onboarding process window (on main thread
- Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
- {
- PageSwitcher ps = new PageSwitcher();
- ps.Show();
- }));
+ showOnboardProcess();
shouldShowOnboardProcess = false;
}
}
}
+ private void showOnboardProcess()
+ {
+ Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
+ {
+ PageSwitcher ps = new PageSwitcher();
+ ps.Show();
+ }));
+ }
private void updateStatus(ZeroTierStatus status)
{
if (status != null)
@@ -142,6 +146,15 @@ namespace WinUI
nodeId = status.Address;
}));
}
+
+ if (CentralAPI.Instance.HasAccessToken())
+ {
+ newNetworkItem.IsEnabled = true;
+ }
+ else
+ {
+ newNetworkItem.IsEnabled = false;
+ }
}
private void ToolbarItem_NodeIDClicked(object sender, System.Windows.RoutedEventArgs e)
@@ -331,6 +344,25 @@ namespace WinUI
}
}
+ private async void ToolbarItem_NewNetwork(object sender, System.Windows.RoutedEventArgs e)
+ {
+ if (CentralAPI.Instance.HasAccessToken())
+ {
+ CentralAPI api = CentralAPI.Instance;
+ CentralNetwork newNetwork = await api.CreateNewNetwork();
+
+ APIHandler handler = APIHandler.Instance;
+ handler.JoinNetwork(this.Dispatcher, newNetwork.Id);
+
+ string nodeId = APIHandler.Instance.NodeAddress();
+ bool authorized = await CentralAPI.Instance.AuthorizeNode(nodeId, newNetwork.Id);
+ }
+ else
+ {
+ showOnboardProcess();
+ }
+ }
+
private void setWindowPosition(Window w)
{
double width = w.ActualWidth;