轮胎外观检测添加思谋语义分割模型检测工具
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
using System.Runtime.InteropServices;
 
namespace LB_VisionControls
{
    public partial class ScriptEditControl : UserControl
    {
        public string ScriptText
        {
            get { return fctb.Text; }
            set { fctb.Text = value; }
        }
 
        public ScriptEditControl()
        {
            InitializeComponent();
            CommConfig.AppLocationPath = Application.StartupPath;
            UpStyle();
 
            InitStylesPriority();
 
            #region 新增自定义菜单
            // 
            // toolStripMenuItem1
            // 
            toolStripMenuItem1.ForeColor = SystemColors.ControlDarkDark;
            toolStripMenuItem1.Name = "toolStripMenuItem1";
            toolStripMenuItem1.Size = new Size(109, 6);
 
            获取输入变量StripMenuItem.ForeColor = Color.FromArgb(255, 255, 128);
            获取全局变量StripMenuItem.ForeColor = Color.FromArgb(255, 255, 128);
            设置输出变量StripMenuItem.ForeColor = Color.FromArgb(255, 255, 128);
            设置全局变量StripMenuItem.ForeColor = Color.FromArgb(255, 255, 128);
 
            获取输入变量StripMenuItem.Size = new Size(112, 26);
            获取全局变量StripMenuItem.Size = new Size(112, 26);
            设置输出变量StripMenuItem.Size = new Size(112, 26);
            设置全局变量StripMenuItem.Size = new Size(112, 26);
 
            获取输入变量StripMenuItem.Text = "获取输入变量";
            获取全局变量StripMenuItem.Text = "获取全局变量";
            设置输出变量StripMenuItem.Text = "设置输出变量";
            设置全局变量StripMenuItem.Text = "设置全局变量";
 
            // 插入固定的文本
            获取输入变量StripMenuItem.Click += (sender, e) => fctb.InsertText("object temp = GetInputs(\"key\");\n");
            获取全局变量StripMenuItem.Click += (sender, e) => fctb.InsertText("object temp = GetGlobalVars(\"key\");\n");
            设置输出变量StripMenuItem.Click += (sender, e) => fctb.InsertText("AddOutputs(\"key\", \"value\")\n;");
            设置全局变量StripMenuItem.Click += (sender, e) => fctb.InsertText("AddGlobalVars(\"key\", \"value\")\n;");
 
            contextMenuStripEx1.Items.Clear();
            contextMenuStripEx1.Items.AddRange(new ToolStripItem[]
{
                复制ToolStripMenuItem1,
                剪切ToolStripMenuItem1,
                toolStripMenuItem4,
                粘贴ToolStripMenuItem1,
                toolStripMenuItem5,
                全选ToolStripMenuItem1,
                toolStripMenuItem6,
                清除ToolStripMenuItem1,
                新建ToolStripMenuItem,
                toolStripMenuItem1,
                获取输入变量StripMenuItem,
                获取全局变量StripMenuItem,
                设置输出变量StripMenuItem,
                设置全局变量StripMenuItem
            });
            #endregion
        }
 
        #region 自定义菜单
        private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1 = new ToolStripSeparator();
        private System.Windows.Forms.ToolStripMenuItem 获取输入变量StripMenuItem = new ToolStripMenuItem();
        private System.Windows.Forms.ToolStripMenuItem 获取全局变量StripMenuItem = new ToolStripMenuItem();
        private System.Windows.Forms.ToolStripMenuItem 设置输出变量StripMenuItem = new ToolStripMenuItem();
        private System.Windows.Forms.ToolStripMenuItem 设置全局变量StripMenuItem = new ToolStripMenuItem();
        #endregion
 
        private void UpStyle()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
            UpdateStyles();
        }
 
        private void CreatNew()
        {
            #region 初始化数据
            fctb.Text = @"/*
日志记录
时间:" + DateTime.Now.ToLocalTime() + @"
用户:" + Environment.UserName + @"
记录:
*/
using System;
using System.Text;
class Program
{
    static void Main()
    {
       //代码
       
    }
}";
 
            #endregion
        }
 
        private void InitStylesPriority()
        {
 
            fctb.ClearUndo();
            fctb.IsChanged = false;
 
            CreatNew();
 
            KeyWordsAuto.CreatMenu(fctb, imageList1);
            //KeysWordCMDAuto.CreatMenu(DebugTextBox1, imageList1);
        }
 
        #region 系统UI
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (Directory.Exists(CommConfig.BinPath))
                    Directory.Delete(CommConfig.BinPath, true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if ((Control.ModifierKeys & Keys.Control) != 0 && e.KeyCode == Keys.Up)
            { fctb.Focus(); }
            //else if ((Control.ModifierKeys & Keys.Control) != 0 && e.KeyCode == Keys.Down)
            //{ DebugTextBox1.Focus(); }
        }
        private void fctb_KeyDown(object sender, KeyEventArgs e)
        {
            if (CompliReslut.RowErrorNumber != -1)
            {
                fctb[CompliReslut.RowErrorNumber - 1].BackgroundBrush = null;
                fctb.Invalidate();
                CompliReslut.RowErrorNumber = -1;
            }
        }
        #endregion
 
        #region 右击菜单
        private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fctb.Paste();
        }
 
        private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fctb.Copy();
        }
 
        private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fctb.Cut();
 
        }
 
        private void 全选ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fctb.SelectAll();
        }
 
        private void 清除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            fctb.Clear();
        }
        #endregion
 
        #region 移动
        public const int WM_NCLBUTTONDOWN = 0xA1;
        public const int HT_CAPTION = 0x2;
        [DllImportAttribute("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        [DllImportAttribute("user32.dll")]
        public static extern bool ReleaseCapture();
 
        private void splitContainer1_Panel1_MouseMove(object sender, MouseEventArgs e)
        {
            //移动
            if (e.Button == MouseButtons.Left)
            {
                if (e.X < this.Width)
                {
                    ReleaseCapture();
                    SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
                }
            }
        }
        private void label1_MouseMove(object sender, MouseEventArgs e)
        {
            //移动
            if (e.Button == MouseButtons.Left)
            {
                if (e.X < this.Width)
                {
                    ReleaseCapture();
                    SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
                }
            }
        }
        #endregion
 
        #region 动画
        public bool isShow = true;
        int loadSpeed = 10;
        public void StartMeun()
        {
            if (isShow)
            {
                timerBack.Enabled = true;
            }
            else
            {
                timerCell.Enabled = true;
            }
        }
        private void CellOutputHide()
        {
            panel1.Height -= loadSpeed;
            loadSpeed += loadSpeed;
            if (panel1.Height <= 30)
            {
                timerCell.Enabled = false;
                panel1.Height = 30;
                loadSpeed = 10;
 
                //back
                timerBack.Enabled = true;
            }
        }
        private void CellOutputShow()
        {
            panel1.Height += loadSpeed;
            loadSpeed += loadSpeed;
            if (panel1.Height >= 310)
            {
                timerCell.Enabled = false;
                panel1.Height = 310;
                loadSpeed = 10;
 
                //OK
                // picDic.Image = Properties.Resources.rdir1;
                isShow = false;//显示过程完成
            }
        }
 
        private void backOutputHide()
        {
            panel1.Left += loadSpeed;
            loadSpeed += loadSpeed;
            if (panel1.Left >= this.Width)
            {
                timerBack.Enabled = false;
                panel1.Left = this.Width;
                loadSpeed = 10;
 
                //OK
                //picDic.Image = Properties.Resources.dir1;
                isShow = true;//显示过程结束
            }
        }
        private void backOutputShow()
        {
            panel1.Left -= loadSpeed;
            loadSpeed += loadSpeed;
            if (panel1.Left <= this.Width - panel1.Width - 18)
            {
                timerBack.Enabled = false;
                panel1.Left = this.Width - panel1.Width - 18;
                loadSpeed = 10;
 
                //celll
                timerCell.Enabled = true;
            }
        }
        private void timerCell_Tick(object sender, EventArgs e)
        {
            if (isShow)
            {
                CellOutputShow();
            }
            else
            {
                CellOutputHide();
            }
        }
 
        private void timerBack_Tick(object sender, EventArgs e)
        {
            if (isShow)
            {
                backOutputShow();
            }
            else
            {
                backOutputHide();
            }
        }
 
        #endregion
 
 
        public void FileSave()
        {
            if (!Directory.Exists(CommConfig.ClassLibPath))
            {
                Directory.CreateDirectory(CommConfig.ClassLibPath);
            }
            File.WriteAllText(CommConfig.fileName, fctb.Text);
        }
 
        #region 添加UI
        public void AddCsc()
        {
            panControlView.Controls.Clear();
            ComplieUI cp = new ComplieUI();
            cp.BackColor = Color.Transparent;
            cp.fctb = this.fctb;
            cp.Dock = DockStyle.Fill;
            panControlView.Controls.Add(cp);
        }
        public void AddClassFileList()
        {
            panControlView.Controls.Clear();
            ClassFileList cp = new ClassFileList();
            cp.BackColor = Color.Transparent;
            cp.fctb = this.fctb;
            cp.Dock = DockStyle.Fill;
            panControlView.Controls.Add(cp);
        }
        public void AddText(string txt)
        {
            panControlView.Controls.Clear();
            TextBox tx = new TextBox();
            tx.Text = txt;
            tx.Dock = DockStyle.Fill;
            tx.BorderStyle = BorderStyle.None;
            tx.BackColor = Color.FromArgb(30, 17, 18);
            tx.ForeColor = Color.Green;
            tx.Multiline = true;
            tx.ScrollBars = ScrollBars.Both;
            tx.Font = new System.Drawing.Font("微软雅黑", 9);
            panControlView.Controls.Add(tx);
        }
        #endregion
 
        private void DebugTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
                e.Handled = true;
        }
 
        private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InitStylesPriority();
        }
    }
 
}