winform

        //点击退出系统
        private void btn_Exit_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("您确定要退出吗?", "退出系统对话框", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                //添加日志
                dao.AddLog("软件关闭");
                System.Environment.Exit(0);//不管什么线程都会关闭
            }
        }

 

 

        //在lst_operate列表框中记录日志 往ListBox里写入 this.AddLog("连接PLC:"+AppConfig.PLCIP);
        private void AddLog(String msg)
        {
            if (this.lst_operate.InvokeRequired)//当前线程不是创建控件的线程时为真
            {
                this.lst_operate.Invoke(new EventHandler(delegate
                {
                    this.lst_operate.Items.Add(msg);
                    this.lst_operate.SelectedIndex = this.lst_operate.Items.Count - 1;
                }));
            }
            else
            {
                this.lst_operate.Items.Add(msg);
                this.lst_operate.SelectedIndex = this.lst_operate.Items.Count - 1;
            }
        }

 

 //this.groupBox1.Paint += groupBox_Paint;

//为GroupBox设置边框颜色
        public void groupBox_Paint(object sender, PaintEventArgs e)
        {
            GroupBox gbox = (GroupBox)sender;
            e.Graphics.Clear(gbox.BackColor);
            e.Graphics.DrawString(gbox.Text, gbox.Font, Brushes.Black, 10, 1);
            var vSize = e.Graphics.MeasureString(gbox.Text, gbox.Font);
            e.Graphics.DrawLine(Pens.Black, 1, vSize.Height / 2, 8, vSize.Height / 2);
            e.Graphics.DrawLine(Pens.Black, vSize.Width + 8, vSize.Height / 2, gbox.Width - 2, vSize.Height / 2);
            e.Graphics.DrawLine(Pens.Black, 1, vSize.Height / 2, 1, gbox.Height - 2);
            e.Graphics.DrawLine(Pens.Black, 1, gbox.Height - 2, gbox.Width - 2, gbox.Height - 2);
            e.Graphics.DrawLine(Pens.Black, gbox.Width - 2, vSize.Height / 2, gbox.Width - 2, gbox.Height - 2);
        }

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值