-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubForm.cs
249 lines (234 loc) · 7.91 KB
/
SubForm.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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MouseMapper
{
class SubForm
{
#region variabili
//SIZE E LOCATION DI PANEL
private const int wP = 511;
private const int hP = 271;
private const int lPx = 109;
private const int lPy = 148;
//SIZE E LOCATION DI TEXTBOXES
private const int wTxt = 300;
private const int hTxt = 27;
private const int lTxt12x = 103;
private const int lTxt1y = 71;
private const int lTxt2y = 140;
//SIZE E LOCATION DI LABEL
private const int lTitlex = -1;
private const int lTitley = 1;
private const int lAliaslblx = 143;
private const int lAliaslbly = 49;
private const int lDirlblx = 164;
private const int lDirlbly = 118;
//SIZE E LOCATION DI RADIOBUTTON
private const int lRdbSoftx = 103;
private const int lRdbGamex = 275;
private const int lRdbSGy = 185;
//SIZE E LOCATION DI BUTTON
private const int wChoose = 63;
private const int hChoose = 27;
private const int wAddCancel = 119;
private const int hAddCancel = 43;
private const int lChoosex = 409;
private const int lChoosey = 140;
private const int lAddx = 254;
private const int lCancelx = 136;
private const int lAddCancely = 227;
//OGGETTI
#region oggetti
//PANEL
public Panel panel = new Panel();
//TEXTBOXES
private TextBox aliastxt = new TextBox();
private TextBox dirtxt = new TextBox();
//LABEL
private Label title = new Label();
private Label aliaslbl = new Label();
private Label dirlbl = new Label();
//RADIOBUTTON
private RadioButton softwarechoose = new RadioButton();
private RadioButton gameschoose = new RadioButton();
//BUTTON
private Button choosebtn = new Button();
private Button addbtn = new Button();
private Button cancelbtn = new Button();
//FILEDIALOG PER LA SCELTA DEL PROGRAMMA
public OpenFileDialog SubOFD = new OpenFileDialog();
//ALTRE VARIABILI
private string alias;
private string filename;
private string dir;
private int sgmod;
#endregion
#endregion
//COSTRUTTORE
public SubForm()
{
//DEFINISCO IL PANEL
panel.Size = new Size(wP, hP);
panel.Location = new Point(lPx, lPy);
panel.BorderStyle = BorderStyle.FixedSingle;
panel.BackColor = Color.FromArgb(Properties.Settings.Default.Rf, Properties.Settings.Default.Gf, Properties.Settings.Default.Bf);
//DEFINISCO LE TEXTBOX
aliastxt.Size = dirtxt.Size = new Size(wTxt, hTxt);
aliastxt.Location = new Point(lTxt12x, lTxt1y);
dirtxt.Location = new Point(lTxt12x, lTxt2y);
dirtxt.Enabled = false;
aliastxt.Font = dirtxt.Font = Properties.Settings.Default.DefaultSubText;
//DEFINISCO I LABEL
title.Location = new Point(lTitlex, lTitley);
aliaslbl.Location = new Point(lAliaslblx, lAliaslbly);
dirlbl.Location = new Point(lDirlblx, lDirlbly);
title.AutoSize = aliaslbl.AutoSize = dirlbl.AutoSize = true;
title.Font = aliaslbl.Font = dirlbl.Font = Properties.Settings.Default.DefaultSubText;
title.Text = "MouseMapper - Crea una nuova configurazione";
aliaslbl.Text = "Scegli l'alias per la configurazione:";
dirlbl.Text = "Posizione del programma:";
//DEFINISCO I RADIOBUTTON
softwarechoose.Location = new Point(lRdbSoftx, lRdbSGy);
gameschoose.Location = new Point(lRdbGamex, lRdbSGy);
softwarechoose.AutoSize = gameschoose.AutoSize = true;
softwarechoose.Font = gameschoose.Font = Properties.Settings.Default.DefaulttxtFont;
softwarechoose.Text = "Identifica come software";
gameschoose.Text = "Identifica come gioco";
//DEFINISCO I BUTTON
choosebtn.Size = new Size(wChoose, hChoose);
addbtn.Size = cancelbtn.Size = new Size(wAddCancel, hAddCancel);
choosebtn.Location = new Point(lChoosex, lChoosey);
addbtn.Location = new Point(lAddx, lAddCancely);
cancelbtn.Location = new Point(lCancelx, lAddCancely);
choosebtn.Font = addbtn.Font = cancelbtn.Font = Properties.Settings.Default.DefaultSubText;
choosebtn.FlatStyle = addbtn.FlatStyle = cancelbtn.FlatStyle = FlatStyle.Flat;
cancelbtn.Text = "Annulla";
addbtn.Text = "Aggiungi";
choosebtn.Text = "...";
//AGGIUNGO I CONTROLLI A panel
panel.Controls.Add(title);
panel.Controls.Add(aliaslbl);
panel.Controls.Add(dirlbl);
panel.Controls.Add(aliastxt);
panel.Controls.Add(dirtxt);
panel.Controls.Add(choosebtn);
panel.Controls.Add(cancelbtn);
panel.Controls.Add(addbtn);
panel.Controls.Add(softwarechoose);
panel.Controls.Add(gameschoose);
//AGGIUNGO I FILTRI
SubOFD.Filter = "Exectuable Files (*.exe)|*.exe";
//INIZIALIZZO LE VARIABILI PRIVATE STRING E INT
alias = "";
filename = "";
dir = "";
sgmod = -1;
}
//SETTER
#region setter
public void setAlias(string s)
{
alias = s;
}
public void setAliastxt(string s)
{
aliastxt.Text = s;
}
public void setName(string s)
{
filename = s;
}
public void setDir(string s)
{
dir = s;
}
public void setDirtxt(string s)
{
dirtxt.Text = s;
}
public void setGMod(int x)
{
if (x == 0)
sgmod = 0;
else
sgmod = 1;
setGamemode();
}
public void setGamemode()
{
if (gameschoose.Checked || sgmod == 1)
{
sgmod = 1;
gameschoose.Checked = true;
}
else
{
sgmod = 0;
softwarechoose.Checked = true;
}
}
public void setaddev (EventHandler e)
{
addbtn.Click += e;
}
public void setcanceldev(EventHandler e)
{
cancelbtn.Click += e;
}
public void setchoosedev(EventHandler e)
{
choosebtn.Click += e;
}
//SETTARE DISABLE CHECKBOXES PER MODIFICABUTTON
public void setAcDischeck(bool active)
{
if(active == true)
gameschoose.Enabled = softwarechoose.Enabled = true;
else
gameschoose.Enabled = softwarechoose.Enabled = false;
}
public void clear()
{
setDirtxt("");
setDir("");
setAlias("");
setAliastxt("");
setName("");
softwarechoose.Checked = false;
gameschoose.Checked = false;
}
#endregion
//GETTER
#region getter
public string getAlias() {
return alias;
}
public string getName()
{
return filename;
}
public string getDir()
{
return dir;
}
public int getSGmod()
{
return sgmod;
}
//DA FORM
public string getAliasfromTxt()
{
return aliastxt.Text;
}
public string getDirfromTxt()
{
return dirtxt.Text;
}
#endregion
}
}