-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainformLayout.cs
More file actions
129 lines (115 loc) · 3.87 KB
/
mainformLayout.cs
File metadata and controls
129 lines (115 loc) · 3.87 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
/*
디렉토리 구조
InstituteManager/
├── MainForm.cs
├── UserControls/
│ ├── DashboardControl.cs
│ ├── AttendanceControl.cs
│ ├── TimetableControl.cs
│ ├── StudentListControl.cs
│ ├── AdminControl.cs
│ ├── NoticeControl.cs
│ └── CalendarControl.cs
*/
/*
mainform
- 사이드바
- UserControls 부모클래스
- 나머지 폼, 자식 클래스(기능 폼)
*/
using System;
using System.Windows.Forms;
namespace InstituteManager
{
public partial class MainForm : Form
{
private Panel sidebar;
private Panel mainPanel;
public MainForm()
{
InitializeComponent();
InitializeUI();
}
private void InitializeUI()
{
this.Text = "학원 통합 관리 시스템";
this.Size = new System.Drawing.Size(1200, 800);
this.StartPosition = FormStartPosition.CenterScreen;
sidebar = new Panel
{
Dock = DockStyle.Left,
Width = 200,
BackColor = System.Drawing.Color.LightSlateGray
};
this.Controls.Add(sidebar);
mainPanel = new Panel
{
Dock = DockStyle.Fill,
BackColor = System.Drawing.Color.White
};
this.Controls.Add(mainPanel);
string[] menuItems = {
"대시보드", "출석 관리", "시간표 보기", "학생 명단 관리",
"관리자 기능", "공지사항", "캘린더 일정", "로그아웃"
};
for (int i = 0; i < menuItems.Length; i++)
{
Button btn = new Button
{
Text = menuItems[i],
Width = 180,
Height = 50,
Top = 20 + i * 60,
Left = 10,
BackColor = System.Drawing.Color.WhiteSmoke,
FlatStyle = FlatStyle.Flat
};
btn.Click += SidebarButton_Click;
sidebar.Controls.Add(btn);
}
LoadControl(new UserControls.DashboardControl());
}
private void SidebarButton_Click(object sender, EventArgs e)
{
if (sender is Button btn)
{
UserControl control = null;
switch (btn.Text)
{
case "대시보드":
control = new UserControls.DashboardControl();
break;
case "출석 관리":
control = new UserControls.AttendanceControl();
break;
case "시간표 보기":
control = new UserControls.TimetableControl();
break;
case "학생 명단 관리":
control = new UserControls.StudentListControl();
break;
case "관리자 기능":
control = new UserControls.AdminControl();
break;
case "공지사항":
control = new UserControls.NoticeControl();
break;
case "캘린더 일정":
control = new UserControls.CalendarControl();
break;
case "로그아웃":
Application.Exit();
return;
}
if (control != null)
LoadControl(control);
}
}
private void LoadControl(UserControl control)
{
mainPanel.Controls.Clear();
control.Dock = DockStyle.Fill;
mainPanel.Controls.Add(control);
}
}
}