-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainForm.cs
More file actions
189 lines (164 loc) · 6.24 KB
/
Copy pathmainForm.cs
File metadata and controls
189 lines (164 loc) · 6.24 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolTip;
namespace MiniManager
{
public partial class mainForm : Form
{
int default_item_height = 40; // item height
int default_item_loc_x = 1; // keep 1
int default_item_loc_y = 160; // item location startpoint
int default_item_spacer = 40; // spacer between item to item
public Color idleText = Color.LightGray;
public Color idleColor = Color.FromArgb(255, 35, 35, 40);
public Color hoverColor = Color.FromArgb(255, 32, 32, 35);
public Color selectColor = Color.FromArgb(255, 31, 31, 34);
public Font idleFont = new Font("Bahnschrift Light", 11, FontStyle.Regular);
public string[] tabContents = {
"Client mods",
"Server mods",
"App settings",
"Close"
};
public mainForm()
{
InitializeComponent();
}
private void mainForm_Load(object sender, EventArgs e)
{
clientModsPanel.Visible = false;
serverModsPanel.Visible = false;
appSettingsPanel.Visible = false;
default_item_loc_y = tabPanel.Size.Height / 3;
listSystem(tabPanel, tabContents);
}
private void clearUI(Panel control)
{
// server box
for (int i = control.Controls.Count - 1; i >= 0; i--)
{
Label selected = control.Controls[i] as Label;
if (selected != null)
{
try
{
control.Controls.RemoveAt(i);
selected.Dispose();
}
catch (Exception err)
{
Debug.WriteLine($"ERROR: {err.ToString()}");
MessageBox.Show($"Oops! It seems like we received an error. If you're uncertain what it\'s about, please message the developer with a screenshot:\n\n{err.ToString()}", this.Text, MessageBoxButtons.OK);
}
}
}
}
public void listSystem(Control component, string[] arr)
{
clearUI(tabPanel);
for (int i = 0; i < arr.Length; i++)
{
Label lbl = new Label();
lbl.Text = arr[i];
lbl.AutoSize = false;
lbl.Anchor = (AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right);
lbl.TextAlign = ContentAlignment.MiddleLeft;
lbl.Size = new Size(component.Size.Width - 2, default_item_height);
lbl.Location = new Point(default_item_loc_x, default_item_loc_y + (i * default_item_spacer));
lbl.Font = idleFont;
lbl.BackColor = idleColor;
lbl.ForeColor = idleText;
lbl.Margin = new Padding(1, 1, 1, 1);
lbl.Cursor = Cursors.Hand;
lbl.MouseEnter += new EventHandler(lbl_MouseEnter);
lbl.MouseLeave += new EventHandler(lbl_MouseLeave);
lbl.MouseDown += new MouseEventHandler(lbl_MouseDown);
lbl.MouseUp += new MouseEventHandler(lbl_MouseUp);
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Visible = true;
component.Controls.Add(lbl);
}
}
private void lbl_MouseEnter(object sender, EventArgs e)
{
System.Windows.Forms.Label label = (System.Windows.Forms.Label)sender;
if (label.Text != "")
{
if (label.BackColor != selectColor)
{
label.BackColor = hoverColor;
}
}
}
private void lbl_MouseLeave(object sender, EventArgs e)
{
System.Windows.Forms.Label label = (System.Windows.Forms.Label)sender;
if (label.Text != "")
{
if (label.BackColor != selectColor)
{
label.BackColor = idleColor;
}
}
}
private void lbl_MouseUp(object sender, EventArgs e)
{
System.Windows.Forms.Label label = (System.Windows.Forms.Label)sender;
if (label.Text != "") { }
}
private void lbl_MouseDown(object sender, EventArgs e)
{
Control list = this.Controls["tabPanel"];
clientModsPanel.Visible = true;
serverModsPanel.Visible = true;
appSettingsPanel.Visible = true;
System.Windows.Forms.Label lbl = (System.Windows.Forms.Label)sender;
if (lbl.Text != "")
{
foreach (Control component in list.Controls)
{
if (component.Text.Contains("> "))
{
component.Text = component.Text.Remove(0, 2);
}
if (component is Label && component.Text != lbl.Text)
{
component.BackColor = idleColor;
component.ForeColor = idleText;
}
}
lbl.BackColor = selectColor;
if (lbl.Text.ToLower() == "client mods")
{
clientModsPanel.BringToFront();
}
else if (lbl.Text.ToLower() == "server mods")
{
serverModsPanel.BringToFront();
}
else if (lbl.Text.ToLower() == "app settings")
{
appSettingsPanel.BringToFront();
}
else if (lbl.Text.ToLower() == "close")
{
Application.Exit();
}
/*
string activeItem = lbl.Text;
activeItem = "> " + activeItem;
lbl.Text = activeItem;
lbl.ForeColor = Color.DodgerBlue;
*/
}
}
}
}