-
Notifications
You must be signed in to change notification settings - Fork 5
/
MainMenuScreen.cs
135 lines (118 loc) · 4.33 KB
/
MainMenuScreen.cs
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
using System;
using System.Drawing;
using System.Windows.Forms;
using FontAwesome.Sharp;
namespace airline_reservation_system
{
public partial class MainMenuScreen : Form
{
private IconButton currentBtn;
private Panel leftBorderBtn;
private Form currentChildForm;
public MainMenuScreen()
{
InitializeComponent();
leftBorderBtn = new Panel();
leftBorderBtn.Size = new Size(7, 70);
MenuPanel.Controls.Add(leftBorderBtn);
}
private struct RGBColors
{
public static Color color1 = Color.FromArgb(113, 201, 245);
public static Color color2 = Color.FromArgb(255, 230, 0);
public static Color color3 = Color.FromArgb(214, 15, 38);
public static Color color4 = Color.FromArgb(242, 158, 56);
public static Color color5 = Color.FromArgb(255, 0, 0);
}
private void ActivateBtn (object senderBtn, Color color)
{
if (senderBtn != null)
{
DisableButton();
//button design
currentBtn = (IconButton)senderBtn;
currentBtn.BackColor = Color.FromArgb(85, 124, 230);
currentBtn.ForeColor = color;
currentBtn.TextAlign = ContentAlignment.MiddleCenter;
currentBtn.IconColor = color;
currentBtn.TextImageRelation = TextImageRelation.TextBeforeImage;
currentBtn.ImageAlign = ContentAlignment.MiddleRight;
//left border design
leftBorderBtn.BackColor = color;
leftBorderBtn.Location = new Point(0, currentBtn.Location.Y);
leftBorderBtn.Visible = true;
leftBorderBtn.BringToFront();
//child form title bar
iconCurrentChildForm.IconChar = currentBtn.IconChar;
iconCurrentChildForm.IconColor = color;
}
}
private void DisableButton()
{
if (currentBtn != null)
{
currentBtn.BackColor = Color.FromArgb(33, 30, 68);
currentBtn.ForeColor = Color.White;
currentBtn.TextAlign = ContentAlignment.MiddleLeft;
currentBtn.IconColor = Color.White;
currentBtn.TextImageRelation = TextImageRelation.ImageBeforeText;
currentBtn.ImageAlign = ContentAlignment.MiddleLeft;
}
}
private void OpenChildForm(Form form)
{
if (currentChildForm != null)
{
currentChildForm.Close();
}
currentChildForm = form;
form.TopLevel = false;
form.FormBorderStyle = FormBorderStyle.None;
form.Dock = DockStyle.Fill;
panelChildForm.Controls.Add(form);
panelChildForm.Tag = form;
form.BringToFront();
form.Show();
lblTitle.Text = form.Text;
}
private void AddRes_Click(object sender, EventArgs e)
{
ActivateBtn(sender, RGBColors.color1);
OpenChildForm(new AddResScreen());
}
private void RescheduleRes_Click(object sender, EventArgs e)
{
ActivateBtn(sender, RGBColors.color2);
OpenChildForm(new RescheduleResScreen());
}
private void CancelRes_Click(object sender, EventArgs e)
{
ActivateBtn(sender, RGBColors.color3);
OpenChildForm(new CancelResScreen());
}
private void ViewRes_Click(object sender, EventArgs e)
{
ActivateBtn(sender, RGBColors.color4);
OpenChildForm(new ViewResScreen());
}
private void Logo_Click(object sender, EventArgs e)
{
Reset();
}
private void Reset()
{
DisableButton();
currentChildForm.Close();
leftBorderBtn.Visible = false;
iconCurrentChildForm.IconChar = IconChar.Home;
iconCurrentChildForm.IconColor = Color.White;
lblTitle.Text = "Home";
}
private void LogOut_Click(object sender, EventArgs e)
{
ActivateBtn(sender, RGBColors.color5);
new LoginScreen().Show();
this.Hide();
}
}
}