目录
一 设计原型
二 后台源码
一 设计原型
二 后台源码
namespace 流水线作业模拟
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private int Count = 0;
private bool IsStop = false;
private void uiLight1_Click(object sender, EventArgs e)
{
}
private void uiTurnSwitch1_ValueChanged(object sender, bool value)
{
if (uiTurnSwitch1.Active)
{
uiLight1.OffCenterColor = Color.Green;
uiLight1.OffColor = Color.Green;
uiLight1.OnCenterColor = Color.Green;
uiLight1.OnColor = Color.Green;
IsStop = true;
}
else
{
uiLight1.OffCenterColor = Color.Red;
uiLight1.OffColor = Color.Red;
uiLight1.OnCenterColor = Color.Red;
uiLight1.OnColor = Color.Red;
IsStop = false;
uiAnalogMeter1.Value = 0;
}
}
private void Form1_Load(object sender, EventArgs e)
{
Task.Factory.StartNew(() =>
{
while (true)
{
if (IsStop)
{
Count++;
this.Invoke(() =>
{
uiAnalogMeter1.Value = new Random().Next(30, 100);
uiDigitalLabel1.Value = Count;
int A = new Random().Next(888888, 989888778);
int B = new Random().Next(787867, 989888778);
int C = new Random().Next(78767, 989888778);
int D = new Random().Next(546456, 989888778);
int E = new Random().Next(989887, 98988778);
int F = new Random().Next(3234234, 98988778);
int G = new Random().Next(5645654, 98988778);
int H = new Random().Next(5464564, 98988778);
string Result = "OK";
string DateTimes = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
uiDataGridView1.Rows.Add(A, B, C, D, E, F, G, H, Result, DateTimes);
});
}
Thread.Sleep(1000);
}
});
}
}
}