/// <summary>
        /// Raises the <see cref="MouseUp"/> event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        protected virtual void OnMouseUp(MouseEventArgs e)
        {
            IsClicked = false;
            OdysseyUI.CurrentHud.ClickedControl = null;

            UpdateAppearance();

            EventHandler<MouseEventArgs> handler = (EventHandler<MouseEventArgs>) Events[EventMouseUp];
            if (handler != null)
                handler(this, e);
        }
 /// <summary>
 /// Raises the <see cref="MouseWheel"/> event.
 /// </summary>
 /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
 protected virtual void OnMouseWheel(MouseEventArgs e)
 {
     EventHandler<MouseEventArgs> handler = (EventHandler<MouseEventArgs>) Events[EventMouseWheel];
     if (handler != null)
         handler(this, e);
 }
        /// <summary>
        /// Raises the <see cref="MouseDown"/> event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        protected virtual void OnMouseDown(MouseEventArgs e)
        {
            IsClicked = true;
            Hud hud = OdysseyUI.CurrentHud;
            hud.ClickedControl = this;
            //hud.WindowManager.BringToFront(depth.WindowLayer);

            if (hud.FocusedControl != this)
                hud.FocusedControl.OnLostFocus(e);

            UpdateAppearance();

            EventHandler<MouseEventArgs> handler = (EventHandler<MouseEventArgs>) Events[EventMouseDown];
            if (handler != null)
                handler(this, e);
        }
        /// <summary>
        /// Raises the <see cref="MouseLeave"/> event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        protected virtual void OnMouseLeave(MouseEventArgs e)
        {
            //DebugManager.LogToScreen(
            //    DateTime.Now.Millisecond + " Leaving " +
            //    id + " H: " + isHighlighted);

            isInside = false;
            if (ApplyStatusChanges)
            {
                if (AvengersUtd.Odyssey.UserInterface.Input.Mouse.ClickButton == e.Button)
                {
                    if (OdysseyUI.CurrentHud.ClickedControl == this)
                    {
                        IsHighlighted = IsClicked = false;
                    }
                    else
                        return;
                }
                else
                {
                    IsHighlighted = false;
                }
            }

            EventHandler<MouseEventArgs> handler = (EventHandler<MouseEventArgs>) Events[EventMouseLeave];
            if (handler != null)
                handler(this, e);
        }
        /// <summary>
        /// Raises the <see cref="MouseClick"/> event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        protected virtual void OnMouseClick(MouseEventArgs e)
        {
            UpdateAppearance();

            EventHandler<MouseEventArgs> handler = (EventHandler<MouseEventArgs>) Events[EventMouseClick];
            if (handler != null)
                handler(this, e);
        }
        internal virtual bool ProcessMouseRelease(MouseEventArgs e)
        {
            if (canRaiseEvents && (HasCaptured || IntersectTest(e.Location)))
            {
                if (IsClicked)
                {
                    if (e.Button != MouseButton.None)
                        OnMouseClick(e);
                }
                OnMouseUp(e);
                return true;
            }

            if (IsClicked)
                IsClicked = false;
            return false;
        }
        internal virtual bool ProcessMousePress(MouseEventArgs e)
        {
            if (!canRaiseEvents || !IntersectTest(e.Location))
                return false;

            if (e.Button == Mouse.ClickButton && !IsClicked && isEnabled)
            {
                OnMouseDown(e);

                if (isFocusable && !IsFocused)
                    OnGotFocus(EventArgs.Empty);
            }

            return true;
        }
        internal virtual bool ProcessMouseMovement(MouseEventArgs e)
        {
            if (!HasCaptured && !IntersectTest(e.Location))
                return false;

            if (canRaiseEvents)
            {
                if (!isInside)
                    OnMouseEnter(e);

                if (e.Delta != 0)
                    OnMouseWheel(e);

                OnMouseMove(e);
                return true;
            }
            return false;
        }
Example #9
0
        static void MouseMovementHandler(object sender, MouseEventArgs e)
        {
            bool handled = false;

            // Checks whether a control has captured the mouse pointer
            if (CurrentHud.CaptureControl != null)
            {
                CurrentHud.CaptureControl.ProcessMouseMovement(e);
                return;
            }

            //// Check whether a modal window is displayed
            //if (CurrentHud.WindowManager.Foremost != null && CurrentHud.WindowManager.Foremost.IsModal)
            //{
            //    foreach (
            //        BaseControl control in
            //            TreeTraversal.PostOrderControlInteractionVisit(CurrentHud.WindowManager.Foremost))
            //    {
            //        handled = control.ProcessMouseMovement(e);
            //        if (handled)
            //        {
            //            return;
            //        }
            //    }
            //    CurrentHud.WindowManager.Foremost.ProcessMouseMovement(e);

            //    return;
            //}

            // Proceeds with the rest
            foreach (BaseControl control in TreeTraversal.PostOrderControlInteractionVisit(CurrentHud))
            {
                handled = control.ProcessMouseMovement(e);
                if (handled)
                    break;
            }
            if (!handled)
                CurrentHud.ProcessMouseMovement(e);
        }