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

来源:互联网 发布:阿里云cdn流量包 编辑:程序博客网 时间:2024/05/19 22:27

 这段时间我们在做一个触屏的软件,负责人提出要将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;
                    }
                }
            }
        }

原创粉丝点击