Beispiel #1
0
        public Main()
        {
            //CheckForIllegalCrossThreadCalls = false;
            main = this;
            InitializeComponent();
            //显示版本号
            this.Text      += " " + Application.ProductVersion.ToString();
            lblLine.Text   += Pqm.line;
            lblLine.Visible = NTRSjudge.Layout.lineSwitch;
            //新建文件夹(log、pqm、sum)
            Document.CreateDocument();
            //载入统计信息
            try { TxtTotal.Text = Sum.ReadTotal(); }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n请检查下面统计文件格式或删除文件清零\r\n" + Document.pathList[2] + "total_yield.txt"
                                , "载入统计文件", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
            //创建注册表文件
            try { Registry.LocalMachine.CreateSubKey(@"software\NTRS"); }
            catch (Exception ex) { MessageBox.Show(ex.Message); Environment.Exit(0); }
            //验证(串口)
            if (!Regedit.verifyPort())
            {
checkPort:
                DialogResult dr = MessageBox.Show("串口验证失败,\n按确定键重新设置串口属性或关闭程序。", "错误", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dr == DialogResult.No)
                {
                    Environment.Exit(0);
                }
                Port port = new Port();
                port.ShowDialog();
                if (!Regedit.verifyPort())
                {
                    goto checkPort;
                }
            }

            //验证(运动轨迹)
            if (!Regedit.verifyTrajectory())
            {
checkTrajectory:
                DialogResult dr = MessageBox.Show("运动轨迹验证失败,\n按确定键重新设置运动轨迹或关闭程序。", "错误", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (dr == DialogResult.No)
                {
                    Environment.Exit(0);
                }
                Trajectory trajectory = new Trajectory();
                trajectory.ShowDialog();
                if (!Regedit.verifyTrajectory())
                {
                    goto checkTrajectory;
                }
            }
            #region 布局
            TlpLayout.RowCount    = NTRSjudge.Layout.row;
            TlpLayout.ColumnCount = NTRSjudge.Layout.col;

            for (int i = 0; i < NTRSjudge.Layout.row; i++)
            {
                TlpLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            }
            for (int i = 0; i < NTRSjudge.Layout.col; i++)
            {
                TlpLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            }

            /*
             * for (int i = 0; i < NTRSjudge.Layout.row; i++)
             * {
             *  for (int j = 0; j < NTRSjudge.Layout.col; j++)
             *  {
             *      Label label = new Label();
             *      label.Dock = DockStyle.Fill;
             *      label.BackColor = Color.Red;
             *      label.Text = "\r\n\r\n\r\n(" + (i + 1).ToString() + "," + (j + 1).ToString() + ")";
             *      tableLayoutPanel1.Controls.Add(label, j, i);
             *      //下面这句要是在行和列不够的情况下,会建到100行1000列
             *      //tableLayoutPanel1.Controls.Add(label1, 100, 1000);
             *  }
             * }
             */
            #endregion
            //定时执行
            SetTaskAtFixedTime();
        }
Beispiel #2
0
        private void 运动轨迹ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Trajectory trajectory = new Trajectory();

            trajectory.ShowDialog();
        }