This repository has been 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
/
Copy pathDashboard_Calendar.vb
1140 lines (1056 loc) · 58.6 KB
/
Dashboard_Calendar.vb
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Drawing.Drawing2D
Imports System.Globalization
Imports System.Resources
Imports System.Text.RegularExpressions
Imports System.Net
Imports Svg
Imports System.IO
Public Class Dashboard_Calendar
Inherits BaseForm
Private SidePanel As FlowLayoutPanel
Private MainPanel As Transparent.Panel
Private Calendar As Transparent.Panel
Private Class BaseComboBox
Inherits Transparent.Panel
Private WithEvents ComboBoxElement As Transparent.ComboBox
Private WithEvents PlaceHolderElement As Label
Property PlaceHolder As String
Get
Return PlaceHolderElement.Text
End Get
Set(value As String)
PlaceHolderElement.Text = value
End Set
End Property
Property Items As List(Of String)
Get
Dim toReturm As New List(Of String)
For Each item In ComboBoxElement.Items
toReturm.Add(item)
Next
Return toReturm
End Get
Set
ComboBoxElement.Items.Clear()
For Each item In Value
ComboBoxElement.Items.Add(item)
Next
End Set
End Property
Property SelectedIndex As Integer
Get
Return ComboBoxElement.SelectedIndex
End Get
Set(value As Integer)
ComboBoxElement.SelectedIndex = value
BaseComboBoxDropDownClosed(Me, Nothing)
End Set
End Property
Property SelectedItem As String
Get
Return ComboBoxElement.SelectedItem
End Get
Set(value As String)
ComboBoxElement.SelectedItem = value
End Set
End Property
Public Sub New()
Me.BackColor = Color.Yellow
Me.PlaceHolderElement = New Transparent.Label With {
.Size = Me.Size,
.Location = New Point(0, 0),
.ForeColor = Globals.Palette("Plain Light"),
.Font = Globals.GetFont("Raleway", Globals.Unit(0.5), FontStyle.Bold),
.BackColor = Globals.Palette("Primary"),
.TextAlign = ContentAlignment.MiddleCenter
}
Me.Controls.Add(Me.PlaceHolderElement)
Me.ComboBoxElement = New Transparent.ComboBox With {
.Size = Me.Size,
.Location = New Point(0, 0),
.DropDownWidth = Me.Width,
.DropDownStyle = ComboBoxStyle.DropDownList,
.Font = Globals.GetFont("Raleway", Globals.Unit(0.5), FontStyle.Bold),
.ForeColor = Globals.Palette("Plain Dark"),
.BackColor = Globals.Palette("Plain Light"),
.FlatStyle = FlatStyle.Flat
}
Me.Controls.Add(Me.ComboBoxElement)
AddHandler Me.PlaceHolderElement.Click, Sub()
Me.ComboBoxElement.DroppedDown = True
End Sub
End Sub
Protected Sub BaseComboBoxResize(sender As Object, e As EventArgs) Handles Me.Resize
Me.PlaceHolderElement.Size = Me.Size
Me.ComboBoxElement.Size = Me.Size
Me.ComboBoxElement.DropDownWidth = Me.Width
End Sub
Protected Sub BaseComboBoxDropDownClosed(sender As Object, e As EventArgs) Handles ComboBoxElement.DropDownClosed
Me.PlaceHolderElement.Text = Me.ComboBoxElement.SelectedItem
If Me.ComboBoxElement.Items.Count = 0 Then
Me.PlaceHolderElement.Text = Me.PlaceHolder
End If
RaiseEvent SelectedIndexChanged(Me, e)
End Sub
Public Event SelectedIndexChanged(sender As Object, e As EventArgs)
End Class
Shared TimestampLabelHeight As Integer = 0
Private Class SchedulePanel
Inherits Transparent.Panel
Public Header As Label
Public Description As Label
Public Identifier As Label
Property Color As Color
Get
Return Me.BackColor
End Get
Set(value As Color)
Me.BorderTop.BackColor = value
Me.BorderBottom.BackColor = value
Me.BorderLeft.BackColor = value
Me.BorderRight.BackColor = value
Me.Header.BackColor = value
End Set
End Property
Private BorderTop As Panel
Private BorderBottom As Panel
Private BorderLeft As Panel
Private BorderRight As Panel
Property HeaderText As String
Get
Return Me.Header.Text
End Get
Set(value As String)
Me.Header.Text = value
End Set
End Property
Property DescriptionText As String
Get
Return Me.Description.Text
End Get
Set(value As String)
Me.Description.Text = value
End Set
End Property
Property IdentifierText As String
Get
Return Me.Identifier.Text
End Get
Set(value As String)
Me.Identifier.Text = value
End Set
End Property
Property ID As String
Property YearLevel As String
Property Section As String
Property FacultyID As String
Property Facility As String
Property Day As String
Property StartTime As String
Property EndTime As String
Public Sub New(
HeaderText As String,
DescriptionText As String,
IdentifierText As String,
ID As String,
YearLevel As String,
Section As String,
FacultyID As String,
Facility As String,
Day As String,
StartTime As String,
EndTime As String
)
Me.BackColor = Globals.Palette("Plain Light")
Me.BorderTop = New Panel With {
.Size = New Size(Me.Width, Globals.Unit(0.1)),
.Location = New Point(0, 0),
.BackColor = Me.Color
}
Me.Controls.Add(Me.BorderTop)
Me.BorderBottom = New Panel With {
.Size = New Size(Me.Width, Globals.Unit(0.1)),
.Location = New Point(0, Me.Height - Globals.Unit(0.1)),
.BackColor = Me.Color
}
Me.Controls.Add(Me.BorderBottom)
Me.BorderLeft = New Panel With {
.Size = New Size(Globals.Unit(0.1), Me.Height),
.Location = New Point(0, 0),
.BackColor = Me.Color
}
Me.Controls.Add(Me.BorderLeft)
Me.BorderRight = New Panel With {
.Size = New Size(Globals.Unit(0.1), Me.Height),
.Location = New Point(Me.Width - Globals.Unit(0.1), 0),
.BackColor = Me.Color
}
Me.Controls.Add(Me.BorderRight)
Me.Header = New Label With {
.Text = HeaderText,
.Size = New Size(Me.Width, TimestampLabelHeight),
.Location = New Point(0, 0),
.Font = Globals.GetFont("Raleway", Globals.Unit(0.25) + (Globals.Unit(0.25) / 2), FontStyle.Bold),
.TextAlign = ContentAlignment.MiddleCenter,
.ForeColor = Globals.Palette("Plain Light")
}
Me.Controls.Add(Me.Header)
Me.Description = New Label With {
.Text = DescriptionText,
.Size = New Size(Me.Width, TimestampLabelHeight),
.Location = New Point(0, TimestampLabelHeight),
.Font = Globals.GetFont("Open Sans", Globals.Unit(0.25) + (Globals.Unit(0.25) / 2), FontStyle.Regular),
.TextAlign = ContentAlignment.MiddleCenter,
.ForeColor = Globals.Palette("Plain Dark")
}
Me.Controls.Add(Me.Description)
Me.Identifier = New Label With {
.Text = IdentifierText,
.Size = New Size(Me.Width, TimestampLabelHeight),
.Location = New Point(0, TimestampLabelHeight * 2),
.Font = Globals.GetFont("Open Sans", Globals.Unit(0.25) + (Globals.Unit(0.25) / 2), FontStyle.Regular),
.TextAlign = ContentAlignment.MiddleCenter,
.ForeColor = Globals.Palette("Plain Dark")
}
Me.Controls.Add(Me.Identifier)
AddHandler Me.Header.Click, AddressOf SchedulePanelClick
AddHandler Me.Description.Click, AddressOf SchedulePanelClick
AddHandler Me.Identifier.Click, AddressOf SchedulePanelClick
AddHandler Me.BorderTop.Click, AddressOf SchedulePanelClick
AddHandler Me.BorderBottom.Click, AddressOf SchedulePanelClick
AddHandler Me.BorderLeft.Click, AddressOf SchedulePanelClick
AddHandler Me.BorderRight.Click, AddressOf SchedulePanelClick
Me.ID = ID
Me.YearLevel = YearLevel
Me.Section = Section
Me.FacultyID = FacultyID
Me.Facility = Facility
Me.Day = Day
Me.StartTime = StartTime
Me.EndTime = EndTime
End Sub
Protected Sub SchedulePanelResize(sender As Object, e As EventArgs) Handles Me.Resize
Me.BorderTop.Size = New Size(Me.Width, Globals.Unit(0.1))
Me.BorderBottom.Size = New Size(Me.Width, Globals.Unit(0.5))
Me.BorderLeft.Size = New Size(Globals.Unit(0.1), Me.Height)
Me.BorderRight.Size = New Size(Globals.Unit(0.1), Me.Height)
Me.BorderBottom.Location = New Point(0, Me.Height - Globals.Unit(0.1))
Me.BorderRight.Location = New Point(Me.Width - Globals.Unit(0.1), 0)
Me.Header.Size = New Size(Me.Width, TimestampLabelHeight)
Me.Description.Size = New Size(Me.Width, TimestampLabelHeight)
Me.Identifier.Size = New Size(Me.Width, TimestampLabelHeight)
Me.Description.Location = New Point(0, TimestampLabelHeight)
Me.Identifier.Location = New Point(0, TimestampLabelHeight * 2)
End Sub
Protected Sub SchedulePanelClick(sender As Object, e As EventArgs) Handles Me.Click
Dim Parent As Panel = Me.Parent
Dim PreviousPopupPanel As Panel = Parent.Controls.Find("PopUpPanel", True).FirstOrDefault()
Dim SchedulesBehind As New List(Of SchedulePanel)
If PreviousPopupPanel IsNot Nothing Then
Parent.Controls.Remove(PreviousPopupPanel)
End If
Dim PopUpPanel As New Panel With {
.Size = New Size(
Me.Width * 2,
(
(Globals.Unit(1.5) + Globals.Unit(0.25)) * 6
) + (
(Globals.Unit(1) + Globals.Unit(0.25)) * 3
)
),
.BackColor = Me.Color,
.Name = "PopUpPanel",
.TabIndex = TabIndex + 1
}
Dim PopUpX As Integer = Me.Right
Dim PopUpY As Integer = Me.Top
If PopUpPanel.Width > Parent.Width - Me.Right Then
PopUpX = Me.Left - PopUpPanel.Width
End If
If PopUpPanel.Height + Me.Top > Parent.Height - Globals.Unit(1) Then
PopUpY = Parent.Height - PopUpPanel.Height - Globals.Unit(1)
End If
PopUpPanel.Location = New Point(PopUpX, PopUpY)
AddHandler Me.Resize, Sub()
PopUpPanel.Size = New Size(
Me.Width * 2,
(
(Globals.Unit(1.5) + Globals.Unit(0.25)) * 6
) + (
(Globals.Unit(1) + Globals.Unit(0.25)) * 3
) + Globals.Unit(0.25)
)
PopUpX = Me.Right
PopUpY = Me.Top
If PopUpPanel.Width > Parent.Width - Me.Right Then
PopUpY = Parent.Height - PopUpPanel.Height
End If
If PopUpPanel.Height + Me.Top > Parent.Height - Globals.Unit(1) Then
PopUpY = Parent.Height - PopUpPanel.Height - Globals.Unit(1)
End If
PopUpPanel.Location = New Point(PopUpX, PopUpY)
End Sub
Parent.Controls.Add(PopUpPanel)
Me.Parent.Controls.SetChildIndex(PopUpPanel, 0)
Dim FacultyDropDown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), Globals.Unit(0.25)),
.Name = "Faculty",
.PlaceHodlder = "Select Faculty"
}
AddHandler Me.Resize, Sub()
FacultyDropDown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
Invoke(Sub()
FacultyDropDown.Items.Clear()
FacultyDropDown.PlaceHodlder = "Select Faculty"
Try
Dim tempItems = New List(Of String)
FacultyDropDown.Items.Clear()
Dim response As String = Globals.API("GET", "admin/dashboard/program/" & Globals.PROGRAM & "/faculties", Nothing)
Dim data = Globals.JSONToDictionary(response)
For i As Integer = 0 To data.Keys.Count - 1
tempItems.Add(data.Keys(i) & " - " & data.Values(i))
Next
FacultyDropDown.Items = tempItems
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)
PopUpPanel.Controls.Add(FacultyDropDown)
Dim SectionDropDown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), FacultyDropDown.Bottom + Globals.Unit(0.25)),
.Name = "Section",
.PlaceHodlder = "Select Section"
}
AddHandler Me.Resize, Sub()
SectionDropDown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
Invoke(Sub()
SectionDropDown.Items.Clear()
SectionDropDown.PlaceHodlder = "Select Section"
Try
Dim tempItems = New List(Of String)
Dim response As String = Globals.API("GET", "admin/dashboard/program/" & Globals.PROGRAM & "/sections/" & Me.YearLevel, Nothing)
Dim data = Globals.JSONToDictionary(response)
For Each value In data.Values
tempItems.Add(value)
Next
SectionDropDown.Items = tempItems
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)
PopUpPanel.Controls.Add(SectionDropDown)
Dim FacilityDropDown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), SectionDropDown.Bottom + Globals.Unit(0.25)),
.Name = "Facility",
.PlaceHodlder = "Select Facility"
}
AddHandler Me.Resize, Sub()
FacilityDropDown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
Invoke(Sub()
FacilityDropDown.Items.Clear()
FacilityDropDown.PlaceHodlder = "Select Facility"
Try
Dim tempItems = New List(Of String)
FacilityDropDown.Items.Clear()
Dim response As String = Globals.API("GET", "admin/dashboard/program/" & Globals.PROGRAM & "/facilities", Nothing)
Dim data = Globals.JSONToDictionary(response)
For i As Integer = 0 To data.Keys.Count - 1
tempItems.Add(data.Keys(i) & " - " & data.Values(i))
Next
FacilityDropDown.Items = tempItems
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)
PopUpPanel.Controls.Add(FacilityDropDown)
Dim DayDropdown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), FacilityDropDown.Bottom + Globals.Unit(0.25)),
.Name = "Day",
.PlaceHodlder = "Select Day"
}
DayDropdown.Items = New List(Of String) From {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
}
AddHandler Me.Resize, Sub()
DayDropdown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
PopUpPanel.Controls.Add(DayDropdown)
Dim StartTimeDropDown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), DayDropdown.Bottom + Globals.Unit(0.25)),
.Name = "StartTime",
.PlaceHodlder = "Select Start Time"
}
StartTimeDropDown.Items = New List(Of String) From {
"07:00 AM",
"07:30 AM",
"08:00 AM",
"08:30 AM",
"09:00 AM",
"09:30 AM",
"10:00 AM",
"10:30 AM",
"11:00 AM",
"11:30 AM",
"12:00 PM",
"12:30 PM",
"01:00 PM",
"01:30 PM",
"02:00 PM",
"02:30 PM",
"03:00 PM",
"03:30 PM",
"04:00 PM",
"04:30 PM",
"05:00 PM",
"05:30 PM",
"06:00 PM",
"06:30 PM",
"07:00 PM"
}
AddHandler Me.Resize, Sub()
StartTimeDropDown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
PopUpPanel.Controls.Add(StartTimeDropDown)
Dim EndTimeDropDown As New BaseDropDown With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5)),
.Location = New Point(Globals.Unit(0.25), StartTimeDropDown.Bottom + Globals.Unit(0.25)),
.Name = "EndTime",
.PlaceHodlder = "Select End Time"
}
AddHandler Me.Resize, Sub()
EndTimeDropDown.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1.5))
End Sub
AddHandler StartTimeDropDown.SelectedIndexChanged, Sub()
If StartTimeDropDown.SelectedIndex = -1 Then
Exit Sub
End If
EndTimeDropDown.Items.Clear()
EndTimeDropDown.PlaceHodlder = "Select End Time"
Dim TimeItems = New List(Of String)
Dim StartTimeIndex As Integer = StartTimeDropDown.SelectedIndex
For i As Integer = StartTimeIndex + 1 To StartTimeDropDown.Items.Count - 1
TimeItems.Add(StartTimeDropDown.Items(i))
Next
EndTimeDropDown.Items = TimeItems
End Sub
PopUpPanel.Controls.Add(EndTimeDropDown)
Dim SubmitButton As New BaseButton With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1)),
.Location = New Point(Globals.Unit(0.25), EndTimeDropDown.Bottom + Globals.Unit(0.25)),
.Text = "Submit"
}
AddHandler Me.Resize, Sub()
SubmitButton.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1))
End Sub
PopUpPanel.Controls.Add(SubmitButton)
Dim DeleteButton As New BaseButton With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1)),
.Location = New Point(Globals.Unit(0.25), SubmitButton.Bottom + Globals.Unit(0.25)),
.Text = "Delete",
.SubButton = True
}
AddHandler Me.Resize, Sub()
DeleteButton.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1))
End Sub
PopUpPanel.Controls.Add(DeleteButton)
Dim CancelButton As New BaseButton With {
.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1)),
.Location = New Point(Globals.Unit(0.25), DeleteButton.Bottom + Globals.Unit(0.25)),
.Text = "Cancel",
.SubButton = True
}
AddHandler Me.Resize, Sub()
CancelButton.Size = New Size((Me.Width * 2) - Globals.Unit(0.5), Globals.Unit(1))
CancelButton.PerformClick()
End Sub
AddHandler CancelButton.Click, Sub()
Parent.Controls.Remove(PopUpPanel)
End Sub
PopUpPanel.Controls.Add(CancelButton)
FacultyDropDown.SelectedItem = FacultyDropDown.Items.Find(Function(x) x.Contains(Me.FacultyID))
SectionDropDown.SelectedItem = SectionDropDown.Items.Find(Function(x) x.Contains(Me.Section))
FacilityDropDown.SelectedItem = FacilityDropDown.Items.Find(Function(x) x.Contains(Me.Facility))
DayDropdown.SelectedItem = DayDropdown.Items.Find(Function(x) x.Contains(Me.Day))
'Convert Military time to 12 hour time format
' 08:00:00 to 08:00 AM
Dim StartTime As String = Me.StartTime
Dim StartTimeHour As Integer = CInt(StartTime.Split(":")(0))
Dim StartTimeMinute As Integer = CInt(StartTime.Split(":")(1))
Dim StartTimePeriod As String = "AM"
If StartTimeHour > 12 Then
StartTimeHour -= 12
StartTimePeriod = "PM"
End If
StartTime = $"{StartTimeHour.ToString("00")}:{StartTimeMinute.ToString("00")} {StartTimePeriod}"
StartTimeDropDown.SelectedItem = StartTimeDropDown.Items.Find(Function(x) x.Contains(StartTime))
Dim EndTime As String = Me.EndTime
Dim EndTimeHour As Integer = CInt(EndTime.Split(":")(0))
Dim EndTimeMinute As Integer = CInt(EndTime.Split(":")(1))
Dim EndTimePeriod As String = "AM"
If EndTimeHour > 12 Then
EndTimeHour -= 12
EndTimePeriod = "PM"
End If
EndTime = EndTimeHour.ToString("00") & ":" & EndTimeMinute.ToString("00") & " " & EndTimePeriod
EndTimeDropDown.SelectedItem = EndTimeDropDown.Items.Find(Function(x) x.Contains(EndTime))
For Each Control As Control In Parent.Controls
Control.Refresh()
Next
AddHandler SubmitButton.Click, Sub()
Try
Dim FacultyID As String = FacultyDropDown.SelectedItem.Split(" - ")(0)
Dim Section As String = SectionDropDown.SelectedItem
Dim Facility As String = FacilityDropDown.SelectedItem.Split(" - ")(0)
Dim Day As String = DayDropdown.SelectedItem
Dim StartTimeData As String = StartTimeDropDown.SelectedItem
Dim EndTimeData As String = EndTimeDropDown.SelectedItem
If EndTimeDropDown.SelectedIndex = -1 Then
Dim EndTimeModal As New BaseModal With {
.Title = "Error",
.Message = "Please select an end time."
}
EndTimeModal.ShowDialog()
Exit Sub
End If
Dim data As New Dictionary(Of String, String) From {
{"facultyID", FacultyID},
{"facilityID", Facility},
{"section", Section},
{"day", Day},
{"startTime", StartTimeData},
{"endTime", EndTimeData}
}
Dim response As String = Globals.API("POST", "admin/dashboard/program/" & Globals.PROGRAM & "/update/schedule/" & Me.ID, Globals.DictionaryToJSON(data))
Dim Modal As New BaseModal With {
.Title = "Success",
.Message = response
}
Modal.ShowDialog()
Parent.Controls.Remove(PopUpPanel)
Parent.Controls.Find("Schedule", True).ToList().ForEach(Sub(x) Parent.Controls.Remove(x))
Dim ScheduleSelection As BaseComboBox = Parent.Controls.Find("ScheduleSelection", True).FirstOrDefault()
Dim ScheduleSelectionIndex As Integer = ScheduleSelection.SelectedIndex
ScheduleSelection.SelectedIndex = ScheduleSelectionIndex - 1
ScheduleSelection.SelectedIndex = ScheduleSelectionIndex
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
AddHandler DeleteButton.Click, Sub()
Try
Dim data As New Dictionary(Of String, String) From {
{"facultyID", Me.FacultyID},
{"facilityID", Me.Facility},
{"section", Me.Section},
{"day", Me.Day},
{"startTime", Me.StartTime},
{"endTime", Me.EndTime}
}
Dim response As String = Globals.API("POST", "admin/dashboard/program/" & Globals.PROGRAM & "/delete/schedule/" & Me.ID, Globals.DictionaryToJSON(data))
Dim Modal As New BaseModal With {
.Title = "Success",
.Message = response
}
Modal.ShowDialog()
Parent.Controls.Remove(PopUpPanel)
Parent.Controls.Find("Schedule", True).ToList().ForEach(Sub(x) Parent.Controls.Remove(x))
Dim ScheduleSelection As BaseComboBox = Parent.Controls.Find("ScheduleSelection", True).FirstOrDefault()
Dim ScheduleSelectionIndex As Integer = ScheduleSelection.SelectedIndex
ScheduleSelection.SelectedIndex = ScheduleSelectionIndex - 1
ScheduleSelection.SelectedIndex = ScheduleSelectionIndex
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
End Sub
End Class
Private Schedules As New List(Of SchedulePanel)
Protected Sub Dashboard_Load(sender As Object, e As EventArgs) Handles MyBase.Load
BackendSocket.Connect("calendar_admin")
Me.Name = "Dashboard"
Me.SidePanel = New FlowLayoutPanel With {
.Size = New Size(Globals.Unit(2), Me.Contents.Height - (Me.HeaderBar.Height + Me.resizerBarTop.Height)),
.BackColor = Globals.Palette("Plain Light"),
.FlowDirection = FlowDirection.TopDown,
.WrapContents = False,
.AutoScroll = True,
.Padding = New Padding(0, 0, 0, 0),
.Location = New Point(
Me.resizerBarRight.Width,
Me.HeaderBar.Height + Me.resizerBarTop.Height
)
}
Me.Contents.Controls.Add(Me.SidePanel)
Dim CallendarIcon As New PictureBox With {
.Image = Globals.LoadSvgFromResource("Calendar Icon Active", New Size(Globals.Unit(2), Globals.Unit(2))).Draw(),
.Size = New Size(Globals.Unit(2), Globals.Unit(2)),
.SizeMode = PictureBoxSizeMode.Zoom,
.Cursor = Cursors.Hand,
.Margin = New Padding(0),
.Padding = New Padding(0)
}
Me.SidePanel.Controls.Add(CallendarIcon)
Dim CreateIcon As New PictureBox With {
.Image = Globals.LoadSvgFromResource("Create Icon", New Size(Globals.Unit(2), Globals.Unit(2))).Draw(),
.Size = New Size(Globals.Unit(2), Globals.Unit(2)),
.SizeMode = PictureBoxSizeMode.Zoom,
.Cursor = Cursors.Hand,
.Margin = New Padding(0),
.Padding = New Padding(0)
}
AddHandler CreateIcon.Click, Sub()
BackendSocket.Close()
Me.GoToForm(New Dashboard_Create)
End Sub
Me.SidePanel.Controls.Add(CreateIcon)
Dim NotificationIcon As New PictureBox With {
.Image = Globals.LoadSvgFromResource("Notification Icon", New Size(Globals.Unit(2), Globals.Unit(2))).Draw(),
.Size = New Size(Globals.Unit(2), Globals.Unit(2)),
.SizeMode = PictureBoxSizeMode.Zoom,
.Cursor = Cursors.Hand,
.Margin = New Padding(0),
.Padding = New Padding(0)
}
AddHandler NotificationIcon.Click, Sub()
BackendSocket.Close()
Me.GoToForm(New Dashboard_Notification)
End Sub
Me.SidePanel.Controls.Add(NotificationIcon)
Dim LogoutIcon As New PictureBox With {
.Image = Globals.LoadSvgFromResource("Logout Icon", New Size(Globals.Unit(2), Globals.Unit(2))).Draw(),
.Size = New Size(Globals.Unit(2), Globals.Unit(2)),
.SizeMode = PictureBoxSizeMode.Zoom,
.Cursor = Cursors.Hand,
.Padding = New Padding(0)
}
LogoutIcon.Margin = New Padding(
0,
(Me.SidePanel.Height - NotificationIcon.Bottom) - LogoutIcon.Height,
0,
0
)
AddHandler Me.SidePanel.Resize, Sub()
LogoutIcon.Margin = New Padding(
0,
(Me.SidePanel.Height - NotificationIcon.Bottom) - LogoutIcon.Height,
0,
0
)
End Sub
AddHandler LogoutIcon.Click, Sub()
Globals.TOKEN = ""
Globals.PROGRAM = ""
BackendSocket.Close()
Me.GoToForm(New Login)
End Sub
Me.SidePanel.Controls.Add(LogoutIcon)
Me.MainPanel = New Transparent.Panel With {
.Size = New Size(
Me.Contents.Width - Me.SidePanel.Width,
Me.Contents.Height - (Me.HeaderBar.Height + Me.resizerBarTop.Height + Me.resizerBarBottom.Height)
),
.AutoScroll = True,
.Location = New Point(
Me.SidePanel.Width + Me.resizerBarRight.Width,
Me.HeaderBar.Height + Me.resizerBarTop.Height
)
}
Me.Contents.Controls.Add(Me.MainPanel)
Me.Calendar = New Transparent.Panel With {
.Size = New Size(
Me.MainPanel.Width - Globals.Unit(2),
Me.MainPanel.Height - Globals.Unit(2)
),
.Location = New Point(Globals.Unit(1), Globals.Unit(1))
}
Me.MainPanel.Controls.Add(Me.Calendar)
Dim ScheduleSelection As New BaseComboBox With {
.Size = New Size(Me.Calendar.Width, Globals.Unit(1)),
.Location = New Point(0, 0),
.PlaceHolder = "Select Calendar",
.Name = "ScheduleSelection"
}
AddHandler Me.Calendar.Resize, Sub()
ScheduleSelection.Size = New Size(Me.Calendar.Width, Globals.Unit(1))
End Sub
Me.Calendar.Controls.Add(ScheduleSelection)
AddHandler BackendSocket.OnMessage, Sub(data As String)
ScheduleSelection.SelectedIndex = ScheduleSelection.SelectedIndex - 1
ScheduleSelection.SelectedIndex = ScheduleSelection.SelectedIndex + 1
End Sub
Dim PopupPanel As Panel = Me.Calendar.Controls.Find("PopUpPanel", True).FirstOrDefault()
If PopupPanel IsNot Nothing Then
Me.Calendar.Controls.Remove(PopupPanel)
End If
Dim HeaderPanel As New Transparent.FlowLayoutPanel With {
.Size = New Size(
Me.MainPanel.Width - Globals.Unit(2),
Me.MainPanel.Height - Globals.Unit(2)
),
.Location = New Point(0, Globals.Unit(1)),
.FlowDirection = FlowDirection.LeftToRight,
.WrapContents = False,
.BackColor = Globals.Palette("Secondary"),
.Padding = New Padding(0, 0, 0, 0),
.Margin = New Padding(0, 0, 0, 0),
.Name = "HeaderPanel"
}
AddHandler Me.Calendar.Resize, Sub()
HeaderPanel.Size = New Size(
Me.Calendar.Width,
Globals.Unit(1)
)
End Sub
Me.Calendar.Controls.Add(HeaderPanel)
Dim Days As New List(Of String) From {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
}
For Each Day In Days
Dim DayLabel As New Transparent.Label With {
.Text = Day,
.Name = Day,
.Size = New Size(
(Me.Calendar.Width / Days.Count) - (Globals.Unit(0.5) * (Days.Count - 1)),
Globals.Unit(1)
),
.AutoSize = False,
.Font = Globals.GetFont("Raleway", Globals.Unit(0.5), FontStyle.Bold),
.TextAlign = ContentAlignment.MiddleCenter,
.Margin = New Padding(0),
.Padding = New Padding(0),
.BackColor = Globals.Palette("Secondary"),
.ForeColor = Globals.Palette("Plain Light")
}
AddHandler Me.Calendar.Resize, Sub()
HeaderPanel.Padding = New Padding(CInt(Me.Calendar.Width / 6.4), 0, 0, 0)
DayLabel.Size = New Size(
(Me.Calendar.Width - (Me.Calendar.Width / 6.4)) / Days.Count,
Globals.Unit(1)
)
End Sub
HeaderPanel.Controls.Add(DayLabel)
Next
Dim TimestampPanel As New Transparent.FlowLayoutPanel With {
.Size = New Size(
Me.Calendar.Width / 6.4,
Me.Calendar.Height - Globals.Unit(3)
),
.Location = New Point(0, Globals.Unit(2)),
.FlowDirection = FlowDirection.TopDown,
.WrapContents = False,
.Padding = New Padding(0, Globals.Unit(0.5), 0, Globals.Unit(0.5)),
.Margin = New Padding(0, 0, 0, 0),
.Name = "TimestampPanel"
}
Me.Calendar.Controls.Add(TimestampPanel)
Dim Times As New List(Of String) From {
"07:00 - 07:30 AM",
"07:30 - 08:00 AM",
"08:00 - 08:30 AM",
"08:30 - 09:00 AM",
"09:00 - 09:30 AM",
"09:30 - 10:00 AM",
"10:00 - 10:30 AM",
"10:30 - 11:00 AM",
"11:00 - 11:30 AM",
"11:30 - 12:00 NN",
"12:00 - 12:30 PM",
"12:30 - 01:00 PM",
"01:00 - 01:30 PM",
"01:30 - 02:00 PM",
"02:00 - 02:30 PM",
"02:30 - 03:00 PM",
"03:00 - 03:30 PM",
"03:30 - 04:00 PM",
"04:00 - 04:30 PM",
"04:30 - 05:00 PM",
"05:00 - 05:30 PM",
"05:30 - 06:00 PM",
"06:00 - 06:30 PM",
"06:30 - 07:00 PM"
}
For Each Time In Times
Dim TimeLabel As New Transparent.Label With {
.Text = Time,
.Name = Time,
.Size = New Size(
TimestampPanel.Width,
((TimestampPanel.Height - Globals.Unit(1)) / Times.Count) - Globals.Unit(0.25) / 2
),
.AutoSize = False,
.Font = Globals.GetFont("Open Sans", Globals.Unit(0.5) - (Globals.Unit(0.25) / 2), FontStyle.Regular),
.TextAlign = ContentAlignment.MiddleCenter,
.Margin = New Padding(0, 0, 0, Globals.Unit(0.25) / 2),
.Padding = New Padding(0),
.ForeColor = Globals.Palette("Plain Dark")
}
AddHandler Me.Calendar.Resize, Sub()
TimestampPanel.Size = New Size(
Me.Calendar.Width / 6.4,
Me.Calendar.Height - Globals.Unit(3)
)
TimeLabel.Size = New Size(
TimestampPanel.Width,
((TimestampPanel.Height - Globals.Unit(1)) / Times.Count) - Globals.Unit(0.25) / 2
)
TimestampLabelHeight = TimeLabel.Height
End Sub
TimestampPanel.Controls.Add(TimeLabel)
Next
Dim FooterPanel As New Panel With {
.Size = New Size(Me.Calendar.Width, Globals.Unit(1)),
.Location = New Point(0, Me.Calendar.Height - Globals.Unit(1)),
.BackColor = Globals.Palette("Primary")
}
AddHandler Me.Calendar.Resize, Sub()
FooterPanel.Size = New Size(Me.Calendar.Width, Globals.Unit(1))
FooterPanel.Location = New Point(0, Me.Calendar.Height - Globals.Unit(1))
End Sub
Me.Calendar.Controls.Add(FooterPanel)
Dim Identifiers = New Dictionary(Of String, Dictionary(Of String, String))
Dim getCalendars = Sub()
Try
Dim response As String = Globals.API("GET", "admin/dashboard/program/" & Globals.PROGRAM & "/calendars/", Nothing)
Dim data = Globals.JSONToDictionary(response, True)
Dim Selections As New List(Of String)
For Each item In data.Values
Selections.Add(item("name"))
Identifiers.Add(item("name"), New Dictionary(Of String, String) From {
{"key", item("key")},
{"identifier", item("identifier")},
{"name", item("name")}
})
Next
ScheduleSelection.Items = Selections
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
getCalendars()
'AddHandler BackendSocket.OnMessage, Sub(message)
' MsgBox(message)
' If message = "refresh" Then
' Dim calendarPreviousIndex As Integer = ScheduleSelection.SelectedIndex
' ScheduleSelection.Items.Clear()
' getCalendars()
' ScheduleSelection.SelectedIndex = calendarPreviousIndex
' End If
' End Sub
Dim DisplaySchedules = Sub()
'Check if ScheduleSelection is empty
If ScheduleSelection.Items.Count = 0 Then
ScheduleSelection.PlaceHolder = "No Calendars Available"
Exit Sub
End If
If ScheduleSelection.SelectedIndex = -1 Then
ScheduleSelection.PlaceHolder = "No Calendars Selected"
Exit Sub
End If
Me.Calendar.Controls.Find("Schedule", True).ToList().ForEach(Sub(x) Me.Calendar.Controls.Remove(x))
Me.Calendar.Controls.Find("PopUpPanel", True).ToList().ForEach(Sub(x) Me.Calendar.Controls.Remove(x))
Dim Key As String = Identifiers(ScheduleSelection.SelectedItem)("key")
Dim Identifier As String = Identifiers(ScheduleSelection.SelectedItem)("identifier")
Dim PossibleTimes As New List(Of String) From {
"07:00:00",
"07:30:00",
"08:00:00",
"08:30:00",
"09:00:00",
"09:30:00",
"10:00:00",
"10:30:00",
"11:00:00",
"11:30:00",
"12:00:00",
"12:30:00",
"13:00:00",