Esempio n. 1
0
        // Check and Throw button's events
        public virtual void TreatEvent()
        {
            if (this.enable)
            {
                lastState = state;
                this.CheckState();

                if (this.lastState == ButtonStated.Down && this.state == ButtonStated.Up)
                {
                    isClicked = true;
                    if (Clicked != null)
                        Clicked(this, EventArgs.Empty);
                }
                else if (this.lastState == ButtonStated.Up)
                {
                    isClicked = false;
                    if (Released != null)
                        Released(this, EventArgs.Empty);
                }
            }
        }
Esempio n. 2
0
 public Button(Button button)
     : base(button)
 {
     this.state = button.state;
     this.Initialize();
 }
Esempio n. 3
0
 // Check about button's state
 public virtual void CheckState()
 {
     if (GMouse.MousePosition.X >= bound.X && GMouse.MousePosition.X <= bound.X + bound.Width
         && GMouse.MousePosition.Y >= bound.Y && GMouse.MousePosition.Y <= bound.Y + bound.Height)
     {
         if (GMouse.IsLeftButtonDown)
         {
             this.state = ButtonStated.Down;
         }
         else if (this.state == ButtonStated.Down && GMouse.IsLeftButtonUp)
         {
             this.state = ButtonStated.Up;
         }
     }
     else
         this.state = ButtonStated.Normal;
 }