MetroDynamicTesting.cs
10.4 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Comm;
using MetroFramework.Forms;
using Dal;
namespace App
{
using FrmTestManageSwitch = FrmTestManage2;
public partial class MetroDynamicTesting : FrmBase
{
private bool isTest = true;//判断上一个状态是否为暂停测试
FrmTestManageSwitch newForm;
private LoginManager _loginManager;
public MetroDynamicTesting(LoginManager loginManager)
{
InitializeComponent();
this.WindowState = FormWindowState.Maximized;
this.SetLanguage(this);
this._loginManager = loginManager;
Init();
this.label1.Text = getMsg("FrmTestNoData");
}
private void Init()
{
if (Fuction.m_Language == Const.LANGUAGE_ENGLISH)
{
this.Text = getMsg("FrmMDItsmi_Dynamic") +" " + getMsg("FrmMDItabTest");
}
else
{
this.Text = getMsg("FrmMDItsmi_Dynamic") + getMsg("FrmMDItabTest");
}
this.startTestingButton.Text = getMsg("FrmMDIAuth_2010");
this.stopTestingButton.Text = getMsg("FrmMDIAuth_2020");
this.gobackButton.Text = getMsg("back");
this.btnNext.Text = getMsg("frmProductbtn_Choose");
this.lbl_temp.Text = getMsg("FrmMDIRightNavigateBarlbl_SolventTemp")+":";
this.lbl_pattern.Text = getMsg("FrmMDIRightNavigateBarlbl_TestMode")+":";
this.lbl_solvent.Text = getMsg("FrmMDIRightNavigateBarlbl_TestSolvent")+":";
this.lbl_time.Text = getMsg("FrmMDIRightNavigateBarlbl_Date")+":";
}
//
public void AddToDynamicPanel(FrmTestManageSwitch form)
{
try
{
this.DynamicTestingShow.Location = new Point(12, -50);
this.DynamicTestingShow.Size = new System.Drawing.Size(this.mdiPanel.Width - 24, this.mdiPanel.Height-20);
this.DynamicTestingShow.BorderStyle = System.Windows.Forms.BorderStyle.None;
newForm = form;
this.IsMdiContainer = true;
newForm.Movable = false;
newForm.ControlBox = false;
newForm.ShowInTaskbar = false;
newForm.MdiParent = this;//指定当前窗体为顶级Mdi窗体
newForm.Parent = this.DynamicTestingShow;//指定子窗体的父容器为
newForm.FormBorderStyle = FormBorderStyle.None;// 无边框
newForm.Dock = System.Windows.Forms.DockStyle.Fill;
this.DynamicTestingShow.Controls.Add(newForm);// 添加到 Panel中
newForm.Show(); // 显示
this.label1.SendToBack();
newForm.Activate();//激活
}
catch (Exception ex)
{
LOGGER.Error("AddToDynamicPanel", ex);
}
}
/**
* 开始测试
*/
private void startTestingButton_Click(object sender, EventArgs e)
{
this.DynamicTestingShow.Location = new Point(113, 10);
this.DynamicTestingShow.Size = new System.Drawing.Size(this.mdiPanel.Width - 120, this.mdiPanel.Height - 20);
this.DynamicTestingShow.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.IsMdiContainer = true;
this.label1.Visible = false;
chooseProduct();
}
private MetroProduct mp;
public void chooseProduct()
{
try
{
gobackButton.Visible = true;
btnNext.Visible = true;
stopTestingButton.Visible = false;
gobackButton.Enabled = true;
btnNext.Enabled = false;
MetroProduct.returnValue = -100;
mp = new MetroProduct(Const.OPERATION_CHOOSE, "testModeItemDYNAMIC", _loginManager);
//newForm.Owner = this;
mp.Movable = false;
mp.ControlBox = false;
//newForm.ShowInTaskbar = false;
mp.MdiParent = this;//指定当前窗体为顶级Mdi窗体
mp.Parent = this.DynamicTestingShow;//指定子窗体的父容器为
mp.FormBorderStyle = FormBorderStyle.None; // 无边框
mp.Dock = System.Windows.Forms.DockStyle.Fill;
this.DynamicTestingShow.Controls.Add(mp); // 添加到 Panel中
mp.checkMachineState();
mp.Show(); // 显示
mp.Activate();//激活
}
catch (Exception ex)
{
LOGGER.Error("chooseProduct", ex);
}
}
private void stopTestingButton_Click(object sender, EventArgs e)
{
if (ShowMessageBox.ShowQuestion(Const.MESSAGEBOX_TITLE_NOTE, Const.Cut_Off_Test))
{
CutOffTest();//中止测试
this.label1.SendToBack();
}
}
private void CutOffTest()
{
if (newForm is FrmTestManageSwitch)
{
((FrmTestManageSwitch)newForm).CutOffTest();
return;
}
}
private void goBackButton_Click(object sender, EventArgs e)
{
this.Close();
MetroMDI mm = new MetroMDI(_loginManager);
mm.Show();
}
private void PauseTest()
{
if (newForm is FrmTestManage)
{
//if (((FrmTestManage)newForm).IsRealStart)
//{
//如果之前为暂停测试,点击按钮后名字变为继续测试
//如果之前为继续测试,点击按钮后名字变为暂停测试
if (this.isTest)
{
//////tn.Text = getMsg("FrmMDIAuth_" + Const.TREE_GOONTEST);//继续测试
//(Fuction.m_Language == Const.LANGUAGE_CHINESE) ? "继续测试" : "GoOn Test";
this.isTest = false;//按下暂停键
gobackButton.Text = getMsg("FrmMDIAuth_2031");//按钮文字改为继续测试
//((FrmTestManage)newForm).PauseTest();
return;
}
else
{
//////tn.Text = getMsg("FrmMDIAuth_" + Const.TREE_PAUSETEST);////暂停测试
//(Fuction.m_Language == Const.LANGUAGE_CHINESE) ? "暂停测试" : "Pause Test";
this.isTest = true;//按下继续测试
gobackButton.Text = getMsg("FrmMDIAuth_2030");//按钮文字改为暂停测试
//((FrmTestManage)newForm).GoOnTest();
return;
}
//}
}
}
private void panel1_MouseHover(object sender, EventArgs e)
{
//showInfo();
}
private void showInfo()
{
//this.label5.Location = new Point(this.label5.Location.X + 40, this.label5.Location.Y);
//this.label6.Location = new Point(this.label6.Location.X + 196, this.label6.Location.Y);
//this.label7.Location = new Point(this.label7.Location.X + 196, this.label7.Location.Y);
//this.label8.Location = new Point(this.label8.Location.X + 196, this.label8.Location.Y);
this.lbl_time.Visible = true;
this.lbl_temp.Visible = true;
this.lbl_solvent.Visible = true;
this.lbl_pattern.Visible = true;
}
private void hideInfo()
{
this.label5.Location = new Point(this.label5.Location.X - 40, this.label5.Location.Y);
this.label6.Location = new Point(this.label6.Location.X - 65, this.label6.Location.Y);
this.label7.Location = new Point(this.label7.Location.X - 65, this.label7.Location.Y);
this.label8.Location = new Point(this.label8.Location.X - 65, this.label8.Location.Y);
this.lbl_time.Visible = false;
this.lbl_temp.Visible = false;
this.lbl_solvent.Visible = false;
this.lbl_pattern.Visible = false;
}
private void panel1_MouseLeave(object sender, EventArgs e)
{
//hideInfo();
}
public void showInfo(int para, string data)
{
int count = this.panel1.Controls.Count;
for (int i = 0; i < count; i++)
{
if (this.panel1.Controls[i] is Label && Convert.ToInt32(this.panel1.Controls[i].Tag) == para)
{
this.panel1.Controls[i].Text = data;
return;
}
}
}
public void showControls()
{
this.stopTestingButton.Visible = true;
//this.pauseTestingButton.Visible = true;
//this.panel1.Visible = true;
}
private void MetroDynamicTesting_Load(object sender, EventArgs e)
{
chooseProduct();
this.label1.SendToBack();
this.label1.Left = (this.DynamicTestingShow.Width - this.label1.Width) / 2;
this.label1.Top = (this.DynamicTestingShow.Height - this.label1.Height) / 2;
}
private bool isShow = true;
private void panel1_Click(object sender, EventArgs e)
{
if (isShow)
{
showInfo();
isShow = false;
}
else
{
hideInfo();
isShow = true;
}
}
/**
* 下一步
*/
private void btnNext_Click(object sender, EventArgs e)
{
//mp.checkMachineState();
if (this.btnNext.Enabled)
{
this.stopTestingButton.Location = this.btnNext.Location;
this.DynamicTestingShow.Height = this.mdiPanel.Height;
this.gobackButton.Visible = false;
this.btnNext.Visible = false;
mp.Next();
}
}
public void showNextButton()
{
this.btnNext.Enabled = true;
}
public void hideNextButton()
{
this.btnNext.Enabled = false;
}
}
}