geboshi_V1/LeatherProject/LeatherApp/Page/WaitFMFrm.cs

123 lines
4.9 KiB
C#

using DocumentFormat.OpenXml.Bibliography;
using DocumentFormat.OpenXml.Office2010.ExcelAc;
using Models;
using OpenCvSharp;
using S7.Net.Types;
using Sunny.UI;
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;
namespace LeatherApp.Page
{
public partial class WaitFMFrm : UIEditForm
{
public List<DefectInfo> lastWaitlst;
private List<DefectInfo> Fmlst = new List<DefectInfo>();
public string[] FMInfo = new string[4];
public WaitFMFrm(List<DefectInfo> Waitlst)
{
InitializeComponent();
#region dataGridView设置
uiDataGridView1.AllowUserToAddRows = uiDataGridView1.AllowUserToDeleteRows = false;//用户添加删除行
uiDataGridView1.AllowUserToResizeRows = false;//用户调整行大小
uiDataGridView1.AllowUserToResizeColumns = false;//用户调整列大小
uiDataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;//只可选中整行,不是单元格
//显示行号与列宽度自动调整
uiDataGridView1.RowHeadersVisible = true;
uiDataGridView1.RowHeadersWidth = 60;
uiDataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
uiDataGridView1.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;//数据量过百绑定太变
uiDataGridView1.RowPostPaint += (sender, e) =>//序号列头
{
Utils.Util.showRowNum_onDataGrid_RowPostPaint(this.uiDataGridView1, sender, e);
};
for (int i = 0; i < uiDataGridView1.Columns.Count; i++)//禁止点击列头排序
uiDataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
#endregion
lastWaitlst = Waitlst;
InitFrm(Waitlst);
//模拟计算让码数
double ydis = Math.Round((Waitlst[Waitlst.Count - 1].CentreY - Waitlst[0].CentreY) / 100.0f, 2);
int bs = (int)(ydis / 0.2) + 1;
numFMLen.Text = (0.2 * bs).ToString("0.00");
}
private void InitFrm(List<DefectInfo> Waitlst)
{
List<object[]> dataRowlist = new List<object[]>();
foreach (DefectInfo info in Waitlst)
{
dataRowlist.Add(new object[]{ true, info.PhotoIndex,info.Name,
info.CentreX, info.CentreY / 100,info.Width * 10,info.Height * 10, info.Area * 100});
}
int index = 0;
foreach (var rowItem in dataRowlist)
this.uiDataGridView1.Rows.Insert(index++, rowItem);
}
private void btnOK_Click(object sender, EventArgs e)
{
//加入放码队列
for (int i = 0; i < this.uiDataGridView1.Rows.Count; i++)
{
if ((bool)this.uiDataGridView1.Rows[i].Cells["ChkCol"].Value)
Fmlst.Add(lastWaitlst[i]);
else
continue;
}
//从待定队列移除
foreach (var item in Fmlst)
{
lastWaitlst.Remove(item);
}
if (Fmlst.Count > 0)
{
//生成放码信息
string str1 = "";
string str2 = "";
string str3 = "";
List<JDefectTotal> DefectTotal = Fmlst.GroupBy(x => x.Name).Select(g => new JDefectTotal { Name = g.Key, Count = g.Count() }).ToList();
if (DefectTotal != null && DefectTotal.Count > 0)
{
foreach (var dit in DefectTotal)
{
//str += $"{dit.Name}{dit.Count}个,";
str1 += $"{dit.Name},";
str2 += $"{dit.Count},";
str3 += $"{numFMLen.Text},";
}
//str.Remove(str.Length - 1, 1)
FMInfo[0] = str1.Remove(str1.Length - 1, 1);
FMInfo[1] = str2.Remove(str2.Length - 1, 1);
FMInfo[2] = str3.Remove(str3.Length - 1, 1);
FMInfo[3] = (Fmlst[0].CentreY /100).ToString("0.00");
}
}
this.Close();
}
public class JDefectTotal
{
[Description("疵点名")]
public string Name { get; set; }
[Description("疵点数")]
public int Count { get; set; }
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}