-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserControlHelper.cs
More file actions
40 lines (37 loc) · 1.37 KB
/
Copy pathUserControlHelper.cs
File metadata and controls
40 lines (37 loc) · 1.37 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
using STI_Join.MenuOptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace STI_Join
{
public static class UserControlHelper
{
public static void HandleButtonClick(Button clickedButton, Button activeButton, Action<Button> setActiveButton, Action<Button> setInactiveButton, Action<UserControl> loadUserControl, string ButtonIdentifier)
{
if (activeButton != null && activeButton != clickedButton)
{
setInactiveButton(activeButton);
}
setActiveButton(clickedButton);
loadUserControl(GetUserControlForButton(clickedButton, ButtonIdentifier));
}
public static UserControl GetUserControlForButton(Button button, string ButtonIdentifier)
{
switch (ButtonIdentifier)
{
case var _ when button.Name == "btnHome":
return new Home();
case var _ when button.Name == "btnAddStudent":
return new AddStudent();
case var _ when button.Name == "btnStudentList":
return new StudentList();
case var _ when button.Name == "btnAbout":
return new About();
default:
return null;
}
}
}
}