气泡案例

气泡案例

this.Top:表示窗体上边框与屏幕顶部的距离

this.Left:表示窗体左边框与屏幕左边的距离

Screen.PrimaryScreen.WorkingArea.Width:屏幕的宽,不包括任务栏

Screen.PrimaryScreen.Bounds.Width:屏幕的宽,包括任务栏

Screen.PrimaryScreen.WorkingArea.Height:屏幕的高,不包括任务栏

Screen.PrimaryScreen.Bounds.Height:屏幕的高,包括任务栏

Timer:计时器控件,控制某种行为在特定时间的运行

Interval属性:设置计时器的频率

双击计时器会创建对应的tick事件

窗体平移

窗体平移:

窗体从屏幕左上角——》屏幕右上角——》屏幕右下角——》屏幕左下角——》屏幕左上角循环

多个计时器:

重点考虑每个计时器中的行为,开始/停止计时器的时机

代码:
private void Form1_Load(object sender, EventArgs e)
        {
            this.Location = new Point(0, 0);//窗口位置
            this.BackColor = Color.Beige;//窗口背景颜色
            this.FormBorderStyle = FormBorderStyle.None;//窗体边框样式
            this.Size = new Size(200, 200);//窗体大小
            timer1.Start();//开启计时器
        }

        int w = Screen.PrimaryScreen.WorkingArea.Width;//获取屏幕宽度(WorkingArea,不包括任务栏)
        int h = Screen.PrimaryScreen.Bounds.Height;//获取屏幕宽度(Bounds,包括任务栏)
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            this.Left += 10;//即this.Left=this.Left+10,使窗体右移
            //到达屏幕右上角关闭计时器1,开启计时器2
            if (this.Width + this.Left >= w)
            {
                timer1.Stop();
                timer2.Start();
            }
        }

        private void timer2_Tick_1(object sender, EventArgs e)
        {
            this.Top += 10;//即this.top=this.top+10,使窗体下移
            //到达屏幕右下角关闭计时器2,开启计时器3
            if (this.Height + this.Top >= h)
            {
                timer2.Stop();
        
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值