Repository navigation
Expand file tree
/
Copy pathfoo.cs
More file actions
158 lines (126 loc) · 5.3 KB
/
Copy pathfoo.cs
File metadata and controls
158 lines (126 loc) · 5.3 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using System.Windows;
using System.Windows.Controls;
using GitMasterGui;
using GitMasterGui.License;
using GitMasterGui.LoginWindow;
using GitMaster.UI;
using GitMaster.UI.Web;
using GitMaster.Web.Models.Api;
using GitMasterGui.License.Download;
using GitMasterGui.Api;
namespace GitMaster.LoginWindow
{
internal class WaitingLicensePanel : DockPanel
{
internal WaitingLicensePanel(
IGitMasterRestApi restApi,
LoginWindowLicenseDownloader.INotifier licenseDownloaderNotifier)
{
mRestApi = restApi;
mLicenseDownloaderNotifier = licenseDownloaderNotifier;
BuildComponents();
}
internal void DownloadLicense(string teamInvitationCode)
{
RunDownloadLicense(teamInvitationCode);
}
internal void Dispose()
{
if (mGetLicenseButton != null)
mGetLicenseButton.Click -= GetLicenseButton_Click;
}
void LoginButton_Click(object sender, RoutedEventArgs e)
{
ClearErrors();
LoginConfiguration.Data data = LoginConfiguration.Data.Build(
mUserTextBox.Text,
mPasswordTextBox.Text);
Login.ValidationResult result = Login.Validate(data);
if (!result.IsOk())
{
ShowErrors(result);
return;
}
Login.Run(mRestApi, data, mProgressControls, mLoginSuccessNotifier);
}
internal void NotifyLicenseError(string message)
{
Children.Clear();
Image mascotImage = ControlBuilder.CreateImage(
GitMasterImages.GetImage(
GitMasterImages.ImageName.IllustrationSignupError));
mascotImage.Width = 300;
mascotImage.Margin = new Thickness(50, 0, 0, 0);
mascotImage.HorizontalAlignment = HorizontalAlignment.Center;
mascotImage.VerticalAlignment = VerticalAlignment.Center;
WebEntriesPacker.AddMascotContentComponents(
this, mascotImage, CreateContentErrorPanel(message));
}
void GetLicenseButton_Click(object sender, RoutedEventArgs e)
{
Children.Clear();
BuildComponents();
RunDownloadLicense(mTeamInvitationCodeTextBox.Text);
}
void RunDownloadLicense(string teamInvitationCode)
{
LoginWindowLicenseDownloader.Run(mRestApi, teamInvitationCode, mLicenseDownloaderNotifier);
}
void BuildComponents()
{
Image mascotImage = ControlBuilder.CreateImage(
GitMasterImages.GetImage(
GitMasterImages.ImageName.IllustrationLicenseWaiting));
mascotImage.HorizontalAlignment = HorizontalAlignment.Center;
mascotImage.VerticalAlignment = VerticalAlignment.Center;
mascotImage.Width = 300;
mascotImage.Margin = new Thickness(50, 0, 0, 0);
WebEntriesPacker.AddMascotContentComponents(
this, mascotImage, CreateContentPanel());
}
Panel CreateContentPanel()
{
StackPanel result = new StackPanel();
TextBlock titleTextBlock = WebControlBuilder.CreateTitle(
GitMasterLocalization.GetString(
GitMasterLocalization.Name.WaitingLicensePanelTitle));
titleTextBlock.Margin = new Thickness(0, 25, 0, 15);
WebEntriesPacker.AddRelatedComponents(
result,
titleTextBlock,
WebEntriesPacker.CreateWaitingPanel(GitMasterLocalization.GetString(
GitMasterLocalization.Name.DownloadingLicense)));
return result;
}
Panel CreateContentErrorPanel(string message)
{
StackPanel result = new StackPanel();
TextBlock titleTextBlock = WebControlBuilder.CreateTitle(
GitMasterLocalization.GetString(
GitMasterLocalization.Name.WaitingLicensePanelErrorTitle));
titleTextBlock.Margin = new Thickness(0, 40, 0, 15);
WebErrorPanel errorPanel = new WebErrorPanel();
errorPanel.ShowError(message);
mTeamInvitationCodeTextBox = WebControlBuilder.CreateTextBox(
GitMasterLocalization.GetString(
GitMasterLocalization.Name.WaitingLicensePanelTeamInvitationCodeWatermark));
mGetLicenseButton = WebControlBuilder.CreateMainActionButton(
GitMasterLocalization.GetString(
GitMasterLocalization.Name.GetLicenseButtonUppercase));
mGetLicenseButton.Click += GetLicenseButton_Click;
WebEntriesPacker.AddRelatedComponents(
result,
titleTextBlock,
errorPanel,
mTeamInvitationCodeTextBox,
mGetLicenseButton);
return result;
}
TextBox mTeamInvitationCodeTextBox;
Button mGetLicenseButton;
LoginWindowLicenseDownloader.INotifier mLicenseDownloaderNotifier;
IGitMasterRestApi mRestApi;
string mSuccessfulPanelTitle;
}
}