模仿视屏软件,定时将pan隐藏

 这段时间我们在做一个触屏的软件,负责人提出要将menu的pan定时隐藏。

 同事已经研究出来了,我就想偷懒,但是却发现,代码到我这根本不好使。试过很多种方法,但是,发现pan.top的值是固定的,一直不变,我就想既然这样不好使,或许,直接用height还能省很多事。

 下面就是原码:

 private void fCity_Load(object sender, EventArgs e)
        {

            //panButton伸缩
            this.panBottom.Height = 72;//pan的高

            this.timer1.Enabled = true;//时间控件            
        }

  private void timer1_Tick(object sender, EventArgs e)
        {
            int x = Cursor.Position.X;//得到鼠标的x坐标
            int y = Cursor.Position.Y;//得到鼠标的y坐标


            if (this.panBottom.Height == 0)       //弹出
            {

                if (y >= this.Bottom - 50 && x > this.panBottom.Left && x < this.panBottom.Left + this.panBottom.Width)
                {
                    for (int i = 0; i <= 72; i++)
                    {
                        this.panBottom.Height = i;
                    }
                    this.timer1.Interval = 5000;
                }
            }
            else            //缩进
            {
                if (y < this.Bottom - 50)
                {
                    if (y < this.Bottom - this.panBottom.Height || y < this.panBottom.Top || x < this.panBottom.Left || x > this.panBottom.Right - this.panBottom.Width)//判断鼠标X,Y是是否在窗体中,如果不在就缩窗体
                    {
                        for (int i = 72; i >= 0; i--)
                        {
                            this.panBottom.Height = i;
                        }
                        this.timer1.Interval = 100;
                    }
                }
            }
        }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值