M182轴承端盖外观缺陷AOI
kingno
2025-05-26 5a405c7dce20d8c79a733c9c786cc42eb59fe81c
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
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 Bro.M141.Process.UI
{
    public partial class CtrlDefectsInPosition : UserControl
    {
        public CtrlDefectsInPosition()
        {
            InitializeComponent();
        }
 
        List<DefectPositionSet> PositionDefects = new List<DefectPositionSet>();
        public string PositionNum { get; set; }
 
 
        public string ProduceNum { get; set; }
 
        List<string> AllDefects = new List<string>();
 
        public CtrlDefectsInPosition(List<string> allDefects, string positionNum, List<DefectPositionSet> positionDefects, string produceNum)
        {
            InitializeComponent();
 
            PositionDefects = positionDefects;
            PositionNum = positionNum;
            ProduceNum = "产品" + produceNum;
            AllDefects = new List<string>(allDefects.OrderBy(u => u));
 
            fpDefects.AutoScroll = true;
 
            this.Load += CtrlDefectsInPosition_Load;
            chkSelectAll.CheckedChanged += ChkSelectAll_CheckedChanged;
        }
 
        private void ChkSelectAll_CheckedChanged(object? sender, EventArgs e)
        {
            foreach (Control c in fpDefects.Controls)
            {
                if (c is Sunny.UI.UICheckBox chk)
                {
                    chk.Checked = chkSelectAll.Checked;
                }
            }
        }
 
        private void CtrlDefectsInPosition_Load(object? sender, EventArgs e)
        {
            lblPosition.Text = $"{PositionNum}";
            label1.Text = ProduceNum;
            fpDefects.Controls.Clear();
            AllDefects.ForEach(s =>
            {
                Sunny.UI.UICheckBox chk = new Sunny.UI.UICheckBox();
                chk.Text = s;
 
                chk.Checked = PositionDefects.Any(u => u.Code == s);
 
                fpDefects.Controls.Add(chk);
            });
        }
 
        public List<DefectPositionSet> GetPositionDefects()
        {
            List<DefectPositionSet> list = new List<DefectPositionSet>();
 
 
            foreach (Control c in fpDefects.Controls)
            {
                if (c is Sunny.UI.UICheckBox chk)
                {
                    if (chk.Checked)
                    {
                        DefectPositionSet pSet = new DefectPositionSet()
                        {
                            Code = chk.Text,
                            PositionNum = lblPosition.Text,
                            ProduceIndex = label1.Text.Replace("产品", "")
                            //PositionNum2 = PositionNum2,
                        };
 
                        list.Add(pSet);
                    }
                }
            }
 
 
            return list;
        }
    }
}