-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
848 lines (720 loc) · 27.9 KB
/
MainForm.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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
using System;
using System.IO;
using System.Net;
using Microsoft.Win32;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
using System.IO.Compression;
using System.Security.Principal;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Drawing;
namespace RAMLite
{
[StructLayout(LayoutKind.Sequential)]
public struct Timer
{
public uint min;
public uint max;
public uint cur;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct MEMORYSTATUSEX
{
public uint dwLength;
public uint dwMemoryLoad;
public ulong ullTotalPhys;
public ulong ullAvailPhys;
public ulong ullTotalPageFile;
public ulong ullAvailPageFile;
public ulong ullTotalVirtual;
public ulong ullAvailVirtual;
public ulong ullAvailExtendedVirtual;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct SYSTEM_CACHE_INFORMATION_64_BIT
{
public long MinimumWorkingSet;
public long MaximumWorkingSet;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
public partial class Mainform : Form
{
private Random _mRandom = new Random();
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);
[DllImport("advapi32.dll", SetLastError = true)]
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
[DllImport("psapi.dll", SetLastError = true)]
public static extern int EmptyWorkingSet(IntPtr hwProc);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GlobalMemoryStatusEx(out MEMORYSTATUSEX lpBuffer);
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
static extern bool GetSystemTimes(out FILETIME lpIdleTime, out FILETIME lpKernelTime, out FILETIME lpUserTime);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern void NtSetTimerResolution(uint DesiredResolution, bool SetResolution, ref uint CurrentResolution);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern UInt32 NtSetSystemInformation(int InfoClass, IntPtr Info, int Length);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern int NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint ActualResolution);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
public string Folder = "";
private int _mResult = 0;
private bool allowVisible;
public string newestver = "";
public uint CurrentResolution;
private TimeSpan SysIdleOldTs;
private TimeSpan SysKernelOldTs;
private TimeSpan SysUserOldTs;
public float ValueCpuUsage { private set; get; }
WebClient wc = new WebClient();
RegistryKey Settings = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\RamLite", true);
RegistryKey Startup = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
SettingsForm SettingsForm = new SettingsForm();
Boolean attivo;
public Mainform()
{
InitializeComponent();
// Abilito Pulizia della standbylist
if (Settings.GetValue("EnableClearingOfTheStandbyList") != null)
{
}
else
{
Settings.SetValue("EnableClearingOfTheStandbyList", "1", RegistryValueKind.String);
}
if (Settings.GetValue("EnableClearingOfTheStandbyList").ToString() == "1")
{
SettingsForm.CheckBoxEnableClearingOfTheStandbyList.Checked = true;
}
else if (Settings.GetValue("EnableClearingOfTheStandbyList").ToString() == "0")
{
SettingsForm.CheckBoxEnableClearingOfTheStandbyList.Checked = false;
}
// Abilita valore timer custom
if (Settings.GetValue("EnableCustomTimerResolution") != null)
{
}
else
{
Settings.SetValue("EnableCustomTimerResolution", "1", RegistryValueKind.String);
}
if (Settings.GetValue("EnableCustomTimerResolution").ToString() == "1")
{
SettingsForm.CheckBoxEnableCustomTimerResolution.Checked = true;
}
else if (Settings.GetValue("EnableCustomTimerResolution").ToString() == "0")
{
SettingsForm.CheckBoxEnableCustomTimerResolution.Checked = false;
}
// EAbilita la pulizia della ram in uso
if (Settings.GetValue("EnableEmptyingOfTheWorkingSet") != null)
{
}
else
{
Settings.SetValue("EnableEmptyingOfTheWorkingSet", "1", RegistryValueKind.String);
}
if (Settings.GetValue("EnableEmptyingOfTheWorkingSet").ToString() == "1")
{
SettingsForm.CheckBoxEnableEmptyingOfTheWorkingSet.Checked = true;
}
else if (Settings.GetValue("EnableEmptyingOfTheWorkingSet").ToString() == "0")
{
SettingsForm.CheckBoxEnableEmptyingOfTheWorkingSet.Checked = false;
}
// Hotkey per pulire
if (Settings.GetValue("HotkeyToCleanMemory") != null)
{
SettingsForm.HotkeyToCleanMemory.Text = Settings.GetValue("HotkeyToCleanMemory").ToString();
}
else
{
SettingsForm.HotkeyToCleanMemory.Text = "F10";
Settings.SetValue("HotkeyToCleanMemory", SettingsForm.HotkeyToCleanMemory.Text, RegistryValueKind.String);
}
// Avvia il programma all avvio
if (Settings.GetValue("StartMemoryCleanerOnSystemStartup") != null)
{
}
else
{
Settings.SetValue("StartMemoryCleanerOnSystemStartup", "0", RegistryValueKind.String);
}
if (Settings.GetValue("StartMemoryCleanerOnSystemStartup").ToString() == "1")
{
SettingsForm.CheckBoxStartMemoryCleanerOnSystemStartup.Checked = true;
Startup.SetValue("RamLite", "\"" + Application.ExecutablePath + "\"", RegistryValueKind.String);
}
else if (Settings.GetValue("StartMemoryCleanerOnSystemStartup").ToString() == "0")
{
SettingsForm.CheckBoxStartMemoryCleanerOnSystemStartup.Checked = false;
if (Startup.GetValue("RamLite") != null)
{
Startup.DeleteValue("RamLite");
}
}
// Start Minimized
if (Settings.GetValue("StartMinimized") != null)
{
}
else
{
Settings.SetValue("StartMinimized", "0", RegistryValueKind.String);
}
if (Settings.GetValue("StartMinimized").ToString() == "1")
{
SettingsForm.CheckBoxStartMinimized.Checked = true;
Minimize();
}
else if (Settings.GetValue("StartMinimized").ToString() == "0")
{
SettingsForm.CheckBoxStartMinimized.Checked = false;
Maximize();
}
// Start Timer Automatico
if (Settings.GetValue("StartTimerResolutionAutomatically") != null)
{
}
else
{
Settings.SetValue("StartTimerResolutionAutomatically", "0", RegistryValueKind.String);
}
if (Settings.GetValue("StartTimerResolutionAutomatically").ToString() == "1")
{
SettingsForm.CheckBoxStartTimerResolutionAutomatically.Checked = true;
TimerRes(1);
}
else if (Settings.GetValue("StartTimerResolutionAutomatically").ToString() == "0")
{
SettingsForm.CheckBoxStartTimerResolutionAutomatically.Checked = false;
TimerRes(2);
}
// Timer Abilitato
if (Settings.GetValue("TimerEnabled") != null)
{
}
else
{
Settings.SetValue("TimerEnabled", "1", RegistryValueKind.String);
}
if (Settings.GetValue("TimerEnabled").ToString() == "1")
{
SettingsForm.CheckBoxEnableTimer.Checked = true;
}
else if (Settings.GetValue("TimerEnabled").ToString() == "0")
{
SettingsForm.CheckBoxEnableTimer.Checked = false;
}
// Timer intervallo de aggiornamento
if (Settings.GetValue("TimerPollingInterval") != null)
{
SettingsForm.TimerPollingInterval.Text = Settings.GetValue("TimerPollingInterval").ToString();
}
else
{
SettingsForm.TimerPollingInterval.Text = "1 sec";
Settings.SetValue("TimerPollingInterval", SettingsForm.TimerPollingInterval.Text, RegistryValueKind.String);
}
SaveSettings();
}
public void CpuUsage()
{
var th = new Thread(() =>
{
while (true)
{
Thread.Sleep(1500);
Update();
}
});
th.IsBackground = true;
th.Start();
}
private new bool Update()
{
FILETIME sysIdle;
FILETIME sysKernel;
FILETIME sysUser;
if (GetSystemTimes(out sysIdle, out sysKernel, out sysUser))
{
TimeSpan sysIdleTs = GetTimeSpanFromFileTime(sysIdle);
TimeSpan sysKernelTs = GetTimeSpanFromFileTime(sysKernel);
TimeSpan sysUserTs = GetTimeSpanFromFileTime(sysUser);
TimeSpan sysIdleDiffenceTs = sysIdleTs.Subtract(SysIdleOldTs);
TimeSpan sysKernelDiffenceTs = sysKernelTs.Subtract(SysKernelOldTs);
TimeSpan sysUserDiffenceTs = sysUserTs.Subtract(SysUserOldTs);
SysIdleOldTs = sysIdleTs;
SysKernelOldTs = sysKernelTs;
SysUserOldTs = sysUserTs;
TimeSpan system = sysKernelDiffenceTs.Add(sysUserDiffenceTs);
try
{
ValueCpuUsage = (float)(((system.Subtract(sysIdleDiffenceTs).TotalMilliseconds) * 100) / system.TotalMilliseconds);
if (ValueCpuUsage < 0)
ValueCpuUsage = 0;
lblCpuUsage.Text = Convert.ToString(Convert.ToInt32(ValueCpuUsage)) + '%';
progressBar1.Value = Convert.ToInt32(ValueCpuUsage);
}
catch
{ }
return true;
}
else
{
return false;
}
}
private static TimeSpan GetTimeSpanFromFileTime(FILETIME time)
{
return TimeSpan.FromMilliseconds((((ulong)time.dwHighDateTime << 32) + (uint)time.dwLowDateTime) * 0.000001);
}
public override string ToString()
{
return string.Format("CPU: {0:0.00} %", ValueCpuUsage);
}
private void MenuItemExit_Click(object sender, EventArgs e)
{
Exit(sender, e);
UpdateValues();
}
private void MenuItemSettings_Click(object sender, EventArgs e)
{
SettingsForm.ShowDialog(this);
UpdateValues();
}
private void MenuItemAbout_Click(object sender, EventArgs e)
{
UpdateValues();
}
private void ButtonStart_Click(object sender, EventArgs e)
{
TimerRes(1);
UpdateValues();
}
private void ButtonStop_Click(object sender, EventArgs e)
{
TimerRes(2);
UpdateValues();
}
public string GetEffectName(int index)
{
string result = string.Format("Effect{0}", index);
return result;
}
private void ButtonCleanMemory_Click(object sender, EventArgs e)
{
try
{
CleanMemory();
UpdateValues();
}
catch(Exception ex)
{
}
}
private void SystemTrayIcon_DoubleClick(object sender, MouseEventArgs e)
{
Maximize();
UpdateValues();
}
private void MainForm_Load(object sender, EventArgs e)
{
UpdateValues();
}
private void MainForm_Resize(object sender, EventArgs e)
{
switch (this.WindowState)
{
case FormWindowState.Minimized:
Minimize();
UpdateValues();
break;
case FormWindowState.Maximized:
Maximize();
UpdateValues();
break;
}
}
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
Exit(sender, e);
}
private void Exit(object sender, EventArgs e)
{
Application.Exit();
UnregisterHotKey(this.Handle, 1);
}
public void SaveSettings()
{
RegisterHotkey();
UpdateValues();
Timer();
switch (SettingsForm.CheckBoxStartMemoryCleanerOnSystemStartup.Checked)
{
case true:
Startup.SetValue("RamLite ", "\"" + Application.ExecutablePath + "\"", RegistryValueKind.String);
break;
case false:
if (Startup.GetValue("RamLite ") != null)
{
Startup.DeleteValue("RamLite ");
}
break;
}
}
protected override void SetVisibleCore(bool value)
{
if (!allowVisible)
{
value = false;
if (!this.IsHandleCreated) CreateHandle();
}
base.SetVisibleCore(value);
}
private ulong GetMemory(int x)
{
MEMORYSTATUSEX statex = new MEMORYSTATUSEX();
statex.dwLength = 64;
bool a = GlobalMemoryStatusEx(out statex);
switch (x)
{
case 1:
return statex.ullAvailPhys;
case 2:
return statex.ullTotalPhys;
default:
return 0;
}
}
private void TimerRes(int x)
{
switch (x)
{
case 1:
NtSetTimerResolution(Convert.ToUInt32(SettingsForm.DesiredTimerResolution.Value), true, ref CurrentResolution);
break;
case 2:
NtSetTimerResolution(Convert.ToUInt32(SettingsForm.DesiredTimerResolution.Value), false, ref CurrentResolution);
break;
}
}
private Timer GetTimerRes()
{
var a = new Timer();
NtQueryTimerResolution(out a.min, out a.max, out a.cur);
return a;
}
private void Minimize()
{
this.Hide();
this.WindowState = FormWindowState.Minimized;
}
private void Maximize()
{
this.allowVisible = true;
this.Show();
this.WindowState = FormWindowState.Normal;
this.ShowInTaskbar = true;
}
private void RegisterHotkey()
{
Keys a;
Enum.TryParse(SettingsForm.HotkeyToCleanMemory.Text.Replace("Shift + ", "").Replace("Control + ", "").Replace("Alt + ", ""), out a);
if (SettingsForm.HotkeyToCleanMemory.Text.Contains("Shift"))
{
UnregisterHotKey(this.Handle, 1);
RegisterHotKey(this.Handle, 1, (int)4, a.GetHashCode());
}
else if (SettingsForm.HotkeyToCleanMemory.Text.Contains("Control"))
{
UnregisterHotKey(this.Handle, 1);
RegisterHotKey(this.Handle, 1, (int)2, a.GetHashCode());
}
else if (SettingsForm.HotkeyToCleanMemory.Text.Contains("Alt"))
{
UnregisterHotKey(this.Handle, 1);
RegisterHotKey(this.Handle, 1, (int)1, a.GetHashCode());
}
else
{
UnregisterHotKey(this.Handle, 1);
RegisterHotKey(this.Handle, 1, (int)0, a.GetHashCode());
}
}
private void Timer()
{
switch (SettingsForm.TimerPollingInterval.Text)
{
case "0.5 sec":
if (SettingsForm.CheckBoxEnableTimer.Checked == true)
{
Timer1.Interval = 500;
}
break;
case "1 sec":
if (SettingsForm.CheckBoxEnableTimer.Checked == true)
{
Timer1.Interval = 1000;
}
break;
case "2 sec":
if (SettingsForm.CheckBoxEnableTimer.Checked == true)
{
Timer1.Interval = 2000;
}
break;
case "5 sec":
if (SettingsForm.CheckBoxEnableTimer.Checked == true)
{
Timer1.Interval = 5000;
}
break;
case "10 sec":
if (SettingsForm.CheckBoxEnableTimer.Checked == true)
{
Timer1.Interval = 10000;
}
break;
}
switch (SettingsForm.CheckBoxEnableTimer.Checked)
{
case true:
Timer1.Enabled = true;
break;
case false:
Timer1.Enabled = false;
break;
}
}
private void Clear(int x)
{
switch (x)
{
case 1:
string processname = "";
Process[] allProcesses = Process.GetProcesses();
List<string> successProcesses = new List<string>();
List<string> failProcesses = new List<string>();
for (int i = 0; i < allProcesses.Length; i++)
{
Process p = new Process();
p = allProcesses[i];
try
{
processname = p.ProcessName;
EmptyWorkingSet(p.Handle);
}
catch
{
}
}
break;
case 2:
try
{
if (SetIncreasePrivilege("SeIncreaseQuotaPrivilege"))
{
int SystemInfoLength = Marshal.SizeOf(4);
GCHandle gcHandle = GCHandle.Alloc(4, GCHandleType.Pinned);
SYSTEM_CACHE_INFORMATION_64_BIT information64Bit = new SYSTEM_CACHE_INFORMATION_64_BIT();
information64Bit.MinimumWorkingSet = -1L;
information64Bit.MaximumWorkingSet = -1L;
SystemInfoLength = Marshal.SizeOf(information64Bit);
gcHandle = GCHandle.Alloc(information64Bit, GCHandleType.Pinned);
gcHandle.Free();
}
if (SetIncreasePrivilege("SeProfileSingleProcessPrivilege"))
{
GCHandle gcHandle = GCHandle.Alloc(4, GCHandleType.Pinned);
uint num = NtSetSystemInformation(80, gcHandle.AddrOfPinnedObject(), Marshal.SizeOf(4));
if (num != 0)
{
throw new Exception("NtSetSystemInformation(SYSTEMMEMORYLISTINFORMATION) error: ", new Win32Exception(Marshal.GetLastWin32Error()));
}
gcHandle.Free();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
break;
}
}
private void CleanMemory()
{
if (SettingsForm.CheckBoxEnableEmptyingOfTheWorkingSet.Checked == true)
{
Clear(1);
}
if (SettingsForm.CheckBoxEnableClearingOfTheStandbyList.Checked == true)
{
Clear(2);
}
}
private static bool SetIncreasePrivilege(string privilegeName)
{
using (WindowsIdentity current = WindowsIdentity.GetCurrent(TokenAccessLevels.Query | TokenAccessLevels.AdjustPrivileges))
{
TokPriv1Luid newst;
newst.Count = 1;
newst.Luid = 0L;
newst.Attr = 2;
if (!LookupPrivilegeValue(null, privilegeName, ref newst.Luid))
{
throw new Exception("Error in LookupPrivilegeValue: ", new Win32Exception(Marshal.GetLastWin32Error()));
}
int num = AdjustTokenPrivileges(current.Token, false, ref newst, 0, IntPtr.Zero, IntPtr.Zero) ? 1 : 0;
if (num == 0)
{
throw new Exception("Error in AdjustTokenPrivileges: ", new Win32Exception(Marshal.GetLastWin32Error()));
}
return num != 0;
}
}
private void UpdateValues()
{
Update();
AvailableMemory.Text = "Available: " + (GetMemory(1) / 1048576) + " MB";
TotalMemory.Text = "Total: " + (GetMemory(2) / 1048576) + " MB";
Utilizzo.Minimum = 0;
Utilizzo.Maximum = Convert.ToInt32((GetMemory(2) / 1048576)) ;
Utilizzo.Value = Convert.ToInt32((GetMemory(1) / 1048576));
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == 0x0312)
{
CleanMemory();
UpdateValues();
}
}
private void Timer1_Tick(object sender, EventArgs e)
{
UpdateValues();
}
private void fileToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void SetAutomation_Click(object sender, EventArgs e)
{
}
private void btnFerma_Click(object sender, EventArgs e)
{
TimerAuto.Enabled = false;
}
private void auto()
{
if (Convert.ToInt32((GetMemory(1) / 1048576)) < Convert.ToInt32(edtMinima.Text))
{
CleanMemory();
UpdateValues();
}
}
private void TimerAuto_Tick(object sender, EventArgs e)
{
auto();
}
private void automazioneToolStripMenuItem_Click(object sender, EventArgs e)
{
if (groupBoxAuto.Visible == true)
{
if (groupBoxCpu.Visible == true)
{
groupBoxAuto.Visible = false;
this.Size = new System.Drawing.Size(406, 212);
}
else
{
groupBoxAuto.Visible = false;
this.Size = new System.Drawing.Size(256, 212);
}
}
else
{
if (groupBoxCpu.Visible == true)
{
groupBoxAuto.Visible = true;
this.Size = new System.Drawing.Size(406, 323);
}
else
{
groupBoxAuto.Visible = true;
this.Size = new System.Drawing.Size(256, 323);
}
//groupBoxAuto.Visible = true;
//this.Size = new System.Drawing.Size(256, 323);
}
}
private void button1_Click(object sender, EventArgs e)
{
TimerAuto.Interval = 500;
TimerAuto.Enabled = true;
}
private void btnFerma_Click_1(object sender, EventArgs e)
{
TimerAuto.Enabled = false;
}
private void cpuToolStripMenuItem_Click(object sender, EventArgs e)
{
if (groupBoxCpu.Visible == true)
{
if (groupBoxAuto.Visible == true)
{
groupBoxCpu.Visible = false;
this.Size = new System.Drawing.Size(256, 323); ;
}
else
{
groupBoxCpu.Visible = false;
this.Size = new System.Drawing.Size(256, 212);
}
// groupBoxCpu.Visible = false;
//this.Size = new System.Drawing.Size(256, 212);
}
else
{
if (groupBoxAuto.Visible == true)
{
groupBoxCpu.Visible = true;
this.Size = new System.Drawing.Size(406, 323); ;
}
else
{
groupBoxCpu.Visible = true;
this.Size = new System.Drawing.Size(406, 212);
}
}
}
private void gameModeToolStripMenuItem_Click(object sender, EventArgs e)
{
//todo
if (this.TopMost){
this.TopMost = false;
this.Opacity = 1D;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
} else {
this.TopMost = true;
this.Opacity = 0.5D;
this.FormBorderStyle = FormBorderStyle.None;
}
}
}
}