using Bro.Common.Helper;
|
using Bro.Common.Interface;
|
using Bro.M141.Process;
|
using Bro.UI.Model.Winform;
|
|
namespace Bro.M135.Process.UI
|
{
|
//[MenuNode("ProductStatus", "检测状态显示界面", 1, EnumHelper.TopMenu.SystemInfo, MenuNodeType.Form)]
|
public partial class FrmProductStatus : MenuFormBase
|
{
|
M141Process M141Process => Process as M141Process;
|
M141Config M141Config => Process.IConfig as M141Config;
|
|
List<CtrlPositionDisplay> displayCtrls = new List<CtrlPositionDisplay>();
|
|
const string RESULTSUMMARY = "结果汇总";
|
|
public FrmProductStatus()
|
{
|
InitializeComponent();
|
}
|
|
public override void OnProcessUpdated()
|
{
|
if (M141Process != null)
|
{
|
tbMain.Controls.Clear();
|
|
List<int> productIndexsList = M141Config.MeasureBindCollection.SelectMany(s => s.ProductIndices).Distinct().ToList();
|
|
//根据当前工位配置和产品索引配置,来刷新界面UI的行列数
|
tbMain.RowStyles.Clear();
|
tbMain.ColumnStyles.Clear();
|
|
tbMain.RowCount = 0;
|
tbMain.ColumnCount = productIndexsList.Count * (M141Config.WorkPositionCollection.Count() + 1);
|
RowStyle rowStyle = new RowStyle(SizeType.Percent, (float)100);
|
for (int i = 0; i < tbMain.ColumnCount; i++)
|
{
|
ColumnStyle columnStyle = new ColumnStyle(SizeType.Percent, (float)(1.0 / tbMain.ColumnCount));
|
tbMain.ColumnStyles.Add(columnStyle);
|
}
|
|
List<int> rows = new List<int>();
|
List<int> columns = new List<int>();
|
for (int i = 0; i < productIndexsList.Count * (M141Config.WorkPositionCollection.Count() + 2); i++)
|
{
|
rows.Add(0);
|
columns.Add(i);
|
}
|
|
int index = 0;
|
M141Config.WorkPositionCollection.ToList().ForEach(u =>
|
{
|
////产品1
|
//CtrlPositionDisplay c1 = new CtrlPositionDisplay(u.PositionName + "_1", M141Config.BackgroundImageFilePath);
|
//c1.Dock = DockStyle.Fill;
|
//tbMain.Controls.Add(c1, columns[index], rows[index]);
|
//displayCtrls.Add(c1);
|
//index++;
|
|
////产品2
|
//CtrlPositionDisplay c2 = new CtrlPositionDisplay(u.PositionName + "_2", M141Config.BackgroundImageFilePath);
|
//c2.Dock = DockStyle.Fill;
|
//tbMain.Controls.Add(c2, columns[index], rows[index]);
|
//displayCtrls.Add(c2);
|
//index++;
|
|
productIndexsList.ForEach(f =>
|
{
|
CtrlPositionDisplay c = new CtrlPositionDisplay(u.PositionName + $"_{f}", M141Config.BackgroundImageFilePath);
|
c.Dock = DockStyle.Fill;
|
tbMain.Controls.Add(c, columns[index], rows[index]);
|
displayCtrls.Add(c);
|
index++;
|
});
|
});
|
|
////产品1
|
//CtrlPositionDisplay c1 = new CtrlPositionDisplay(RESULTSUMMARY + "_1", M141Config.BackgroundImageFilePath);
|
//tbMain.Controls.Add(c1, 3, 0);
|
//displayCtrls.Add(c1);
|
|
////产品2
|
//CtrlPositionDisplay c2 = new CtrlPositionDisplay(RESULTSUMMARY + "_2", M141Config.BackgroundImageFilePath);
|
//tbMain.Controls.Add(c2, 3, 1);
|
//displayCtrls.Add(c2);
|
|
productIndexsList.ForEach(f =>
|
{
|
CtrlPositionDisplay c = new CtrlPositionDisplay(RESULTSUMMARY + $"_{f}", M141Config.BackgroundImageFilePath);
|
c.Dock = DockStyle.Fill;
|
tbMain.Controls.Add(c, columns[index], rows[index]);
|
displayCtrls.Add(c);
|
index++;
|
});
|
|
M141Process.OnPositionResultUpdated -= M135Process_OnPositionResultUpdated;
|
M141Process.OnPositionResultUpdated += M135Process_OnPositionResultUpdated;
|
}
|
}
|
|
private void M135Process_OnPositionResultUpdated(string positionName, string productIndex, List<IShapeElement> eleList)
|
{
|
var c = displayCtrls.FirstOrDefault(u => u.PositionName == positionName + "_" + productIndex);
|
if (c == null)
|
{
|
c = displayCtrls.FirstOrDefault(u => u.PositionName == RESULTSUMMARY + "_" + productIndex);
|
}
|
|
if (c == null)
|
{
|
LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"工位{positionName},产品序号{productIndex}未能获取显示控件");
|
}
|
else
|
{
|
c.UpdateProductResult(eleList);
|
}
|
}
|
|
|
//将界面产品二维码数据更新到配置中
|
public void M135Process_OnSetProductBarcodeToSetting(bool a)
|
{
|
//if (textBox_ProductABarcode.Text != "")
|
//{
|
if (label_AcupointA.Text.Split("-")[1] == "1")
|
{
|
M141Config.BarcodeDataList.Add(textBox_ProductABarcode.Text.ToString());
|
M141Config.BarcodeDataList.Add(textBox_ProductBBarcode.Text.ToString());
|
}
|
else
|
{
|
M141Config.BarcodeDataList.Add(textBox_ProductBBarcode.Text.ToString());
|
M141Config.BarcodeDataList.Add(textBox_ProductABarcode.Text.ToString());
|
}
|
//}
|
}
|
|
//将界面产品二维码数据清空,同时清空配置里的数据
|
public void M135Process_OnClearProductBarcodeForSettingAndInterface(bool a)
|
{
|
M141Config.BarcodeDataList.Clear();
|
textBox_ProductABarcode.Text = textBox_ProductBBarcode.Text = "";
|
}
|
public override void OnCustomizedLoad()
|
{
|
base.OnCustomizedLoad();
|
}
|
|
public override void OnCustomizedDispose()
|
{
|
base.OnCustomizedDispose();
|
|
M141Process.OnPositionResultUpdated -= M135Process_OnPositionResultUpdated;
|
}
|
}
|
}
|