This repository was archived by the owner on Jun 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBSIT_ProgramHeadSetup.vb
More file actions
262 lines (240 loc) · 12.3 KB
/
Copy pathBSIT_ProgramHeadSetup.vb
File metadata and controls
262 lines (240 loc) · 12.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
Imports System.IO
Imports System.Net
Imports System.Resources
Imports System.Text.RegularExpressions
Imports Svg
Public Class BSIT_ProgramHeadSetup
Inherits BaseForm
Private FormPanel As New Transparent.FlowLayoutPanel
Protected Sub BSIT_ProgramHeadSetup_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Name = "BSIT Program Head Setup"
Me.FormPanel.MinimumSize = New Size(
Me.Width * 0.5,
0
)
Me.FormPanel.MaximumSize = New Size(
Me.Width * 0.5,
0
)
Me.FormPanel.AutoSize = True
Me.FormPanel.Location = New Point(
CInt((Me.Width * 0.75 - Me.FormPanel.Width * 0.5) - Globals.Unit(2)),
CInt(Me.Height * 0.5 - Me.FormPanel.Height * 0.5)
)
Me.Contents.Controls.Add(Me.FormPanel)
Dim Logo As New PictureBox With {
.SizeMode = PictureBoxSizeMode.Zoom,
.Name = "Logo"
}
Dim resourcesManager As ResourceManager = My.Resources.ResourceManager
Dim LogoImage As Image = resourcesManager.GetObject("CdMSMS-ICS Logo")
Logo.Image = LogoImage
Logo.Size = New Size(Me.FormPanel.Width, CInt(LogoImage.Size.Height * (Me.FormPanel.Width / LogoImage.Size.Width)))
Me.FormPanel.Controls.Add(Logo)
Dim Intro As New Transparent.Label With {
.Text = "Continue by registering the BSIT Program Head.",
.MaximumSize = New Size(Me.FormPanel.Width, 0),
.MinimumSize = New Size(Me.FormPanel.Width, 0),
.AutoSize = True,
.Font = Globals.GetFont("Raleway", Globals.Unit(1), FontStyle.Bold),
.ForeColor = Globals.Palette("Primary"),
.TextAlign = ContentAlignment.MiddleCenter
}
Me.FormPanel.Controls.Add(Intro)
Dim NamePanel As New Transparent.Panel With {
.Size = New Size(Me.FormPanel.Width - Globals.Unit(2), Globals.Unit(1))
}
Me.FormPanel.Controls.Add(NamePanel)
Dim FirstNameInput As New BaseTextInput With {
.Name = "First Name",
.Size = New Size((NamePanel.Width / 2) - Globals.Unit(0.25), Globals.Unit(1))
}
FirstNameInput.Location = New Point(0, 0)
NamePanel.Controls.Add(FirstNameInput)
Dim LastNameInput As New BaseTextInput With {
.Name = "Last Name",
.Size = New Size((NamePanel.Width / 2) - Globals.Unit(0.25), Globals.Unit(1))
}
LastNameInput.Location = New Point(NamePanel.Width - LastNameInput.Width, 0)
NamePanel.Controls.Add(LastNameInput)
Dim EmailInput As New BaseTextInput With {
.Name = "Email",
.Size = New Size(Me.FormPanel.Width - Globals.Unit(2), Globals.Unit(1))
}
Me.FormPanel.Controls.Add(EmailInput)
Dim PasswordInput As New BaseTextInput With {
.Name = "Password",
.Size = New Size(Me.FormPanel.Width - Globals.Unit(2), Globals.Unit(1)),
.PasswordChar = "*"
}
Me.FormPanel.Controls.Add(PasswordInput)
Dim ConfirmPasswordInput As New BaseTextInput With {
.Name = "Confirm Password",
.Size = New Size(Me.FormPanel.Width - Globals.Unit(2), Globals.Unit(1)),
.PasswordChar = "*"
}
Me.FormPanel.Controls.Add(ConfirmPasswordInput)
Dim ContinueButton As New BaseButton With {
.Text = "Continue",
.Name = "Continue",
.Size = New Size(Me.FormPanel.Width - Globals.Unit(2), Globals.Unit(1))
}
Me.FormPanel.Controls.Add(ContinueButton)
AddHandler ContinueButton.Click, Sub()
If FirstNameInput.Text = "" And FirstNameInput.Text.Length < 3 Then
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = "First Name must be at least 3 characters."
}
Modal.ShowDialog()
FirstNameInput.Alert()
Exit Sub
End If
If LastNameInput.Text = "" And LastNameInput.Text.Length < 2 Then
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = "Last Name must be at least 2 characters."
}
Modal.ShowDialog()
LastNameInput.Alert()
Exit Sub
End If
If EmailInput.Text = "" And Not New Regex("^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$").IsMatch(EmailInput.Text) Then
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = "Invalid email address."
}
Modal.ShowDialog()
EmailInput.Alert()
Exit Sub
End If
If PasswordInput.Text = "" And PasswordInput.Text.Length < 8 Then
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = "Password must be at least 8 characters."
}
Modal.ShowDialog()
PasswordInput.Alert()
Exit Sub
End If
If PasswordInput.Text <> ConfirmPasswordInput.Text Then
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = "Passwords do not match."
}
Modal.ShowDialog()
ConfirmPasswordInput.Alert()
Exit Sub
End If
Dim data As New Dictionary(Of String, String) From {
{"firstName", FirstNameInput.Text},
{"lastName", LastNameInput.Text},
{"email", EmailInput.Text},
{"password", PasswordInput.Text},
{"role", "bsit"}
}
Try
Dim response As String = Globals.API("POST", "setup/admin", Globals.DictionaryToJSON(data))
Me.GoToForm(New BSIT_SetupData)
Catch ex As WebException
Dim rep As HttpWebResponse = ex.Response
Using rdr As New StreamReader(rep.GetResponseStream())
Dim Modal As New BaseModal With {
.Title = "Error",
.Message = rep.StatusCode & ": " & rdr.ReadToEnd()
}
Modal.ShowDialog()
End Using
End Try
End Sub
Loaded = True
Me.Size = Globals.FormSize
End Sub
Protected Sub BSIT_ProgramHeadSetup_Resize(sender As Object, e As EventArgs) Handles Me.Resize
If Me.Loaded Then
Dim i As Integer = 0
For Each Control As Control In Me.FormPanel.Controls
If Control.Name = "Logo" Then
Dim Logo As PictureBox = Control
Dim resourcesManager As ResourceManager = My.Resources.ResourceManager
Dim LogoImage As Image = resourcesManager.GetObject("CdMSMS-ICS Logo")
Logo.Image = LogoImage
Logo.Size = New Size(Me.FormPanel.Width, CInt(LogoImage.Height * (Me.FormPanel.Width / LogoImage.Width)))
End If
Control.Margin = New Padding(
(Me.FormPanel.Width - Control.Width) * 0.5,
0,
0,
0
)
If i > 1 Then
Control.Margin = New Padding(
Control.Margin.Left,
Globals.Unit(1),
0,
0
)
End If
i = i + 1
Next
Me.FormPanel.Location = New Point(
CInt((Me.Width * 0.75 - Me.FormPanel.Width * 0.5) - Globals.Unit(2)),
CInt(Me.Height * 0.5 - Me.FormPanel.Height * 0.5)
)
Dim Background As New Bitmap(Me.Contents.Width, Me.Contents.Height)
Dim SetupGraphics = Globals.LoadSvgFromResource("BSIT Setup Graphics").Draw()
Dim HalfTrapezoid = Globals.LoadSvgFromResource("Half Trapezoid").Draw()
Dim BarCompliment_Top = Globals.LoadSvgFromResource("Bar Complement").Draw()
Dim Bar_Top = Globals.LoadSvgFromResource("Bar").Draw()
Dim BarCompliment_Bottom = Globals.LoadSvgFromResource("Bar Complement Bottom").Draw()
Dim Bar_Bottom = Globals.LoadSvgFromResource("Bar Bottom").Draw()
Using g As Graphics = Graphics.FromImage(Background)
'HalfTrapezoid
g.DrawImage(
HalfTrapezoid,
0,
0,
CInt(HalfTrapezoid.Width * (Me.Contents.Height / HalfTrapezoid.Height)),
Me.Contents.Height
)
g.DrawImage(
BarCompliment_Top,
0,
-CInt(Globals.Unit(12)),
CInt(Globals.Unit(13)),
CInt(Globals.Unit(15))
)
g.DrawImage(
Bar_Top,
CInt(Me.Width * 0.5),
-CInt(Globals.Unit(12)),
CInt(Globals.Unit(13)),
CInt(Globals.Unit(15))
)
g.DrawImage(
BarCompliment_Bottom,
CInt(Me.Width * 0.25),
CInt(Me.Height * 0.75),
CInt(Globals.Unit(13)),
CInt(Globals.Unit(15))
)
g.DrawImage(
Bar_Bottom,
CInt(Me.Width * 0.75),
CInt(Me.Height * 0.75),
CInt(Globals.Unit(13)),
CInt(Globals.Unit(15))
)
'SetupGraphics
g.DrawImage(
SetupGraphics,
0,
CInt((Me.Contents.Height / 2) - ((Me.Width * 0.5) / 2)),
CInt(Me.Width * 0.5),
CInt(Globals.Unit(19) * (Me.Width * 0.5 / Globals.Unit(19)))
)
End Using
Me.BackgroundBitmap = Background
End If
End Sub
End Class