mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-03 17:22:58 +00:00
Added "Create and Join Network" menu item to windows system tray UI
This commit is contained in:
parent
fc225401a5
commit
4e6151ebd9
@ -43,7 +43,10 @@
|
|||||||
<Separator/>
|
<Separator/>
|
||||||
<MenuItem Header="ZeroTier Central"
|
<MenuItem Header="ZeroTier Central"
|
||||||
Click="ToolbarItem_CentralClicked"/>
|
Click="ToolbarItem_CentralClicked"/>
|
||||||
|
<MenuItem Header="Create and Join Network"
|
||||||
|
Click="ToolbarItem_NewNetwork"
|
||||||
|
x:Name="newNetworkItem"/>
|
||||||
|
<Separator/>
|
||||||
<MenuItem Header="About..."
|
<MenuItem Header="About..."
|
||||||
Click="ToolbarItem_AboutClicked"/>
|
Click="ToolbarItem_AboutClicked"/>
|
||||||
<MenuItem Header="Preferences..."
|
<MenuItem Header="Preferences..."
|
||||||
|
@ -120,17 +120,21 @@ namespace WinUI
|
|||||||
if (shouldShowOnboardProcess)
|
if (shouldShowOnboardProcess)
|
||||||
{
|
{
|
||||||
// TODO: Show onboarding process window (on main thread
|
// TODO: Show onboarding process window (on main thread
|
||||||
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
showOnboardProcess();
|
||||||
{
|
|
||||||
PageSwitcher ps = new PageSwitcher();
|
|
||||||
ps.Show();
|
|
||||||
}));
|
|
||||||
|
|
||||||
shouldShowOnboardProcess = false;
|
shouldShowOnboardProcess = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showOnboardProcess()
|
||||||
|
{
|
||||||
|
Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||||
|
{
|
||||||
|
PageSwitcher ps = new PageSwitcher();
|
||||||
|
ps.Show();
|
||||||
|
}));
|
||||||
|
}
|
||||||
private void updateStatus(ZeroTierStatus status)
|
private void updateStatus(ZeroTierStatus status)
|
||||||
{
|
{
|
||||||
if (status != null)
|
if (status != null)
|
||||||
@ -142,6 +146,15 @@ namespace WinUI
|
|||||||
nodeId = status.Address;
|
nodeId = status.Address;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CentralAPI.Instance.HasAccessToken())
|
||||||
|
{
|
||||||
|
newNetworkItem.IsEnabled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newNetworkItem.IsEnabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToolbarItem_NodeIDClicked(object sender, System.Windows.RoutedEventArgs e)
|
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)
|
private void setWindowPosition(Window w)
|
||||||
{
|
{
|
||||||
double width = w.ActualWidth;
|
double width = w.ActualWidth;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user