summaryrefslogtreecommitdiff
path: root/windows/WinUI/PreferencesView.xaml.cs
diff options
context:
space:
mode:
authorGrant Limberg <grant.limberg@zerotier.com>2017-09-22 15:33:09 -0700
committerGrant Limberg <grant.limberg@zerotier.com>2017-09-22 15:33:09 -0700
commitc666f92e359061c0a4c133ba090832a059298782 (patch)
tree43ab48c8673781f2437dbf326509b1f37e827c4e /windows/WinUI/PreferencesView.xaml.cs
parenteb42ef68eeb7a19a9b841cd9f3fe67ffb999c827 (diff)
downloadinfinitytier-c666f92e359061c0a4c133ba090832a059298782.tar.gz
infinitytier-c666f92e359061c0a4c133ba090832a059298782.zip
new startup process UI for Windows
Diffstat (limited to 'windows/WinUI/PreferencesView.xaml.cs')
-rw-r--r--windows/WinUI/PreferencesView.xaml.cs42
1 files changed, 33 insertions, 9 deletions
diff --git a/windows/WinUI/PreferencesView.xaml.cs b/windows/WinUI/PreferencesView.xaml.cs
index c6733be6..1a5ed756 100644
--- a/windows/WinUI/PreferencesView.xaml.cs
+++ b/windows/WinUI/PreferencesView.xaml.cs
@@ -22,7 +22,7 @@ namespace WinUI
{
public static string AppName = "ZeroTier One";
private RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
-
+ private string AppLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
public PreferencesView()
{
InitializeComponent();
@@ -30,21 +30,45 @@ namespace WinUI
string keyValue = rk.GetValue(AppName) as string;
- if (keyValue != null && keyValue.Equals(System.Reflection.Assembly.GetExecutingAssembly().Location))
+ if (keyValue != null && keyValue.Equals(AppLocation))
{
startupCheckbox.IsChecked = true;
}
- }
- private void startupCheckbox_Checked(object sender, RoutedEventArgs e)
- {
- rk.SetValue(AppName, System.Reflection.Assembly.GetExecutingAssembly().Location);
+ CentralAPI api = CentralAPI.Instance;
+ CentralInstanceTextBox.Text = api.Central.ServerURL;
+ APIKeyTextBox.Text = api.Central.APIKey;
}
- private void startupCheckbox_Unchecked(object sender, RoutedEventArgs e)
+ private void OKButton_Clicked(object sender, RoutedEventArgs e)
{
- rk.DeleteValue(AppName);
- }
+ CentralAPI api = CentralAPI.Instance;
+
+ if (api.Central.ServerURL != CentralInstanceTextBox.Text ||
+ api.Central.APIKey != APIKeyTextBox.Text)
+ {
+ CentralServer newServer = new CentralServer();
+ newServer.ServerURL = CentralInstanceTextBox.Text;
+ newServer.APIKey = APIKeyTextBox.Text;
+
+ api.Central = newServer;
+ }
+ if (startupCheckbox.IsChecked.HasValue && (bool)startupCheckbox.IsChecked)
+ {
+ rk.SetValue(AppName, AppLocation);
+ }
+ else
+ {
+ string keyValue = rk.GetValue(AppName) as string;
+
+ if (keyValue != null && keyValue.Equals(AppLocation))
+ {
+ rk.DeleteValue(AppName);
+ }
+ }
+
+ Close();
+ }
}
}