Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
URSolderingRobot
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 471dbe78
由
几米阳光
编写于
2018-12-18 13:37:58 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
增加程序导入导出功能
1 个父辈
68fc4aca
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
212 行增加
和
97 行删除
DeviceLibrary/bean/BoardManager.cs
URSolderingClient/FrmBoardList.Designer.cs
URSolderingClient/FrmBoardList.cs
URSolderingClient/FrmBoardList.resx
DeviceLibrary/bean/BoardManager.cs
查看文件 @
471dbe7
...
...
@@ -64,72 +64,34 @@ namespace URSoldering.DeviceLibrary
boardList
=
new
List
<
BoardInfo
>();
List
<
int
>
idList
=
new
List
<
int
>();
List
<
string
>
nameList
=
new
List
<
string
>();
foreach
(
string
str
in
lines
)
{
try
{
string
newStr
=
str
;
string
errMsg
=
"\"System.Drawing.Bitmap\""
;
if
(
str
.
Contains
(
errMsg
))
{
newStr
=
str
.
Replace
(
errMsg
,
"null"
);
}
BoardInfo
board
=
JsonHelper
.
DeserializeJsonToObject
<
BoardInfo
>(
newStr
);
bool
isUpdate
=
false
;
if
(
board
!=
null
)
{
if
(
board
.
boardId
>
MaxId
)
{
MaxId
=
board
.
boardId
;
}
if
(
idList
.
Contains
(
board
.
boardId
))
{
LogUtil
.
error
(
"加载产品配置出错:id="
+
board
.
boardId
+
"的数据重复!"
);
}
if
(
nameList
.
Contains
(
board
.
boardName
))
{
LogUtil
.
error
(
"加载产品配置出错:name="
+
board
.
boardName
+
"的数据重复!"
);
}
//如果料号是空,用产品名称作为料号
if
(
board
.
PartNumber
==
null
){
board
.
PartNumber
=
board
.
boardName
;
isUpdate
=
true
;
}
if
(
board
.
WareCode
==
null
)
{
board
.
WareCode
=
""
;
}
if
(
board
.
APointValue
==
null
)
{
board
.
APointValue
=
new
URPointValue
();
board
.
BPointValue
=
new
URPointValue
();
board
.
CPointValue
=
new
URPointValue
();
board
.
DPointValue
=
new
URPointValue
();
isUpdate
=
true
;
}
idList
.
Add
(
board
.
boardId
);
nameList
.
Add
(
board
.
boardName
);
if
(
board
.
boardId
.
Equals
(
CurrBoardId
))
{
LogUtil
.
info
(
"加载产品配置:name="
+
board
.
boardName
+
"为启动时的默认板子!"
);
CurrBoard
=
board
;
}
//if (board.orgType == 0)
//{
// board.orgType = 1;
//}
boardList
.
Add
(
board
);
}
if
(
isUpdate
)
{
SaveListToFile
(
boardList
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错:"
+
ex
.
ToString
());
}
}
foreach
(
string
str
in
lines
)
{
bool
IsNeedUpdate
=
false
;
BoardInfo
board
=
StringToBoard
(
str
,
out
IsNeedUpdate
);
if
(
board
!=
null
)
{
if
(
idList
.
Contains
(
board
.
boardId
))
{
LogUtil
.
error
(
"加载产品配置出错:id="
+
board
.
boardId
+
"的数据重复!"
);
}
if
(
nameList
.
Contains
(
board
.
boardName
))
{
LogUtil
.
error
(
"加载产品配置出错:name="
+
board
.
boardName
+
"的数据重复!"
);
}
idList
.
Add
(
board
.
boardId
);
nameList
.
Add
(
board
.
boardName
);
if
(
board
.
boardId
.
Equals
(
CurrBoardId
))
{
LogUtil
.
info
(
"加载产品配置:name="
+
board
.
boardName
+
"为启动时的默认板子!"
);
CurrBoard
=
board
;
}
boardList
.
Add
(
board
);
if
(
IsNeedUpdate
)
{
SaveListToFile
(
boardList
);
}
}
}
string
path
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
BOARD_IMAGE_PATH
);
string
imagePath
=
Application
.
StartupPath
+
"/"
+
path
+
"/"
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
BOARD_IMAGE_DEFAULT
);
...
...
@@ -160,6 +122,53 @@ namespace URSoldering.DeviceLibrary
}
}
public
static
BoardInfo
StringToBoard
(
string
str
,
out
bool
IsNeedUpdate
)
{
IsNeedUpdate
=
false
;
BoardInfo
board
=
null
;
try
{
string
newStr
=
str
;
string
errMsg
=
"\"System.Drawing.Bitmap\""
;
if
(
str
.
Contains
(
errMsg
))
{
newStr
=
str
.
Replace
(
errMsg
,
"null"
);
}
board
=
JsonHelper
.
DeserializeJsonToObject
<
BoardInfo
>(
newStr
);
// bool isUpdate = false;
if
(
board
!=
null
)
{
if
(
board
.
boardId
>
MaxId
)
{
MaxId
=
board
.
boardId
;
}
//如果料号是空,用产品名称作为料号
if
(
board
.
PartNumber
==
null
)
{
board
.
PartNumber
=
board
.
boardName
;
IsNeedUpdate
=
true
;
}
if
(
board
.
WareCode
==
null
)
{
board
.
WareCode
=
""
;
}
if
(
board
.
APointValue
==
null
)
{
board
.
APointValue
=
new
URPointValue
();
board
.
BPointValue
=
new
URPointValue
();
board
.
CPointValue
=
new
URPointValue
();
board
.
DPointValue
=
new
URPointValue
();
IsNeedUpdate
=
true
;
}
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"出错:"
+
ex
.
ToString
());
}
return
board
;
}
public
static
void
Update
(
BoardInfo
board
)
{
int
index
=
0
;
...
...
URSolderingClient/FrmBoardList.Designer.cs
查看文件 @
471dbe7
...
...
@@ -50,6 +50,8 @@
this
.
txtBoardName
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
btnExport
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnImport
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnCopy
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnBack
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnDel
=
new
System
.
Windows
.
Forms
.
Button
();
...
...
@@ -57,6 +59,7 @@
this
.
btnNew
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
cmbBoardList
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
label1
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
openFileDialog1
=
new
System
.
Windows
.
Forms
.
OpenFileDialog
();
this
.
panel1
.
SuspendLayout
();
this
.
groupBox2
.
SuspendLayout
();
this
.
panBoard
.
SuspendLayout
();
...
...
@@ -72,7 +75,7 @@
this
.
panel1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panel1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panel1
.
Name
=
"panel1"
;
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
1
012
,
626
);
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
1
220
,
626
);
this
.
panel1
.
TabIndex
=
2
;
//
// groupBox2
...
...
@@ -101,7 +104,7 @@
this
.
groupBox2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
71
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
997
,
541
);
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
1205
,
541
);
this
.
groupBox2
.
TabIndex
=
1
;
this
.
groupBox2
.
TabStop
=
false
;
this
.
groupBox2
.
Text
=
"程序信息"
;
...
...
@@ -184,7 +187,7 @@
this
.
label6
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
label6
.
AutoSize
=
true
;
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(-
1
269
,
23
);
this
.
label6
.
Location
=
new
System
.
Drawing
.
Point
(-
1
061
,
23
);
this
.
label6
.
Name
=
"label6"
;
this
.
label6
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
17
);
this
.
label6
.
TabIndex
=
33
;
...
...
@@ -199,7 +202,7 @@
this
.
panBoard
.
Controls
.
Add
(
this
.
picBoard
);
this
.
panBoard
.
Location
=
new
System
.
Drawing
.
Point
(
601
,
21
);
this
.
panBoard
.
Name
=
"panBoard"
;
this
.
panBoard
.
Size
=
new
System
.
Drawing
.
Size
(
389
,
502
);
this
.
panBoard
.
Size
=
new
System
.
Drawing
.
Size
(
597
,
502
);
this
.
panBoard
.
TabIndex
=
10
;
//
// picBoard
...
...
@@ -210,7 +213,7 @@
this
.
picBoard
.
BackColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
picBoard
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
3
);
this
.
picBoard
.
Name
=
"picBoard"
;
this
.
picBoard
.
Size
=
new
System
.
Drawing
.
Size
(
316
,
225
);
this
.
picBoard
.
Size
=
new
System
.
Drawing
.
Size
(
524
,
225
);
this
.
picBoard
.
SizeMode
=
System
.
Windows
.
Forms
.
PictureBoxSizeMode
.
StretchImage
;
this
.
picBoard
.
TabIndex
=
10
;
this
.
picBoard
.
TabStop
=
false
;
...
...
@@ -287,6 +290,8 @@
//
this
.
groupBox1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnExport
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnImport
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnCopy
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnBack
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnDel
);
...
...
@@ -297,14 +302,34 @@
this
.
groupBox1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
5
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
998
,
60
);
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
1206
,
60
);
this
.
groupBox1
.
TabIndex
=
0
;
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"程序管理"
;
//
// btnExport
//
this
.
btnExport
.
Location
=
new
System
.
Drawing
.
Point
(
926
,
16
);
this
.
btnExport
.
Name
=
"btnExport"
;
this
.
btnExport
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnExport
.
TabIndex
=
9
;
this
.
btnExport
.
Text
=
"导出"
;
this
.
btnExport
.
UseVisualStyleBackColor
=
true
;
this
.
btnExport
.
Click
+=
new
System
.
EventHandler
(
this
.
btnExport_Click
);
//
// btnImport
//
this
.
btnImport
.
Location
=
new
System
.
Drawing
.
Point
(
803
,
16
);
this
.
btnImport
.
Name
=
"btnImport"
;
this
.
btnImport
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnImport
.
TabIndex
=
8
;
this
.
btnImport
.
Text
=
"导入"
;
this
.
btnImport
.
UseVisualStyleBackColor
=
true
;
this
.
btnImport
.
Click
+=
new
System
.
EventHandler
(
this
.
btnImport_Click
);
//
// btnCopy
//
this
.
btnCopy
.
Location
=
new
System
.
Drawing
.
Point
(
6
94
,
16
);
this
.
btnCopy
.
Location
=
new
System
.
Drawing
.
Point
(
6
80
,
16
);
this
.
btnCopy
.
Name
=
"btnCopy"
;
this
.
btnCopy
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnCopy
.
TabIndex
=
7
;
...
...
@@ -315,7 +340,7 @@
// btnBack
//
this
.
btnBack
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnBack
.
Location
=
new
System
.
Drawing
.
Point
(
865
,
15
);
this
.
btnBack
.
Location
=
new
System
.
Drawing
.
Point
(
1073
,
16
);
this
.
btnBack
.
Name
=
"btnBack"
;
this
.
btnBack
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnBack
.
TabIndex
=
6
;
...
...
@@ -325,7 +350,7 @@
//
// btnDel
//
this
.
btnDel
.
Location
=
new
System
.
Drawing
.
Point
(
5
70
,
16
);
this
.
btnDel
.
Location
=
new
System
.
Drawing
.
Point
(
5
57
,
16
);
this
.
btnDel
.
Name
=
"btnDel"
;
this
.
btnDel
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnDel
.
TabIndex
=
5
;
...
...
@@ -335,7 +360,7 @@
//
// btnSave
//
this
.
btnSave
.
Location
=
new
System
.
Drawing
.
Point
(
4
46
,
16
);
this
.
btnSave
.
Location
=
new
System
.
Drawing
.
Point
(
4
34
,
16
);
this
.
btnSave
.
Name
=
"btnSave"
;
this
.
btnSave
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnSave
.
TabIndex
=
4
;
...
...
@@ -345,7 +370,7 @@
//
// btnNew
//
this
.
btnNew
.
Location
=
new
System
.
Drawing
.
Point
(
3
22
,
16
);
this
.
btnNew
.
Location
=
new
System
.
Drawing
.
Point
(
3
11
,
16
);
this
.
btnNew
.
Name
=
"btnNew"
;
this
.
btnNew
.
Size
=
new
System
.
Drawing
.
Size
(
117
,
35
);
this
.
btnNew
.
TabIndex
=
3
;
...
...
@@ -357,7 +382,7 @@
//
this
.
cmbBoardList
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbBoardList
.
FormattingEnabled
=
true
;
this
.
cmbBoardList
.
Location
=
new
System
.
Drawing
.
Point
(
85
,
22
);
this
.
cmbBoardList
.
Location
=
new
System
.
Drawing
.
Point
(
77
,
22
);
this
.
cmbBoardList
.
Name
=
"cmbBoardList"
;
this
.
cmbBoardList
.
Size
=
new
System
.
Drawing
.
Size
(
207
,
25
);
this
.
cmbBoardList
.
TabIndex
=
1
;
...
...
@@ -377,7 +402,7 @@
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
7F
,
17F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
AutoSize
=
true
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
012
,
626
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
220
,
626
);
this
.
Controls
.
Add
(
this
.
panel1
);
this
.
Name
=
"FrmBoardList"
;
this
.
Text
=
"程序配置"
;
...
...
@@ -426,5 +451,8 @@
private
System
.
Windows
.
Forms
.
Button
btnCopy
;
private
System
.
Windows
.
Forms
.
TextBox
txtAOIName
;
private
System
.
Windows
.
Forms
.
Label
label10
;
private
System
.
Windows
.
Forms
.
Button
btnExport
;
private
System
.
Windows
.
Forms
.
Button
btnImport
;
private
System
.
Windows
.
Forms
.
OpenFileDialog
openFileDialog1
;
}
}
\ No newline at end of file
URSolderingClient/FrmBoardList.cs
查看文件 @
471dbe7
...
...
@@ -9,6 +9,8 @@ using System.Reflection;
using
System.Windows.Forms
;
using
URSoldering.Common
;
using
System.Drawing.Drawing2D
;
using
System.IO
;
using
System.Text
;
namespace
URSoldering.Client
{
...
...
@@ -21,13 +23,13 @@ namespace URSoldering.Client
}
private
void
FrmBoard_Load
(
object
sender
,
EventArgs
e
)
{
{
LoadCom
();
}
private
void
AddColumn
(
string
text
,
int
width
)
private
void
AddColumn
(
string
text
,
int
width
)
{
ColumnHeader
chName
=
new
ColumnHeader
();
chName
.
Text
=
text
;
//设置列标题
chName
.
Text
=
text
;
//设置列标题
chName
.
Width
=
width
;
//设置列宽度
chName
.
TextAlign
=
HorizontalAlignment
.
Left
;
//设置列的对齐方式
this
.
listPoint
.
Columns
.
Add
(
chName
);
//将列头添加到ListView控件。
...
...
@@ -49,7 +51,7 @@ namespace URSoldering.Client
AddColumn
(
"预热温度"
,
90
);
AddColumn
(
"焊接温度"
,
90
);
AddColumn
(
"初始送丝"
,
90
);
AddColumn
(
"送丝量"
,
80
);
AddColumn
(
"送丝量"
,
80
);
}
private
void
btnSave_Click
(
object
sender
,
EventArgs
e
)
{
...
...
@@ -98,6 +100,9 @@ namespace URSoldering.Client
}
}
int
preId
=
-
1
;
public
object
ResourceCulture
{
get
;
private
set
;
}
private
void
LoadPoint
(
BoardInfo
board
)
{
if
(
preId
>=
0
&&
preId
.
Equals
(
board
.
boardId
))
...
...
@@ -114,10 +119,10 @@ namespace URSoldering.Client
lvi
.
Text
=
point
.
pointName
;
lvi
.
SubItems
.
Add
(
point
.
TypeValue
);
lvi
.
SubItems
.
Add
(
point
.
preheatTemperature
.
ToString
()+
"°C"
);
lvi
.
SubItems
.
Add
(
point
.
preheatTemperature
.
ToString
()
+
"°C"
);
lvi
.
SubItems
.
Add
(
point
.
weldTemperature
.
ToString
()
+
"°C"
);
lvi
.
SubItems
.
Add
((
point
.
startSendWireSpeed
*
point
.
startSendWireTime
).
ToString
()
+
"mm"
);
lvi
.
SubItems
.
Add
((
point
.
sendWireTime
*
point
.
sendWireSpeed
).
ToString
()
+
"mm"
);
lvi
.
SubItems
.
Add
((
point
.
startSendWireSpeed
*
point
.
startSendWireTime
).
ToString
()
+
"mm"
);
lvi
.
SubItems
.
Add
((
point
.
sendWireTime
*
point
.
sendWireSpeed
).
ToString
()
+
"mm"
);
this
.
listPoint
.
Items
.
Add
(
lvi
);
i
++;
}
...
...
@@ -145,7 +150,7 @@ namespace URSoldering.Client
if
(
cmbBoardList
.
Text
!=
""
&&
cmbBoardList
.
SelectedIndex
>=
0
)
{
BoardInfo
board
=
(
BoardInfo
)
cmbBoardList
.
SelectedItem
;
if
(
MessageBox
.
Show
(
"确认要删除程序【"
+
board
.
boardName
+
"】吗?"
,
"删除确认"
,
MessageBoxButtons
.
OKCancel
,
MessageBoxIcon
.
Question
).
Equals
(
DialogResult
.
OK
))
...
...
@@ -162,7 +167,7 @@ namespace URSoldering.Client
MessageBox
.
Show
(
"请选择程序!"
);
}
}
private
void
GetPicPointByUrPoint
(
BoardInfo
boardInfo
,
URPointValue
point
,
out
float
x
,
out
float
y
)
private
void
GetPicPointByUrPoint
(
BoardInfo
boardInfo
,
URPointValue
point
,
out
float
x
,
out
float
y
)
{
int
width
=
picBoard
.
Width
;
int
height
=
picBoard
.
Height
;
...
...
@@ -174,13 +179,13 @@ namespace URSoldering.Client
//判断AD点是否有效
if
(
APointValue
.
IsValid
()
&&
DPointValue
.
IsValid
())
{
x
=
(
float
)((
point
.
X
-
APointValue
.
X
)
*
width
/
(
DPointValue
.
X
-
APointValue
.
X
));
y
=
(
float
)((
point
.
Y
-
APointValue
.
Y
)
*
height
/
(
DPointValue
.
Y
-
APointValue
.
Y
));
x
=
(
float
)((
point
.
X
-
APointValue
.
X
)
*
width
/
(
DPointValue
.
X
-
APointValue
.
X
));
y
=
(
float
)((
point
.
Y
-
APointValue
.
Y
)
*
height
/
(
DPointValue
.
Y
-
APointValue
.
Y
));
}
else
if
(
BPointValue
.
IsValid
()
&&
CPointValue
.
IsValid
())
{
x
=
(
float
)((
point
.
X
-
BPointValue
.
X
)
*
width
/
(
CPointValue
.
X
-
BPointValue
.
X
));
y
=
(
float
)((
point
.
Y
-
CPointValue
.
Y
)
*
height
/
(
BPointValue
.
Y
-
CPointValue
.
Y
));
x
=
(
float
)((
point
.
X
-
BPointValue
.
X
)
*
width
/
(
CPointValue
.
X
-
BPointValue
.
X
));
y
=
(
float
)((
point
.
Y
-
CPointValue
.
Y
)
*
height
/
(
BPointValue
.
Y
-
CPointValue
.
Y
));
}
else
{
...
...
@@ -221,7 +226,7 @@ namespace URSoldering.Client
picBoard
.
Image
=
board
.
GetImage
();
picBoard
.
Refresh
();
Graphics
grfx
=
picBoard
.
CreateGraphics
();
float
preX
=
0
;
float
preY
=
0
;
...
...
@@ -230,7 +235,7 @@ namespace URSoldering.Client
{
int
pointHight
=
16
;
float
x
,
y
;
GetPicPointByUrPoint
(
board
,
weld
.
GetURPoint
(),
out
x
,
out
y
);
GetPicPointByUrPoint
(
board
,
weld
.
GetURPoint
(),
out
x
,
out
y
);
LogUtil
.
debug
(
"显示焊点:X【"
+
x
+
"】Y【"
+
y
+
"】,坐标X【"
+
weld
.
RobotX
+
"】坐标Y【"
+
weld
.
RobotY
+
"】"
);
g
.
FillEllipse
(
Brushes
.
Red
,
x
-
pointHight
/
2
,
y
-
pointHight
/
2
,
pointHight
,
pointHight
);
...
...
@@ -247,7 +252,7 @@ namespace URSoldering.Client
grfx
.
DrawLine
(
RedPen
,
preX
,
preY
,
xCenter
,
yCenter
);
grfx
.
DrawLine
(
p
,
preX
,
preY
,
x
,
y
);
}
}
//写字
g
.
DrawString
(
weld
.
pointName
,
new
Font
(
"Arial "
,
10
,
FontStyle
.
Bold
),
Brushes
.
Red
,
x
-
pointHight
/
2
,
y
+
pointHight
/
2
+
2
);
preX
=
x
;
...
...
@@ -296,5 +301,78 @@ namespace URSoldering.Client
}
}
private
void
btnExport_Click
(
object
sender
,
EventArgs
e
)
{
if
(
cmbBoardList
.
Text
!=
""
&&
cmbBoardList
.
SelectedIndex
>=
0
)
{
BoardInfo
board
=
(
BoardInfo
)
cmbBoardList
.
SelectedItem
;
SaveFileDialog
sfd
=
new
SaveFileDialog
();
sfd
.
InitialDirectory
=
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
DesktopDirectory
);
sfd
.
FileName
=
"程序-"
+
board
.
boardName
+
"-"
+
DateTime
.
Now
.
ToString
(
"yyyy:MM:dd:HH:mm"
).
Replace
(
":"
,
""
);
sfd
.
Filter
=
@"data|*.data"
;
DialogResult
result
=
sfd
.
ShowDialog
();
if
(
result
.
Equals
(
DialogResult
.
OK
))
{
string
filePath
=
sfd
.
FileName
;
{
if
(
File
.
Exists
(
filePath
))
{
File
.
Delete
(
filePath
);
}
File
.
WriteAllText
(
filePath
,
JsonHelper
.
SerializeObject
(
board
),
Encoding
.
GetEncoding
(
"gbk"
));
MessageBox
.
Show
(
"成功导出程序【"
+
board
.
boardName
+
"】到文件:\r\n"
+
filePath
,
"提示"
);
}
}
}
}
private
void
btnImport_Click
(
object
sender
,
EventArgs
e
)
{
openFileDialog1
.
InitialDirectory
=
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
DesktopDirectory
);
openFileDialog1
.
Filter
=
@"data|*.data"
;
DialogResult
result
=
this
.
openFileDialog1
.
ShowDialog
();
if
(
result
.
Equals
(
DialogResult
.
OK
))
{
string
fileName
=
this
.
openFileDialog1
.
FileName
;
string
[]
lines
=
File
.
ReadAllLines
(
fileName
,
Encoding
.
GetEncoding
(
"gbk"
));
if
(
lines
.
Length
<=
0
)
{
MessageBox
.
Show
(
"解析程序失败,请选择正确文件"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
bool
isNeedUpdate
=
false
;
BoardInfo
board
=
BoardManager
.
StringToBoard
(
lines
[
0
],
out
isNeedUpdate
);
if
(
board
==
null
)
{
MessageBox
.
Show
(
"解析程序失败,请选择正确文件"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
if
(
BoardManager
.
getBoardByName
(
board
.
boardName
)
!=
null
)
{
MessageBox
.
Show
(
"导入失败:程序名【"
+
board
.
boardName
+
"】已存在"
,
"提示"
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
string
oldName
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
BOARD_IMAGE_DEFAULT
);
string
newName
=
board
.
boardName
+
Path
.
GetExtension
(
oldName
);
string
configPath
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
BOARD_IMAGE_PATH
);
string
oldPath
=
Application
.
StartupPath
+
"/"
+
configPath
+
"/"
+
oldName
;
string
newPath
=
Application
.
StartupPath
+
"/"
+
configPath
+
"/"
+
newName
;
if
(
File
.
Exists
(
oldPath
))
{
File
.
Copy
(
oldPath
,
newPath
,
true
);
}
board
.
imgName
=
newName
;
board
.
boardId
=
BoardManager
.
GetNextId
();
BoardManager
.
Add
(
board
);
MessageBox
.
Show
(
"程序【"
+
board
.
boardName
+
"】导入成功"
,
"提示"
);
LoadCom
();
preId
=
-
1
;
}
}
}
}
URSolderingClient/FrmBoardList.resx
查看文件 @
471dbe7
...
...
@@ -117,7 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="
$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
">
<value>
True
</value>
<metadata name="
openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
">
<value>
17, 17
</value>
</metadata>
</root>
\ No newline at end of file
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论