new startup process UI for Windows
This commit is contained in:
38
windows/WinUI/OnboardProcess/CreateAccount.xaml
Normal file
38
windows/WinUI/OnboardProcess/CreateAccount.xaml
Normal file
@@ -0,0 +1,38 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.CreateAccount"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Margin="10">Email Address:</Label>
|
||||
<TextBox x:Name="EmailAddressTextBox" Grid.Column="1" Grid.Row="0" Width="150" Margin="10"></TextBox>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="10">Password:</Label>
|
||||
<PasswordBox x:Name="PasswordTextBox1" Grid.Column="1" Grid.Row="1" PasswordChar="*" Margin="10"/>
|
||||
<Label Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" Margin="10">Repeat Password:</Label>
|
||||
<PasswordBox x:Name="PasswordTextBox2" Grid.Column="1" Grid.Row="2" PasswordChar="*" Margin="10"/>
|
||||
|
||||
<Button Grid.Column="1" Grid.Row="3" Click="CreateAccount_Click" Margin="10" Content="Create Account" Background="#FFFFB354" Width="90" HorizontalAlignment="Right"/>
|
||||
|
||||
<Label x:Name="ErrorText" Grid.Row="4" Grid.ColumnSpan="2" HorizontalAlignment="Center"></Label>
|
||||
<Label Grid.Row="5"></Label>
|
||||
<Button Grid.Column="0" Grid.Row="6" Background="#FFFFB354" Click="BackButton_Click">Go Back</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
66
windows/WinUI/OnboardProcess/CreateAccount.xaml.cs
Normal file
66
windows/WinUI/OnboardProcess/CreateAccount.xaml.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CreateAccount.xaml
|
||||
/// </summary>
|
||||
public partial class CreateAccount : UserControl, ISwitchable
|
||||
{
|
||||
public CreateAccount()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UtilizeState(object state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CreateAccount_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DoCreateAccount();
|
||||
}
|
||||
|
||||
public void BackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new RegisterOrLogIn());
|
||||
}
|
||||
|
||||
public async void DoCreateAccount()
|
||||
{
|
||||
if (PasswordTextBox1.Password.ToString() != PasswordTextBox2.Password.ToString())
|
||||
{
|
||||
ErrorText.Content = "Passwords do not match!";
|
||||
}
|
||||
else
|
||||
{
|
||||
CentralAPI api = CentralAPI.Instance;
|
||||
bool accountCreated = await api.Login(EmailAddressTextBox.Text,
|
||||
PasswordTextBox1.Password.ToString(), true);
|
||||
|
||||
if (accountCreated)
|
||||
{
|
||||
Switcher.Switch(new CreateOrJoin());
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorText.Content = "An error ocurred while creating your account.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
windows/WinUI/OnboardProcess/CreateOrJoin.xaml
Normal file
49
windows/WinUI/OnboardProcess/CreateOrJoin.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.CreateOrJoin"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="400">
|
||||
<Grid HorizontalAlignment="Stretch" Margin="15">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="1" x:Name="CreateButton" Content="Create a Network" Background="#FFFFB354" Click="OnCreateButtonClick"/>
|
||||
|
||||
<Label Grid.Column="1" Grid.Row="1" Content="Or" HorizontalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Column="1" Grid.Row="2" Content="Join a Network:" HorizontalAlignment="Center"/>
|
||||
|
||||
<ListBox Grid.ColumnSpan="3" Grid.Column="0" Grid.Row="3" Name="listViewDataBinding" HorizontalContentAlignment="Stretch">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Margin="5" HorizontalAlignment="Left" Text="{Binding Id}"/>
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Margin="5" HorizontalAlignment="Center" Text="{Binding Config.Name}"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Join" HorizontalAlignment="Right" Background="#FFFFB354" Tag="{Binding Id}" Click="OnJoinButtonClick"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
98
windows/WinUI/OnboardProcess/CreateOrJoin.xaml.cs
Normal file
98
windows/WinUI/OnboardProcess/CreateOrJoin.xaml.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CreateOrJoin.xaml
|
||||
/// </summary>
|
||||
public partial class CreateOrJoin : UserControl, ISwitchable
|
||||
{
|
||||
private List<CentralNetwork> networkList = new List<CentralNetwork>();
|
||||
|
||||
public CreateOrJoin()
|
||||
{
|
||||
InitializeComponent();
|
||||
listViewDataBinding.ItemsSource = networkList;
|
||||
|
||||
GetAvailableNetworks();
|
||||
}
|
||||
|
||||
public void UtilizeState(object state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private async void GetAvailableNetworks()
|
||||
{
|
||||
CentralAPI api = CentralAPI.Instance;
|
||||
|
||||
List<CentralNetwork> networks = await api.GetNetworkList();
|
||||
|
||||
foreach (CentralNetwork n in networks)
|
||||
{
|
||||
networkList.Add(n);
|
||||
}
|
||||
|
||||
listViewDataBinding.Items.Refresh();
|
||||
}
|
||||
|
||||
public void OnJoinButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Button button = sender as Button;
|
||||
string networkId = button.Tag as string;
|
||||
|
||||
APIHandler handler = APIHandler.Instance;
|
||||
|
||||
handler.JoinNetwork(this.Dispatcher, networkId);
|
||||
|
||||
AuthorizeNetworkMember(networkId);
|
||||
}
|
||||
|
||||
public void OnCreateButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CreateNewNetwork();
|
||||
}
|
||||
|
||||
private async void CreateNewNetwork()
|
||||
{
|
||||
CentralAPI api = CentralAPI.Instance;
|
||||
|
||||
CentralNetwork newNetwork = await api.CreateNewNetwork();
|
||||
|
||||
APIHandler handler = APIHandler.Instance;
|
||||
|
||||
handler.JoinNetwork(this.Dispatcher, newNetwork.Id);
|
||||
|
||||
AuthorizeNetworkMember(newNetwork.Id);
|
||||
}
|
||||
|
||||
private async void AuthorizeNetworkMember(string networkId)
|
||||
{
|
||||
string nodeId = APIHandler.Instance.NodeAddress();
|
||||
|
||||
bool authorized = await CentralAPI.Instance.AuthorizeNode(nodeId, networkId);
|
||||
|
||||
if (authorized)
|
||||
{
|
||||
Switcher.Switch(new Finished());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
windows/WinUI/OnboardProcess/EnterToken.xaml
Normal file
29
windows/WinUI/OnboardProcess/EnterToken.xaml
Normal file
@@ -0,0 +1,29 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.EnterToken"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="10" TextWrapping="Wrap" HorizontalAlignment="Center" Text="Your API Token can be found or created on https://my.zerotier.com"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="API Token:" Margin="10"/>
|
||||
<TextBox x:Name="APITokenInput" Grid.Column="1" Grid.Row="1" Margin="10"/>
|
||||
|
||||
<Button Grid.Column="1" Grid.Row="2" Background="#FFFFB354" Content="Next" HorizontalAlignment="Right" Click="Next_Click" Margin="10"/>
|
||||
<Label Grid.Row="3"/>
|
||||
<Button Grid.Column="0" Grid.Row="4" Background="#FFFFB354" Content="Go Back" Click="BackButton_Click" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
57
windows/WinUI/OnboardProcess/EnterToken.xaml.cs
Normal file
57
windows/WinUI/OnboardProcess/EnterToken.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EnterToken.xaml
|
||||
/// </summary>
|
||||
public partial class EnterToken : UserControl, ISwitchable
|
||||
{
|
||||
public EnterToken()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (!string.IsNullOrEmpty(CentralAPI.Instance.Central.APIKey))
|
||||
{
|
||||
APITokenInput.Text = CentralAPI.Instance.Central.APIKey;
|
||||
}
|
||||
}
|
||||
|
||||
public void UtilizeState(object staqte)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Next_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CentralAPI api = CentralAPI.Instance;
|
||||
|
||||
if (api.Central.APIKey != APITokenInput.Text)
|
||||
{
|
||||
CentralServer server = new CentralServer();
|
||||
server.APIKey = APITokenInput.Text;
|
||||
api.Central = server;
|
||||
}
|
||||
|
||||
Switcher.Switch(new CreateOrJoin());
|
||||
}
|
||||
|
||||
private void BackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new RegisterOrLogIn());
|
||||
}
|
||||
}
|
||||
}
|
||||
27
windows/WinUI/OnboardProcess/Finished.xaml
Normal file
27
windows/WinUI/OnboardProcess/Finished.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.Finished"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="All Finished!" HorizontalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" Text=""/>
|
||||
<TextBlock Grid.Column="0" Grid.ColumnSpan="1" Grid.Row="2" MaxWidth="270" HorizontalAlignment="Center" Margin="10" Text="You've now joined your first ZeroTier network. Now go to add your other machines!" TextWrapping="Wrap"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" Text=""/>
|
||||
<Button Grid.Column="0" Grid.Row="4" MaxWidth="100" Click="DoneButton_Click" Background="#FFFFB354" Margin="10">Done!</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
37
windows/WinUI/OnboardProcess/Finished.xaml.cs
Normal file
37
windows/WinUI/OnboardProcess/Finished.xaml.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Finished.xaml
|
||||
/// </summary>
|
||||
public partial class Finished : UserControl, ISwitchable
|
||||
{
|
||||
public Finished()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void UtilizeState(object state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void DoneButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Window.GetWindow(this).Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
windows/WinUI/OnboardProcess/LogIn.xaml
Normal file
35
windows/WinUI/OnboardProcess/LogIn.xaml
Normal file
@@ -0,0 +1,35 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.LogIn"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" Margin="10">Email Address:</Label>
|
||||
<TextBox x:Name="EmailAddressTextBox" Grid.Column="1" Grid.Row="0" MinWidth="150" Margin="10"></TextBox>
|
||||
|
||||
<Label Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="10">Password:</Label>
|
||||
<PasswordBox x:Name="PasswordTextBox" Grid.Column="1" Grid.Row="1" PasswordChar="*" Margin="10"/>
|
||||
|
||||
<Button Grid.Column="1" Grid.Row="2" Click="LoginButton_Click" Content="LogIn" Background="#FFFFB354" Width="90" Margin="10" HorizontalAlignment="Right"/>
|
||||
|
||||
<Label x:Name="ErrorText" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Center"></Label>
|
||||
<Label Grid.Row="4"></Label>
|
||||
<Button Grid.Column="0" Grid.Row="5" Background="#FFFFB354" Click="BackButton_Click">Go Back</Button>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
57
windows/WinUI/OnboardProcess/LogIn.xaml.cs
Normal file
57
windows/WinUI/OnboardProcess/LogIn.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LogIn.xaml
|
||||
/// </summary>
|
||||
public partial class LogIn : UserControl, ISwitchable
|
||||
{
|
||||
public LogIn()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UtilizeState(object state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DoLogin();
|
||||
}
|
||||
|
||||
public void BackButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new RegisterOrLogIn());
|
||||
}
|
||||
|
||||
private async void DoLogin()
|
||||
{
|
||||
CentralAPI api = CentralAPI.Instance;
|
||||
bool didLogIn = await api.Login(EmailAddressTextBox.Text, PasswordTextBox.Password.ToString(), false);
|
||||
if (didLogIn)
|
||||
{
|
||||
Switcher.Switch(new CreateOrJoin());
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorText.Content = "Invalid username or password";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
windows/WinUI/OnboardProcess/RegisterOrLogIn.xaml
Normal file
27
windows/WinUI/OnboardProcess/RegisterOrLogIn.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<UserControl x:Class="WinUI.OnboardProcess.RegisterOrLogIn"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:WinUI.OnboardProcess"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<StackPanel>
|
||||
<TextBlock HorizontalAlignment="Center" FontSize="20" FontWeight="Bold" FontFamily="Segoe UI">Welcome to ZeroTier</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center" FontSize="16">Let's get started!</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center"> </TextBlock>
|
||||
<TextBlock HorizontalAlignment="Center" TextWrapping="Wrap">If you haven't yet created an account, click "Create Account" below. If you have an account, you can log in with your username/password, or simply enter an API key.</TextBlock>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type Button}">
|
||||
<Setter Property="Margin" Value="10,10,0,0"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button x:Name="CreateAccountButton" Margin="10,5" Content="Create Account" Background="#FFFFB354" Click="CreateAccountButton_Click"/>
|
||||
|
||||
<Button x:Name="LogInButton" Margin="10,5" Content="Log In" Background="#FFFFB354" Click="LogInButton_Click"/>
|
||||
|
||||
<Button x:Name="TokenButton" Margin="10,5" Content="API Token" Background="#FFFFB354" Click="APIToken_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
48
windows/WinUI/OnboardProcess/RegisterOrLogIn.xaml.cs
Normal file
48
windows/WinUI/OnboardProcess/RegisterOrLogIn.xaml.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace WinUI.OnboardProcess
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RegisterOrLogIn.xaml
|
||||
/// </summary>
|
||||
public partial class RegisterOrLogIn : UserControl, ISwitchable
|
||||
{
|
||||
public RegisterOrLogIn()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UtilizeState(object state)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void CreateAccountButton_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new CreateAccount());
|
||||
}
|
||||
|
||||
private void LogInButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new LogIn());
|
||||
}
|
||||
|
||||
public void APIToken_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Switcher.Switch(new EnterToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user