轮胎外观检测添加思谋语义分割模型检测工具
C3204
7 天以前 8826196fc78ceb9c327d3abf7f2f2cf06dabb5df
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
using LB_VisionProcesses;
using LB_VisionProcesses.Forms;
using System;
using System.Collections.Concurrent;
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 LB_SmartVision.Forms.Pages.SettingPage
{
    public partial class LayoutPage : UserControl
    {
        public LayoutPage()
        {
            InitializeComponent();
 
            btnSave.Click += (sender, e) =>
            {
                if (!VisionForm.SaveAllLayout())
                {
                    MessageBox.Show("!!!保存失败!!!", "异常");
                }
                else
                {
                    MessageBox.Show("保存成功!");
                }
            };
        }
 
        private void LayoutPage_Paint(object sender, PaintEventArgs e)
        {
            this.pnlLayout.Controls.Clear();
 
            for (int index = 0; index < GlobalVar.dicLayout.Count; index++)
            {
                try
                {
                    LayoutSettingControl control = new LayoutSettingControl(GlobalVar.dicLayout[index]);
                    control.Size = new Size(this.pnlLayout.Size.Width, control.Size.Height);
                    control.Location = new Point(0, control.Size.Height * index);
                    this.pnlLayout.Controls.Add(control);
                }
                catch { }
            }
        }
 
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Layout layout = new Layout(GlobalVar.strApplicationPath + "\\生产图片");
            foreach (var item in GlobalVar.dicLayout.Values)
            {
                if (item.Title == layout.Title)
                {
                    layout.Title += "(副本)";
                }
            }
            if (!string.IsNullOrEmpty(layout.Title) && layout.Title.Equals("布局"))
            {
                layout.Title += "(副本)";
            }
            GlobalVar.dicLayout.TryAdd(GlobalVar.dicLayout.Count, layout);
            this.Invalidate();
        }
 
        private void btnDel_Click(object sender, EventArgs e)
        {
            foreach (var control in pnlLayout.Controls)
            {
                if (control is LayoutSettingControl layoutSettingControl
                    && layoutSettingControl.IsSelected)
                {
                    var item = GlobalVar.dicLayout.FirstOrDefault(x => x.Value.Title == layoutSettingControl.Title);
                    GlobalVar.dicLayout.TryRemove(item.Key, out _);
                }
            }
            int i = 0;
            ConcurrentDictionary<int, Layout> dicLayoutTemp = new ConcurrentDictionary<int, Layout>();
            foreach (var control in GlobalVar.dicLayout)
            {
                dicLayoutTemp.TryAdd(i, control.Value);
                i++;
            }
            GlobalVar.dicLayout.Clear();
            GlobalVar.dicLayout= dicLayoutTemp;
            this.Invalidate();
        }
 
        private void btnTop_Click(object sender, EventArgs e)
        {
            bool isSelected = false;
            foreach (var control in pnlLayout.Controls)
            {
                if (control is LayoutSettingControl layoutSettingControl
                    && layoutSettingControl.IsSelected)
                {
                    if (isSelected)
                    {
                        MessageBox.Show("每次只能上移一个!", "异常");
                        return;
                    }
                    isSelected = true;
                }
            }
 
            for (int index = 0; index < GlobalVar.dicLayout.Count; index++)
            {
                foreach (var control in pnlLayout.Controls)
                {
                    if (control is LayoutSettingControl layoutSettingControl
                        && layoutSettingControl.IsSelected)
                    {
                        var item = GlobalVar.dicLayout.FirstOrDefault(x => x.Value.Title == layoutSettingControl.Title);
                        int Key = item.Key;
                        // 已经是第一个了,则无变化
                        if (Key == 0)
                        {
                            return;
                        }
                        var temp = GlobalVar.dicLayout[Key - 1];
                        GlobalVar.dicLayout[Key - 1] = item.Value;
                        GlobalVar.dicLayout[Key] = temp;
                        this.Invalidate();
                        return;
                    }
                }
            }
        }
    }
 
    [Serializable]
    public class Layout
    {
        public string Title { get; set; } = "布局";
 
        public string ProcessName { get; set; } = string.Empty;
 
        public string InputImage { get; set; } = string.Empty;
 
        public string SaveImageDir { get; set; } = string.Empty;
 
        public string SaveImageHead { get; set; } = string.Empty;
 
        public string RecordImage { get; set; } = string.Empty;
 
        public Layout() { }
 
        public Layout(string path) { SaveImageDir = path; }
 
    }
}