FrmBoardCopy.cs
4.7 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
using log4net;
using URSoldering.Common;
using URSoldering.DeviceLibrary;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using URSoldering.Common.util;
using System.IO;
using System.Drawing.Drawing2D;
using URSoldering.LoadCSVLibrary;
namespace URSoldering.Client
{
public partial class FrmBoardCopy : FrmBase
{
private BoardInfo oldBoard = null;
public static readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public FrmBoardCopy(BoardInfo board)
{
oldBoard = board;
InitializeComponent();
this.Text = "复制程序【" + oldBoard.PartNumber + "】的程序";
}
private void FrmBoardInfo_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
txtBoardName.Focus();
LoadBoardInfo();
}
private void LoadBoardInfo()
{
string suffix = "副本";
string newName = oldBoard.boardName + suffix;
txtBoardName.Text = newName;
//txtRobotZHighValue.Text = oldBoard.ZHighValue.ToString();
}
private void btnBack_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
string newName = FormUtil.getValue(txtBoardName);
string newCode = FormUtil.getValue(txtCode);
if (newName.Equals(""))
{
MessageBox.Show("请输入程序名称");
txtBoardName.Focus();
return;
}
//判断是否重名
if (BoardManager.getBoardByName(newName) != null)
{
MessageBox.Show("程序名称【" + newName + "】已存在,复制失败!");
return;
}
BoardInfo newBoard = new BoardInfo();
//newBoard.boardCode = oldBoard.boardCode;
newBoard.boardId = BoardManager.GetNextId();
newBoard.boardLength = oldBoard.boardLength;
newBoard.boardWidth = oldBoard.boardWidth;
newBoard.boardName = newName;
newBoard.planNeedTime = oldBoard.planNeedTime;
newBoard.pointList = new List<WeldPointInfo>(oldBoard.pointList);
newBoard.solderCount = oldBoard.solderCount;
newBoard.solderingCount = oldBoard.solderingCount;
newBoard.solderingTime = oldBoard.solderingTime;
newBoard.solderTime = oldBoard.solderTime;
newBoard.imgName = oldBoard.imgName;
//newBoard.orgType = oldBoard.orgType;
//newBoard.originX = oldBoard.originX;
//newBoard.originY = oldBoard.originY;
newBoard.AoiFileName=oldBoard.AoiFileName;
//newBoard.ZHighValue = newZHigh;
try
{
if (!oldBoard.imgName.Contains(oldBoard.boardName))
{
string oldName = oldBoard.imgName;
string newImgName = oldBoard.boardName + Path.GetExtension(oldName);
string configPath = ConfigAppSettings.GetValue(Setting_Init.BOARD_IMAGE_PATH);
string oldPath = Application.StartupPath + "/" + configPath + "/" + oldName;
string newPath = Application.StartupPath + "/" + configPath + "/" + newImgName;
if (File.Exists(oldPath))
{
File.Copy(oldPath, newPath, true);
}
newBoard.imgName = newImgName;
newBoard.myImage = null;
}
}
catch (Exception ex)
{
LogUtil.error("更新程序名时更改图片出错:" + ex.ToString());
}
BoardManager.Add(newBoard);
MessageBox.Show("新增程序【" + newName + "】成功!");
this.DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception ex)
{
LogUtil.error("保存复制的程序出错:" + ex.ToString());
}
}
}
}