From 4e6151ebd97cbc145d6997f377b3db28d51c6bfc Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Thu, 28 Jun 2018 15:24:45 -0700 Subject: Added "Create and Join Network" menu item to windows system tray UI --- windows/WinUI/ToolbarItem.xaml | 5 ++++- windows/WinUI/ToolbarItem.xaml.cs | 42 ++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'windows') 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 @@ - + + - { - 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; -- cgit v1.2.3