FrmBoardSelect.cs
6.5 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public partial class FrmBoardSelect : FrmBase
{
//1=插件,2=焊接,3=检测
public int WorkType = 1;
private bool IsInitOk = false;
public FrmBoardSelect()
{
InitializeComponent();
}
public FrmBoardSelect(int type)
{
this.WorkType = type;
InitializeComponent();
}
private void FrmBoardSelect_Load(object sender, EventArgs e)
{
SetSkin(this);
LanguageProcess();
LoadCom();
txtCode.Focus();
SetScreen();
IsInitOk = true;
}
private void LoadCom()
{
cmbBoardList.DataSource = null;
List<BoardInfo> list = new List<BoardInfo>(BoardManager.boardList);
BoardInfo board = new BoardInfo();
board.boardId = -1;
board.boardName = "";
list.Insert(0, board);
cmbBoardList.DataSource = list;
cmbBoardList.DisplayMember = "boardName";
cmbBoardList.ValueMember = "boardId";
}
int preIndex = -1;
private void cmbBoardList_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0&&(!cmbBoardList.SelectedIndex.Equals(preIndex)))
{
preIndex = cmbBoardList.SelectedIndex;
BoardInfo board = (BoardInfo)cmbBoardList.SelectedItem;
if (board.boardId.Equals(-1))
{
lblBoardMsg.Text = ResourceCulture.GetString(ResourceCulture.SelectP,"请选择程序");
lblBoardMsg.ForeColor = Color.Red;
return;
}
if (board != null)
{
lblBoardMsg.Text = board.GetDes();
this.lblBoardMsg.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(192)))));
BoardManager.CurrBoard = board;
LogUtil.info("切换到新板子:" + board.boardName);
FrmProjectorScreen.instance.ShowPoint(false,board.smtList.ToArray());
}
}
}
private void btnBack_Click(object sender, EventArgs e)
{
this.Close();
}
private void BtnNext_Click(object sender, EventArgs e)
{
if (this.cmbBoardList.SelectedIndex < 0)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ConfigProduct, "请先配置程序"));
this.Close();
}
else if (this.cmbBoardList.SelectedIndex.Equals(0))
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ConfigProduct, "请先选择程序"));
}
else
{
TSAVBean.OnlyGuoBan = chbGuoban.Checked;
LogUtil.info("选择程序,是否流水线过板=" + TSAVBean.OnlyGuoBan);
if (WorkType.Equals(1))
{
if (BoardManager.CurrBoard.smtList.Count <= 0)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.CanotFindInfo, "电路板【{0}】没有组装信息,请选择其他程序!", BoardManager.CurrBoard.boardName));
return;
}
WorkInfo.LastDBId = 0;
FrmWork fw = new FrmWork();
this.Hide();
fw.ShowDialog();
}
else if (WorkType.Equals(2))
{
if (BoardManager.CurrBoard.GetSolderingSMTList().Count <= 0)
{
MessageBox.Show("电路板【" + BoardManager.CurrBoard.boardName + "】没有配置焊接信息,请选择其他程序!");
return;
}
//FrmTSAVSoldering fw = new FrmTSAVSoldering();
//this.Hide();
//fw.ShowDialog();
}
else if (WorkType.Equals(3))
{
if (BoardManager.CurrBoard.GetCheckSMTList().Count <= 0)
{
MessageBox.Show("电路板【" + BoardManager.CurrBoard.boardName + "】没有配置检测信息,请选择其他程序!");
return;
}
//FrmCheck fw = new FrmCheck();
//this.Hide();
//fw.ShowDialog();
}
this.Close();
}
}
private void txtCode_TextChanged(object sender, EventArgs e)
{
string code = FormUtil.getValue(txtCode).Trim();
if (!code.Equals(""))
{
int index = -1;
List<BoardInfo> list = (from m in BoardManager.boardList where m.boardCode.Equals(code) select m).ToList<BoardInfo>();
if (list.Count > 0)
{
foreach (BoardInfo board in BoardManager.boardList)
{
index++;
if (board.boardCode.Equals(list[0].boardCode))
{
cmbBoardList.SelectedIndex = index + 1;
break;
}
}
}
else
{
cmbBoardList.SelectedIndex = 0;
}
}
else
{
cmbBoardList.SelectedIndex = 0;
}
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (!IsInitOk)
{
return base.ProcessCmdKey(ref msg, keyData); // 其他键按默认处理
}
//Enter键
if (keyData.Equals(Keys.Enter))
{
BtnNext_Click(null, null);
}
return base.ProcessCmdKey(ref msg, keyData); // 其他键按默认处理
}
private void FrmBoardSelect_Shown(object sender, EventArgs e)
{
txtCode.Focus();
}
}
}