zoukankan      html  css  js  c++  java
  • 可移动的按钮

    int temp_X;

    int count = 0;        

    private void Form1_Load(object sender, EventArgs e)        

    {            

      this.pic_OpenLock.Left = 0;            

      this.pan_Lock.Width = this.Width;            

      this.pan_Lock.Top = this.Height - this.pan_Lock.Height;            

      this.label1.Top = this.pictureBox1.Height - this.label1.Height-this.pan_Lock.Height;

           this.label1.Left = this.pan_Lock.Width - this.label1.Width;

           this.pic_Right_open.Left = this.pan_Lock.Width-this.pic_Right_open.Width; 

    }

    private void pic_OpenLock_MouseDown(object sender, MouseEventArgs e)        

    {            

       this.temp_X = e.X;        

    }

    private void pic_OpenLock_MouseMove(object sender, MouseEventArgs e)        

    {            

      if (e.Button == MouseButtons.Left)            

      {                

        this.pic_OpenLock.Left = e.X - temp_X + this.pic_OpenLock.Left;                            

      }        

    }

    private void pic_OpenLock_MouseUp(object sender, MouseEventArgs e)        

    {            

      if (this.pic_OpenLock.Left <= 0)            

      {                

        this.pic_OpenLock.Left = 0;            

      }            

      if (this.pic_OpenLock.Left >= this.pan_Lock.Width - this.pic_OpenLock.Width)            

      {              

           this.pic_OpenLock.Left = this.pan_Lock.Width - this.pic_OpenLock.Width;      

           }          

         if (this.pic_OpenLock.Left < this.pan_Lock.Width - this.pic_OpenLock.Width)            

      {               

          this.pic_OpenLock.Left = 0;            

      }            

      else            

      {                

        Application.Exit();

               

      }        

    }

           

    private void timer1_Tick(object sender, EventArgs e)        

    {            

      count++;            

      if (count % 2 == 0)            

      {                

        this.pic_Right_open.Visible = false;            

      }            

      else            

      {                

      this.pic_Right_open.Visible = true;            

      }        

    }

  • 相关阅读:
    集训Day 7 2020.3.7 动态规划(二)
    集训Day 6 2020.3.6 动态规划(一)
    集训Day 5 2020.3.4 杂题选讲(二)
    集训Day 4 2020.3.3 杂题选讲(一)
    集训Day 2 2020.3.1 数论(质数与筛法)
    集训Day 1 2020.2.29 数论复习(gcd)(一)
    [BZOJ4152]The Captain
    知识点清单(全)
    字符串相关知识
    分块相关知识
  • 原文地址:https://www.cnblogs.com/cz-xjw/p/CanMoveButton.html
Copyright © 2011-2022 走看看