FrmAOISetting.cs
5.8 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
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 System.IO;
// COM 组件接口
using System.Runtime.InteropServices;
using URSoldering.Common;
namespace URSoldering.Client
{
public partial class FrmAOISetting : FrmBase
{
FrmDebugMenu frmMean = null;
public FrmAOISetting(FrmDebugMenu frmMean)
{
this.frmMean = frmMean;
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
cmbPro.SelectedIndex = 0;
//位置配置到文件中
string appPath = Application.StartupPath;
string strFilePathName = ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string filePath = appPath + strFilePathName;
if (File.Exists(filePath))
{
axCKVisionCtrl1.LoadConfigure(filePath);
}
else
{
LogUtil.error("未找到文件:" + strFilePathName);
}
}
private void LOAD_FILE_Click(object sender, EventArgs e)
{
try
{
string filePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string path = Path.GetDirectoryName(filePath);
OpenFileDialog openfileDlg = new OpenFileDialog();
openfileDlg.InitialDirectory = path;
openfileDlg.Filter = "vscf files (*.vscf)|*.vscf";
openfileDlg.FilterIndex = 1;
openfileDlg.RestoreDirectory = true;
if (openfileDlg.ShowDialog() == DialogResult.OK)
{
string strFilePathName = openfileDlg.FileName.ToString();
axCKVisionCtrl1.LoadConfigure(strFilePathName);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
private void SAVE_FILE_Click(object sender, EventArgs e)
{
try
{
string filePath = Application.StartupPath + ConfigAppSettings.GetValue(Setting_Init.AOIFileConfig);
string path = Path.GetDirectoryName(filePath);
SaveFileDialog savefileDlg = new SaveFileDialog();
savefileDlg.InitialDirectory = path;
savefileDlg.Filter = "ckcf files (*.vscf)|*.vscf";
savefileDlg.FilterIndex = 1;
savefileDlg.RestoreDirectory = true;
if (savefileDlg.ShowDialog() == DialogResult.OK)
{
string FilePathName = savefileDlg.FileName.ToString();
bool isSave = axCKVisionCtrl1.SaveConfigure(FilePathName);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not save file to the disk. Original error: " + ex.Message);
}
}
private void EDIT_PROC_Click(object sender, EventArgs e)
{
try
{
axCKVisionCtrl1.ShowEditor( "编辑流程", 0 );
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not edit proc. Original error: " + ex.Message);
}
}
private void EXECUTE_Click(object sender, EventArgs e)
{
try
{
int index = cmbPro.SelectedIndex;
axCKVisionCtrl1.Execute(index);
axCKVisionCtrl1.Redraw();
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not extcute proc. Original error: " + ex.Message);
}
}
private void GET_DATA_Click(object sender, EventArgs e)
{
string strToolName = textBox1.Text;
int idTool = axCKVisionCtrl1.GetTool(strToolName);
int DataId = Convert.ToInt32(textBox2.Text);
double value = 0.0;
object objValue = new VariantWrapper(value);
if (axCKVisionCtrl1.GetValue(idTool, DataId, 0, ref objValue) == true)
{
textBox3.Text = objValue.ToString().Substring(0,6);
}
else
{
MessageBox.Show("获取数据失败! ");
}
}
private void ZOOM_IN_Click(object sender, EventArgs e)
{
axCKVisionCtrl1.ZoomView(0);
axCKVisionCtrl1.Redraw();
}
private void ZOOM_OUT_Click(object sender, EventArgs e)
{
axCKVisionCtrl1.ZoomView(1);
axCKVisionCtrl1.Redraw();
}
private void ZOOM_FIT_Click(object sender, EventArgs e)
{
axCKVisionCtrl1.ZoomView(2);
axCKVisionCtrl1.Redraw();
}
private void ZOOM_1X1_Click(object sender, EventArgs e)
{
axCKVisionCtrl1.ZoomView(3);
axCKVisionCtrl1.Redraw();
}
private void TOOL_Property_Click(object sender, EventArgs e)
{
string strToolName = textBox1.Text;
int idTool = axCKVisionCtrl1.GetTool(strToolName);
axCKVisionCtrl1.ShowProperty(idTool );
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
axCKVisionCtrl1.UnloadConfigure();
frmMean.Visible = true;
}
private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
}
}