FrmCodeLearn.cs
4.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
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
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using System;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace URSoldering.Client
{
public partial class FrmCodeLearn : FrmBase
{
private static string appPath = Application.StartupPath;
private static string path = appPath + ConfigAppSettings.GetValue(Setting_Init.CodeParamPath);
public FrmCodeLearn()
{
InitializeComponent();
}
private void btnOpen_Click(object sender, EventArgs e)
{
string filePath = FormUtil.getValue(txtParamPath);
if (File.Exists(filePath))
{
}
else
{
try
{
File.Create(filePath);
}
catch (Exception ex)
{
LogUtil.error("创建文件:" + filePath + " 失败");
MessageBox.Show("创建文件失败!");
txtParamPath.SelectAll();
txtParamPath.Focus();
return;
}
}
//File.Delete(filePath);
string cameraName = cmbCameraList.Text;
string codeType = this.cmbCodeType.Text;
int count = cmbCount.SelectedIndex + 1;
Task.Factory.StartNew(delegate ()
{
HDevelopCodeLearn.RunHalcon(this.hWindowControl1.HalconWindow, cameraName, codeType, filePath, count);
});
FormStatus(true);
}
private void FormStatus(bool open)
{
btnOpen.Enabled = !open;
btnStop.Enabled = open;
//timer1.Enabled = open;
//cmbCount.Enabled = !open;
//cmbCodeType.Enabled = !open;
//cmbCameraList.Enabled = !open;
}
private void btnStop_Click(object sender, EventArgs e)
{
HDevelopCodeLearn.StopLearn();
FormStatus(false);
}
private void FrmCamera_Load(object sender, EventArgs e)
{
LogUtil.logBox = this.richTextBox2;
HDevelopExport.LoadConfig(ConfigAppSettings.GetValue(Setting_Init.CameraName),ConfigAppSettings.GetValue(Setting_Init.CodeType));
FormStatus(false);
cmbCameraList.DataSource = HDevelopExport.cameraNameList;
if (HDevelopExport.cameraNameList.Count > 0)
{
cmbCameraList.SelectedIndex = 0;
}
cmbCodeType.DataSource = HDevelopExport.codeTypeList;
if (HDevelopExport.codeTypeList.Count > 0)
{
cmbCodeType.SelectedIndex = 0;
}
else
{
cmbCodeType.Items.Add("QR Code");
cmbCodeType.SelectedIndex = 0;
}
string filePath = path + cmbCodeType.Text + ".dcm";
txtParamPath.Text = filePath;
cmbCount.SelectedIndex = 0;
timer1.Start();
}
private void FrmCamera_FormClosed(object sender, FormClosedEventArgs e)
{
if (btnStop.Enabled.Equals(true))
{
btnStop_Click(null, null);
LogUtil.logBox = null;
FormStatus(false);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (HDevelopCodeLearn.IsRun)
{
if (btnOpen.Enabled)
{
btnOpen.Enabled = false ;
}
}
else
{
if (btnOpen.Enabled.Equals(false))
{
btnOpen.Enabled = true;
}
}
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void cmbCodeType_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbCodeType.SelectedIndex >= 0)
{
string filePath = path + cmbCodeType.Text + ".dcm";
txtParamPath.Text = filePath;
}
}
private void btnClearLog_Click(object sender, EventArgs e)
{
LogUtil.ClearLog();
}
}
}