-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClassContainer.cs
388 lines (345 loc) · 13 KB
/
ClassContainer.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;
using System.Timers;
using System.Windows.Media.Media3D;
using System.Windows.Input;
using System.Diagnostics;
using System.Xml.Linq;
using System.Windows.Media.Animation;
using MouseMapper.Properties;
using System.Windows;
namespace MouseMapper
{
class ClassContainer
{
//VARIABILI
#region variabili
//PANNELLO CONTENITORE - POSIZIONE E SIZE
private const int wP1 = 716;
private const int hP1 = 526;
private const int lP1x = 8;
private const int lP1y = 44;
//BOTTONE ELIMINA CONFIGURAZIONE - POSIZIONE E SIZE
private const int whBd = 25;
private const int lBdx = 661;
private const int lBdy = 77;
//CHECKBOX - POSIZIONE E SIZE
private const int lCbx = 476;
private const int lCby = 80;
//LABEL PER LISTE VUOTE
private const int lOpsx = 319;
private const int lOpsy = 176;
private const int lNinsx = 231;
private const int lNinsy = 202;
private const int lhowtoAx = 208;
private const int lhowtoAy = 228;
private const int lAsoftgamesx = 203;
private const int lAsoftgamesy = 254;
private const int lIdentx = 53;
private const int lIdenty = 280;
//OGGETTI GRAFICI
//PANNELLO CONTENITORE
public Panel p1 = new Panel();
public Panel p2 = new Panel();
//SCROLLBAR VERTICALI
public VScrollBar b1 = new VScrollBar();
public VScrollBar b2 = new VScrollBar();
//LABEL PER LISTA VUOTA
Label Ops = new Label();
Label Nins = new Label();
Label howTo = new Label();
Label AsoftGames = new Label();
Label Identify = new Label();
Label Opsg = new Label();
Label Ninsg = new Label();
Label Howtog = new Label();
Label AddSG = new Label();
Label IdG = new Label();
//ALTRE VARIABILI
int lastCheck = 0;
public int conta = 0; //DIPENDE DALLA LETTURA + AGGIUNTA MANUALE
public int contasoftware = 0, contagames = 0;
private int GameorSoftware;
//LISTE
public List<ProgramConfiguration> ListConfig = new List<ProgramConfiguration>(); //UTILIZZO UNA LISTA PER ARCHIVIARE GLI OGGETTI E POTERLI RECUPERARE QUANDO NE NECESSITO
public List<ProgramConfiguration> ListConfigGames = new List<ProgramConfiguration>();
public List<ProgramConfiguration> AllConfig = new List<ProgramConfiguration>();
public List<PanelEx> allPanel = new List<PanelEx>();
public List<PanelEx> allPanelGames = new List<PanelEx>();
private List<Button> allDelete = new List<Button>();
private List<Button> allDeleteGames = new List<Button>();
public SubForm adder = new SubForm();
#endregion
//COSTRUTTORE
public ClassContainer() {
p1.Size = p2.Size = new Size(wP1, hP1);
p1.Location = p2.Location = new Point(lP1x, lP1y);
p1.BorderStyle = p2.BorderStyle = BorderStyle.FixedSingle;
b1.Dock = b2.Dock = DockStyle.Right;
b1.Visible = b2.Visible = true;
b1.SmallChange = b1.LargeChange = b2.SmallChange = b2.LargeChange = 1;
Ops.Location = new Point(lOpsx, lOpsy);
Nins.Location = new Point(lNinsx, lNinsy);
howTo.Location = new Point(lhowtoAx, lhowtoAy);
AsoftGames.Location = new Point(lAsoftgamesx, lAsoftgamesy);
Identify.Location = new Point(lIdentx, lIdenty);
Ops.Text = "Ops!";
howTo.Text = "Per aggiungerne uno, clicca sul";
AsoftGames.Text = "Menù -> Programmi -> Aggiungi";
Ops.Font = AsoftGames.Font = new Font(new Font("calibri", 16f), System.Drawing.FontStyle.Bold);
Nins.Font = howTo.Font = Identify.Font = new Font("calibri light", 16f);
Ops.AutoSize = howTo.AutoSize = AsoftGames.AutoSize = Identify.AutoSize = Nins.AutoSize = true;
Opsg.Location = Ops.Location;
Opsg.Font = Ops.Font;
Opsg.Text = Ops.Text;
Ninsg.Location = Nins.Location;
Ninsg.Font = Nins.Font;
Ninsg.Text = Nins.Text;
Howtog.Location = howTo.Location;
Howtog.Font = howTo.Font;
Howtog.Text = howTo.Text;
AddSG.Location = AsoftGames.Location;
AddSG.Font = AsoftGames.Font;
AddSG.Text = AsoftGames.Text;
IdG.Location = Identify.Location;
IdG.Font = Identify.Font;
IdG.Text = Identify.Text;
Opsg.AutoSize = Ninsg.AutoSize = Howtog.AutoSize = AddSG.AutoSize = IdG.AutoSize = true;
Ops.BackColor = Opsg.BackColor = Nins.BackColor = Ninsg.BackColor = howTo.BackColor = Howtog.BackColor = AddSG.BackColor = AsoftGames.BackColor = Identify.BackColor = IdG.BackColor = Color.Transparent;
checkIfEmpty();
b1.Scroll += new ScrollEventHandler(b1Scroll);
b2.Scroll += new ScrollEventHandler(b2Scroll);
p1.Controls.Add(b1);
p2.Controls.Add(b2);
GameorSoftware = 0;
}
//METODI ESTETICI
#region metodi estetici
//AGGIORNA LE PICTUREBOX DELLE CONFIGURAZIONI CON LE ICONE ASSOCIATE AL PROGRAMMA
public void setPBox()
{
foreach (PanelEx panel in allPanel)
{
foreach (ProgramConfiguration pg in ListConfig)
{
if (panel.dlabel.Text.Equals(pg.getAlias()) && !pg.getNome().Equals(""))
{
Icon x = Icon.ExtractAssociatedIcon(pg.getDir());
Image y = x.ToBitmap();
panel.setImage(y);
}
}
}
foreach (PanelEx panel in allPanelGames)
{
foreach (ProgramConfiguration pg in ListConfigGames)
{
if (panel.dlabel.Text.Equals(pg.getAlias()) && !pg.getNome().Equals(""))
{
Icon x = Icon.ExtractAssociatedIcon(pg.getDir());
Image y = x.ToBitmap();
panel.setImage(y);
}
}
}
}
public void checkIfEmpty()
{
if (ListConfig.Count() == 0 && p1.Contains(Ops) == false)
{
p1.Controls.Add(Ops);
p1.Controls.Add(Nins);
Nins.Text = "Nessun software inserito!";
p1.Controls.Add(howTo);
p1.Controls.Add(AsoftGames);
p1.Controls.Add(Identify);
Identify.Text = "crea un Alias, trova il tuo programma e identificalo come software";
}
if (ListConfigGames.Count() == 0 && p2.Contains(Ops) == false)
{
p2.Controls.Add(Opsg);
p2.Controls.Add(Ninsg);
Ninsg.Text = "Nessun gioco inserito!";
p2.Controls.Add(Howtog);
p2.Controls.Add(AddSG);
p2.Controls.Add(IdG);
IdG.Text = "crea un Alias, trova il tuo programma e identificalo come gioco";
}
if (ListConfig.Count != 0 && p1.Contains(Ops) == true){
p1.Controls.Remove(Ops);
p1.Controls.Remove(Nins);
p1.Controls.Remove(howTo);
p1.Controls.Remove(AsoftGames);
p1.Controls.Remove(Identify);
}
if (ListConfigGames.Count != 0 && p2.Contains(Opsg) == true){
p2.Controls.Remove(Opsg);
p2.Controls.Remove(Ninsg);
p2.Controls.Remove(Howtog);
p2.Controls.Remove(AddSG);
p2.Controls.Remove(IdG);
}
}
#endregion
//AGGIUNTA EVENTHANDLERS
public void addHandlers(EventHandler add, EventHandler cancel, EventHandler choose)
{
adder.setaddev(add);
adder.setcanceldev(cancel);
adder.setchoosedev(choose);
}
public void setWhat(int x)
{
GameorSoftware = x;
}
public int getWhat()
{
return GameorSoftware;
}
public void addtoList(Button b)
{
allDelete.Add(b);
}
public void addtoListGames(Button b)
{
allDeleteGames.Add(b);
}
public void updateNames(int x, Button btR)
{
if(x == 0)
{
allDelete.Remove(btR);
int index = 0;
foreach(Button b in allDelete)
{
b.Name = "CancS" + index.ToString();
index++;
}
}
else
{
allDeleteGames.Remove(btR);
int index = 0;
foreach (Button b in allDeleteGames)
{
b.Name = "CancG" + index.ToString();
index++;
}
}
}
//EVENTHANDLERS
#region eventhandlers
//EVENTI DEDICATI A VSCROLLBARS
private void b1Scroll (object sender, ScrollEventArgs e)
{
if (lastCheck < b1.Maximum)
{
if (b1.Value > lastCheck)
{
foreach (PanelEx panel in allPanel)
{
panel.dynPanel.Location = new Point(panel.dynPanel.Location.X, (panel.dynPanel.Location.Y) - b1.Value + lastCheck);
}
}
else if (b1.Value < lastCheck)
{
foreach (PanelEx panel in allPanel)
{
panel.dynPanel.Location = new Point(panel.dynPanel.Location.X, (panel.dynPanel.Location.Y) - b1.Value + lastCheck);
}
}
}
lastCheck = b1.Value;
}
private void b2Scroll(object sender, ScrollEventArgs e)
{
if (lastCheck < b1.Maximum)
{
if (b2.Value > lastCheck)
{
foreach (PanelEx panel in allPanelGames)
{
panel.dynPanel.Location = new Point(panel.dynPanel.Location.X, (panel.dynPanel.Location.Y) - b1.Value + lastCheck);
}
}
else if (b1.Value < lastCheck)
{
foreach (PanelEx panel in allPanelGames)
{
panel.dynPanel.Location = new Point(panel.dynPanel.Location.X, (panel.dynPanel.Location.Y) - b1.Value + lastCheck);
}
}
}
lastCheck = b2.Value;
}
//EVENTI DEDICATI A DELETEBUTTON
private void deleteAll(object sender, EventArgs e)
{
Button button = (Button)sender;
string filter = button.Name.Replace("deleteb", "");
int getindex = int.Parse(filter);
conta--;
int counter = 0;
foreach (PanelEx panel in allPanel)
{
if (counter != getindex)
{
counter++;
}
else
{
p1.Controls.Remove(panel.dynPanel);
allPanel.Remove(panel);
break;
}
}
counter = 0;
foreach (ProgramConfiguration config in ListConfig)
{
if (counter != getindex)
{
counter++;
}
else
{
ListConfig.Remove(config);
break;
}
}
counter = 0;
foreach (PanelEx panel in allPanel)
{
if (counter != getindex)
{
counter++;
}
else
{
panel.dynPanel.Location = new Point(panel.dynPanel.Location.X, panel.dynPanel.Location.Y - panel.dynPanel.Height - 5);
}
}
} //DA SISTEMARE
//EVENTI DEDICATI A PANELEX.LABELALIAS
public void changeAlias(object sender, EventArgs e)
{
Label x = (Label)sender;
string s = Microsoft.VisualBasic.Interaction.InputBox("Inserisci il nuovo Alias:", "Alias", "Default Response");
foreach (ProgramConfiguration pg in ListConfig)
{
if (pg.getAlias().Equals(x.Text))
{
x.Text = s;
pg.setAlias(x.Text);
sender = x;
break;
}
}
} //DA SISTEMARE
#endregion
}
}