-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormMainMenu.cs
More file actions
202 lines (176 loc) · 6.37 KB
/
FormMainMenu.cs
File metadata and controls
202 lines (176 loc) · 6.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
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
using FontAwesome.Sharp;
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;
namespace WinSCPFileTransfer
{
public partial class FormMainMenu : Form
{
//Fields
private IconButton currentBtn;
private Panel leftBorderBtn;
private Form currentChildForm;
//Constructor
public FormMainMenu()
{
InitializeComponent();
leftBorderBtn = new Panel();
leftBorderBtn.Size = new Size(7, 60);
panelMenu.Controls.Add(leftBorderBtn);
//Form
this.Text = string.Empty;
this.ControlBox = false;
this.DoubleBuffered = true;
this.MaximizedBounds = Screen.FromHandle(this.Handle).WorkingArea;
}
//Structs
private struct RGBColors
{
public static Color color1 = Color.FromArgb(172, 126, 241);
public static Color color2 = Color.FromArgb(249, 118, 176);
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(24, 161, 251);
}
//Methods
private void ActivateButton(object senderBtn, Color color)
{
if (senderBtn != null)
{
DisableButton();
//Button
currentBtn = (IconButton)senderBtn;
currentBtn.BackColor = Color.FromArgb(37, 36, 81);
currentBtn.ForeColor = color;
currentBtn.TextAlign = ContentAlignment.MiddleCenter;
currentBtn.IconColor = color;
currentBtn.TextImageRelation = TextImageRelation.TextBeforeImage;
currentBtn.ImageAlign = ContentAlignment.MiddleRight;
//Left border button
leftBorderBtn.BackColor = color;
leftBorderBtn.Location = new Point(0, currentBtn.Location.Y);
leftBorderBtn.Visible = true;
leftBorderBtn.BringToFront();
//Current Child Form Icon
iconCurrentChildForm.IconChar = currentBtn.IconChar;
iconCurrentChildForm.IconColor = color;
}
}
private void DisableButton()
{
if (currentBtn != null)
{
currentBtn.BackColor = Color.FromArgb(31, 30, 68);
currentBtn.ForeColor = Color.Gainsboro;
currentBtn.TextAlign = ContentAlignment.MiddleLeft;
currentBtn.IconColor = Color.Gainsboro;
currentBtn.TextImageRelation = TextImageRelation.ImageBeforeText;
currentBtn.ImageAlign = ContentAlignment.MiddleLeft;
}
}
private void OpenChildForm(Form childForm)
{
//open only form
if (currentChildForm != null)
{
currentChildForm.Close();
}
currentChildForm = childForm;
//End
childForm.TopLevel = false;
childForm.FormBorderStyle = FormBorderStyle.None;
childForm.Dock = DockStyle.Fill;
panelDesktop.Controls.Add(childForm);
panelDesktop.Tag = childForm;
childForm.BringToFront();
childForm.Show();
lblTitleChildForm.Text = childForm.Text;
}
//Reset
private void Reset()
{
DisableButton();
leftBorderBtn.Visible = false;
iconCurrentChildForm.IconChar = IconChar.Home;
iconCurrentChildForm.IconColor = Color.MediumPurple;
lblTitleChildForm.Text = "Home";
}
//Events
private void btnHome_Click(object sender, EventArgs e)
{
if (currentChildForm != null)
{
currentChildForm.Close();
}
Reset();
}
//Drag Form
[DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();
[DllImport("user32.DLL", EntryPoint = "SendMessage")]
private extern static void SendMessage(System.IntPtr hWnd, int wMsg, int wParam, int lParam);
private void panelTitleBar_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
//Close-Maximize-Minimize
private void btnMaximize_Click(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Normal)
WindowState = FormWindowState.Maximized;
else
WindowState = FormWindowState.Normal;
}
private void btnMinimize_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
}
//Remove transparent border in maximized state
private void FormMainMenu_Resize(object sender, EventArgs e)
{
if (WindowState == FormWindowState.Maximized)
FormBorderStyle = FormBorderStyle.None;
else
FormBorderStyle = FormBorderStyle.Sizable;
}
//Menu Button_Clicks
private void btnDashboard_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color1);
OpenChildForm(new FormDashboard());
}
private void btnServer_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color1);
OpenChildForm(new FormServerMgmt());
}
private void btnDownload_Click(object sender, EventArgs e)
{
}
private void btnApply_Click(object sender, EventArgs e)
{
ActivateButton(sender, RGBColors.color1);
OpenChildForm(new FormPatchApply());
}
private void btnSchedule_Click(object sender, EventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}