轮胎外观检测添加思谋语义分割模型检测工具
C3204
2026-03-30 06c627ec032b3f3876fd7db8a3ff0ff1a6614fa2
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using System.Drawing.Drawing2D;
 
namespace LB_VisionControls
{
    public partial class ComplieUI : UserControl
    {
        public ComplieUI()
        {
            InitializeComponent();
        }
        public FastColoredTextBox fctb { get; set; }
 
        private void btnCsc_Click(object sender, EventArgs e)
        {
            UIConfig(false);
            CreatFile();
 
            txtOutput.Text = runStringCSC(MakeCommond());//编译
 
            if (File.Exists(CommConfig.ExeFilePath) || File.Exists(CommConfig.DllFilePath))
            {
                txtOutput.Text = "====================编译成功==================\r\n";
                if (radExe.Checked || radWinexe.Checked)//测试*.exe文件
                {
                    if (chkCmd.Checked || radWinexe.Checked)//判断是否使用CMD
                    {
                        System.Diagnostics.Process.Start(CommConfig.ExeFilePath);
                    }
                    else
                    {
                        txtOutput.Text += "\r\n" + runStringTemp(txtArgs.Text);
                    }
                }
            }
            else
                txtOutput.Text += "==================编译失败!!=======================";
 
            UIConfig(true);
        }
        public void UIConfig(bool isLock)
        {
            fctb.ReadOnly = !isLock;
            txtArgs.Enabled = isLock;
            radExe.Enabled = isLock;
            radWinexe.Enabled = isLock;
            radDll.Enabled = isLock;
            chkCmd.Enabled = isLock;
        }
        private string MakeCommond()
        {
            StringBuilder sb = new StringBuilder();
 
            if (radExe.Checked)
                sb.Append("/target:exe  /out:" + CommConfig.ExeFilePath + " " + CommConfig.SrcFilePath);
            else if (radWinexe.Checked)
                sb.Append("/target:winexe  /out:" + CommConfig.ExeFilePath + " " + CommConfig.SrcFilePath);
            else
                sb.Append("/target:library /out:" + CommConfig.DllFilePath + " " + CommConfig.SrcFilePath);
            return sb.ToString();
        }
        //测试生成文件
        private string runStringTemp(string commond)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = CommConfig.ExeFilePath;
            p.StartInfo.Arguments = commond;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            p.StandardInput.WriteLine(commond);
            return p.StandardOutput.ReadToEnd();
 
        }
        //编译函数
        private string runStringCSC(string commond)
        {
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            p.StartInfo.FileName = CommConfig.CscPath + "\\csc.exe";
            p.StartInfo.Arguments = commond;
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();
            p.StandardInput.WriteLine(commond);
            // p.StandardInput.WriteLine("exit");
            return p.StandardOutput.ReadToEnd();
 
        }
        private void CreatFile()
        {
            if (Directory.Exists(CommConfig.BinPath))
                Directory.Delete(CommConfig.BinPath, true);
            Directory.CreateDirectory(CommConfig.BinPath);
            Thread.Sleep(500);
            StreamWriter strCode = new StreamWriter(File.OpenWrite(CommConfig.SrcFilePath), System.Text.Encoding.Default);
            strCode.WriteLine(fctb.Text);
            strCode.Close();
        }
 
        private void texstToolStripMenuItem_Click(object sender, EventArgs e)
        {
            txtOutput.Copy();
        }
 
        private void 清楚ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            txtOutput.Clear();
        }
 
    }
}