-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.cs
More file actions
143 lines (124 loc) · 4.26 KB
/
Form1.cs
File metadata and controls
143 lines (124 loc) · 4.26 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using FontAwesome.Sharp;
namespace src
{
public partial class Form1 : Form
{
private IconButton currentBtn;
private Panel bottomBorder;
private Form currentPage;
public Form1()
{
InitializeComponent();
this.Height = Screen.PrimaryScreen.Bounds.Height;
this.Width = Screen.PrimaryScreen.Bounds.Width;
timer1.Enabled = true;
timer1.Interval = 1000;
bottomBorder = new Panel();
bottomBorder.Size = new Size(200, 3);
panelMenu.Controls.Add(bottomBorder);
OpenPage(new Form3());
}
private struct RGBColors
{
public static Color color1 = Color.FromArgb(172, 126, 241);
public static Color color2 = Color.FromArgb(236, 80, 115);
public static Color color3 = Color.FromArgb(253, 138, 114);
public static Color color4 = Color.FromArgb(95, 77, 221);
public static Color color5 = Color.FromArgb(249, 88, 155);
public static Color color6 = Color.FromArgb(49, 159, 232);
}
private void ActivateButton(object sender, Color color)
{
if (sender != null)
{
DisableButton();
currentBtn = (IconButton)sender;
currentBtn.BackColor = Color.FromArgb(47, 23, 69);
currentBtn.ForeColor = color;
currentBtn.IconColor = color;
bottomBorder.BackColor = color;
bottomBorder.Location = new Point(0, currentBtn.Location.Y + 60);
bottomBorder.Visible = true;
bottomBorder.BringToFront();
}
}
private void DisableButton()
{
if (currentBtn != null)
{
currentBtn.BackColor = Color.FromArgb(17, 1, 31);
currentBtn.ForeColor = Color.SeaShell;
currentBtn.TextAlign = ContentAlignment.MiddleLeft;
currentBtn.IconColor = Color.SeaShell;
currentBtn.TextImageRelation = TextImageRelation.ImageBeforeText;
currentBtn.ImageAlign = ContentAlignment.MiddleLeft;
}
}
private void OpenPage(Form page)
{
if (currentPage != null)
{
currentPage.Close();
}
currentPage = page;
currentPage.TopLevel = false;
currentPage.FormBorderStyle = FormBorderStyle.None;
currentPage.Dock = DockStyle.Fill;
panel5.Controls.Add(currentPage);
panel5.Tag = currentPage;
currentPage.BringToFront();
currentPage.Show();
}
private void HomeButton_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color1);
OpenPage(new Form3());
}
private void GraphButton_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color2);
OpenPage(new Form2());
}
private void ContactButton_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color3);
OpenPage(new Form4());
}
private void HMIF_Click(object sender, EventArgs e)
{
currentPage.Close();
Reset();
OpenPage(new Form3());
}
private void Reset()
{
DisableButton();
bottomBorder.Visible = false;
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
Date.Text = DateTime.Now.ToLongDateString();
Clock.Text = DateTime.Now.ToLongTimeString();
}
private void timer1_Tick(object sender, EventArgs e)
{
Clock.Text = DateTime.Now.ToLongTimeString();
timer1.Start();
}
private void exitButton_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}