C#编程:用Thread获取系统时间-3

C#编程:用Thread获取系统时间-3


private void button1_Click(object sender, EventArgs e)
        {
            System.Threading.Thread p_thread =
                new System.Threading.Thread(
                    () =>
                    {
                        while (true)
                        {
                            this.Invoke(
                                (MethodInvoker)delegate()
                                {
                                    this.Refresh();
                                    Graphics p_graphics =
                                        CreateGraphics();
                                    p_graphics.DrawString(
                                        "系统时间: " + DateTime.Now.ToString(
                                            "yyyy年MM月dd日hh时mm分ss秒"
                                        ), new Font("宋体", 15),
                                        Brushes.Blue,
                                        new Point(10, 10));
                                });
                            System.Threading.Thread.Sleep(1000);
                        }
                    });
            p_thread.IsBackground = true;
            p_thread.Start();
        }
图片处理软件简单c#public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Pen p = new Pen(Color.Black, 3); Graphics g = this.CreateGraphics(); g.DrawEllipse(p, 100, 100, 300, 300); } private void button2_Click(object sender, EventArgs e) { SolidBrush b = new SolidBrush(Color.Red); Graphics g = this.CreateGraphics(); g.FillEllipse(b,20,20,150,150); } private void button3_Click(object sender, EventArgs e) { TextureBrush b = new TextureBrush(new Bitmap(@"E:\壁纸\叶子.jpg")); Graphics g = this.CreateGraphics(); g.FillEllipse(b, 50, 50, 150, 150); } private void button4_Click(object sender, EventArgs e) { TextureBrush b = new TextureBrush(new Bitmap(@"E:\壁纸\叶子.jpg")); Pen p = new Pen(b, 5); Graphics g = this.CreateGraphics(); g.DrawRectangle(p,150,150,50,50); } bool zt = false; bool bi= false; Pen p1; Point z1, z2; private void button5_Click(object sender, EventArgs e) { p1 = new Pen(Color.Black, 5); if (bi) { bi = false; } else { bi = true; } } private void Form2_MouseDown(object sender, MouseEventArgs e) { if (bi) { zt = true; z2 = this.PointToClient(Control.MousePosition); z1 = this.PointToClient(Control.MousePosition); } } private void Form2_MouseUp(object sender, MouseEventArgs e) { if (bi) { zt = false; } } private void Form2_MouseMove(object sender, MouseEventArgs e) { if (zt) { z2= this.PointToClient(Control.MousePosition); Graphics g = this.CreateGraphics(); g.DrawLine(p1,z1,z2); z1 = z2; }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值