Exemplo n.º 1
0
        public void Update(MouseState mouseState)
        {
            if (Click != null && Click.GetInvocationList().Length > 0)
            {
                MouseArea = new Rectangle(mouseState.X, mouseState.Y, MouseArea.Width, MouseArea.Height);

                if (Area.Intersects(MouseArea))
                {
                    Image.Color = HoverColor;

                    if (mouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
                    {
                        Image.Color = ClickColor;
                        OnClick(new EventArgs());
                    }

                    oldMouseState = mouseState;
                }
                else
                {
                    Image.Color = DefaultColor;
                }
            }
            else
            {
                // disable button since it has nothing attached
            }
        }
Exemplo n.º 2
0
 public void ClearEvents()
 {
     if (Click != null)
     {
         foreach (Delegate d in Click.GetInvocationList())
         {
             Click -= (EventHandler)d;
         }
     }
 }
Exemplo n.º 3
0
 public bool HasListeners()
 {
     if (Click != null && Click.GetInvocationList().Length > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 4
0
 void doClick()
 {
     foreach (RoutedEventHandler h in Click.GetInvocationList())
     {
         try
         {
             h(this, null);
         }
         catch (Exception)
         {
             Console.WriteLine("A listener threw an exception in its handler");
         }
     }
 }