BoxResetControl.cs
3.3 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
using DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoCountMachine
{
public partial class BoxResetControl : UserControl
{
System.Timers.Timer timer;
public BoxResetControl()
{
InitializeComponent();
if (GetIsDesignMode())
return;
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.AutoReset = true;
timer.Elapsed += Timer_Elapsed;
timer.Enabled = false;
GC.KeepAlive(timer);
}
private bool GetIsDesignMode()
{
return (this.GetService(typeof(System.ComponentModel.Design.IDesignerHost)) != null
|| LicenseManager.UsageMode == LicenseUsageMode.Designtime);
}
private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
this.Invoke((EventHandler)delegate {
NgCountBar.ForeColor = Color.MediumSeaGreen;
MsdCountBar.ForeColor = Color.MediumSeaGreen;
PaperCountBar.ForeColor = Color.MediumSeaGreen;
if (RobotManage.filterMachine.NGBox_Count > RobotManage.filterMachine.Config.NG_BOX_MAXCOUNT * 0.8)
NgCountBar.ForeColor = Color.Red;
if (RobotManage.filterMachine.MSDBox_Count > RobotManage.filterMachine.Config.MSD_BOX_MAXCOUNT * 0.8)
MsdCountBar.ForeColor = Color.Red;
if (RobotManage.filterMachine.PaperBox_Count > RobotManage.filterMachine.Config.PAPER_BOX_MAXCOUNT * 0.8)
PaperCountBar.ForeColor = Color.Red;
NgCountBar.Value = RobotManage.filterMachine.NGBox_Count;
MsdCountBar.Value = RobotManage.filterMachine.MSDBox_Count;
PaperCountBar.Value = RobotManage.filterMachine.PaperBox_Count;
});
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
{
if (state)
{
this.Invoke((EventHandler)delegate
{
NgCountBar.Maximum = RobotManage.filterMachine.Config.NG_BOX_MAXCOUNT;
MsdCountBar.Maximum = RobotManage.filterMachine.Config.MSD_BOX_MAXCOUNT;
PaperCountBar.Maximum = RobotManage.filterMachine.Config.PAPER_BOX_MAXCOUNT;
MsdCountBar.ForeColor = Color.MediumSeaGreen;
PaperCountBar.ForeColor = Color.MediumSeaGreen;
timer.Enabled = true;
timer.Start();
});
}
}
private void btn_NGClear_Click(object sender, EventArgs e)
{
RobotManage.filterMachine.NGBox_Count = 0;
}
private void btn_MSDClear_Click(object sender, EventArgs e)
{
RobotManage.filterMachine.MSDBox_Count = 0;
}
private void btn_PaperClear_Click(object sender, EventArgs e)
{
RobotManage.filterMachine.PaperBox_Count = 0;
}
}
}