-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
74 lines (63 loc) · 2.14 KB
/
App.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
namespace Hbo.Sheepish
{
using Standard;
using System.Net;
using System.Windows;
public partial class App
{
private Settings _settings;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
bool showLogin = false;
_settings = Settings.Load();
if (_settings == null)
{
_settings = new Settings
{
PrimaryQuery = "for: me #Open",
SecondaryQuery = "for: me #Resolved",
};
showLogin = true;
}
ServiceProvider.Initialize(_settings);
MainWindow = new StatusWindow();
if (!showLogin)
{
// Verify that the userlogin matches our cookie's credentials
try
{
// Mostly just care that we don't get a 400 something from this call.
YouTrackService.User currentUser = ServiceProvider.YouTrackService.GetCurrentUser();
if (_settings.UserLogin != currentUser.Login)
{
showLogin = true;
}
}
catch (WebException) { }
}
if (showLogin)
{
var loginWindow = new LoginWindow();
if (!(loginWindow.ShowDialog() ?? false))
{
Application.Current.Shutdown(0);
return;
}
_settings.UserLogin = ServiceProvider.YouTrackService.GetCurrentUser().Login;
_settings.Save();
}
ServiceProvider.OnLoggedIn();
MainWindow.Show();
SingleInstance.SingleInstanceActivated += _SignalExternalCommandLineArgs;
}
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
}
private void _SignalExternalCommandLineArgs(object sender, SingleInstanceEventArgs e)
{
((StatusWindow)MainWindow).ProcessCommandLineArgs(e.Args);
}
}
}