This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
MainWindow.xaml.cs
75 lines (62 loc) · 1.8 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System.Linq;
using System.Windows;
using System.Windows.Input;
using SpeckleCore;
namespace SpecklePopup
{
public partial class MainWindow : Window
{
public string restApi;
public string apitoken;
public string selectedEmail;
public string selectedServer;
public bool HasDefaultAccount = false;
public MainWindow(bool autoClose, bool showButtons)
{
InitializeComponent();
//make the "use selected" button visible
if (showButtons)
{
AccountsControl.ButonUseSelected.Visibility = Visibility.Visible;
AccountsControl.ButonUseSelected.Click += ButtonUseSelected_Click;
}
//if autoclose and there is a defaut account
if (autoClose && AccountsControl.accounts.Any(x => x.IsDefault))
{
UseSelected(AccountsControl.accounts.First(x => x.IsDefault));
HasDefaultAccount = true;
Close();
}
WindowStartupLocation = WindowStartupLocation.CenterScreen;
DragRectangle.MouseDown += (sender, e) =>
{
DragMove();
};
}
private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonUseSelected_Click(object sender, RoutedEventArgs e)
{
if (!(AccountsControl.AccountListBox.SelectedIndex != -1))
{
MessageBox.Show("Please select an account first.");
return;
}
UseSelected(AccountsControl.accounts[AccountsControl.AccountListBox.SelectedIndex]);
Close();
}
private void UseSelected(Account account)
{
restApi = account.RestApi;
apitoken = account.Token;
selectedEmail = account.Email;
selectedServer = account.ServerName;
}
}
}