-
Notifications
You must be signed in to change notification settings - Fork 1
/
PopUp.cs
129 lines (104 loc) · 3.72 KB
/
PopUp.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
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;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StartHub
{
public partial class PopUp : Form
{
public PopUp()
{
InitializeComponent();
}
private int lineCount = -1;
private int fileInt = 0;
private List<ProgramContainer> list = new List<ProgramContainer>();
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();
protected override void OnPaint(PaintEventArgs e)
{
if (lineCount != UtilMethods.getLineCount() || fileInt != UtilMethods.getFileInt())
{
list = UtilMethods.getProgramList();
upDateList();
lineCount = UtilMethods.getLineCount();
fileInt = UtilMethods.getFileInt();
}
base.OnPaint(e);
}
public override void Refresh()
{
if (lineCount != UtilMethods.getLineCount() || fileInt != UtilMethods.getFileInt())
{
list = UtilMethods.getProgramList();
upDateList();
lineCount = UtilMethods.getLineCount();
fileInt = UtilMethods.getFileInt();
}
base.Refresh();
}
private void upDateList()
{
startHubList.Items.Clear();
foreach(ProgramContainer pro in list)
{
startHubList.Items.Add(pro.name + " : " + pro.programId);
}
startHubList.Hide();
startHubList.Show();
}
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)
{
this.Close();
}
private void addProgram_Click(object sender, EventArgs e)
{
SelectPop selectPop = new SelectPop();
selectPop.Show();
}
private void removeProgram_Click(object sender, EventArgs e)
{
ProgramContainer pro = UtilMethods.stringToPC((string)startHubList.SelectedItem, list);
if(pro == null)
{
return;
}
startHubList.Items.Remove(startHubList.SelectedItem);
UtilMethods.removeLine(pro.name, pro.fileLoc, pro.imgLoc);
}
private void PopUp_MouseMove(object sender, MouseEventArgs e)
{
Refresh();
}
private void startHubList_MouseDoubleClick(object sender, MouseEventArgs e)
{
int index = this.startHubList.IndexFromPoint(e.Location);
if (index != System.Windows.Forms.ListBox.NoMatches)
{
ProgramContainer sltPro = UtilMethods.stringToPC(startHubList.Items[index].ToString(), list);
SelectPop selectPop = new SelectPop(sltPro.name, sltPro.fileLoc, sltPro.imgLoc);
selectPop.Show();
}
}
}
}