-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainScreen.cs
105 lines (91 loc) · 2.94 KB
/
MainScreen.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
using StartHub.Controls;
using StartHub.Utils;
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 StartHub
{
public partial class MainScreen : Form
{
private int lineCount = -1;
private int fileInt = 0;
private List<ProgramContainer> list = new List<ProgramContainer>();
private List<ProgramControl> pcList = new List<ProgramControl>();
public MainScreen()
{
InitializeComponent();
ShowImages();
}
private void ShowImages()
{
if (lineCount != UtilMethods.getLineCount() || fileInt != UtilMethods.getFileInt())
{
list = UtilMethods.getProgramList();
upDateList();
lineCount = UtilMethods.getLineCount();
fileInt = UtilMethods.getFileInt();
}
}
private void deleteAll()
{
foreach(ProgramControl pc in pcList)
{
pc.Dispose();
}
pcList.Clear();
}
private void upDateList()
{
deleteAll();
foreach(ProgramContainer pro in list)
{
ProgramControl pc = new ProgramControl(pro.name, pro.fileLoc, pro.imgLoc, pro.programId);
pcList.Add(pc);
pc.Parent = flowLayoutPanel1;
}
}
private void managePrograms_Click(object sender, EventArgs e)
{
PopUp popUp = new PopUp();
popUp.Show();
}
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (System.Windows.Forms.Application.MessageLoop)
{
// WinForms app
System.Windows.Forms.Application.Exit();
}
else
{
// Console app
System.Environment.Exit(1);
}
}
private void flowLayoutPanel1_MouseMove(object sender, MouseEventArgs e)
{
ShowImages();
}
}
}