-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUserForm.cs
103 lines (90 loc) · 2.99 KB
/
UserForm.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
using System;
using System.Windows.Forms;
using pctesting.TestHardware;
namespace pctesting
{
public partial class UserForm : Form
{
FileManager fileWatcher;
TrafficManager trafficWatcher;
ProcessControl process;
ActivityControl activityControl;
string comp;
string user;
public UserForm(string userName, string compName)
{
InitializeComponent();
fileWatcher = new FileManager(userName, compName);
trafficWatcher = new TrafficManager(userName, compName);
process = new ProcessControl(userName, compName);
activityControl = new ActivityControl(userName, compName);
this.comp = compName;
this.user = userName;
fileWatcher.watch();
trafficWatcher.Start();
activityControl.Subscribe();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Show();
pctestingIcon.Visible = false;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
backgroundWorkerForSaveInfo.RunWorkerAsync();
timer1.Enabled = false;
activityControl.Unsubscribe();
trafficWatcher.Stop();
//process.SaveToDatabase();
Application.Exit();
}
private void pctetingIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
pctestingIcon.Visible = false;
}
private void UserForm_Move(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Hide();
pctestingIcon.Visible = true;
}
}
private void testButton_Click(object sender, EventArgs e)
{
TestHardware.Stop st = new TestHardware.Stop(user, comp);
st.ShowDialog();
}
private void timer1_Tick(object sender, EventArgs e)
{
process.UpdateProcess();
}
private void UserForm_Load(object sender, EventArgs e)
{
}
private void UserForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
e.Cancel = true;
this.Hide();
pctestingIcon.Visible = true;
}
}
private void exitButton_Click(object sender, EventArgs e)
{
backgroundWorkerForSaveInfo.RunWorkerAsync();
timer1.Enabled = false;
activityControl.Unsubscribe();
trafficWatcher.Stop();
//process.SaveToDatabase();
new LoginForm().Show();
this.Close();
}
private void backgroundWorkerForSaveInfo_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
process.SaveToDatabase();
}
}
}