예제 #1
0
        /// <summary>
        /// Mouse up event handler.
        /// </summary>
        /// <param name="e">Event args</param>
        /// <returns>If this widget handled this event</returns>
        public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            // if we're in the client area handle let the children try
            if (e.X >= widgetLeft &&
                e.X <= widgetRight &&
                e.Y >= widgetTop &&
                e.Y <= widgetBottom)
            {
                for (int i = 0; i < m_ChildWidgets.Count; i++)
                {
                    if (m_ChildWidgets[i] is jhuapl.util.IInteractive)
                    {
                        jhuapl.util.IInteractive currentInteractive = m_ChildWidgets[i] as jhuapl.util.IInteractive;
                        if (currentInteractive.OnMouseUp(e))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #2
0
        public bool OnMouseWheel(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            for (int index = 0; index < m_ChildWidgets.Count; index++)
            {
                jhuapl.util.IWidget currentWidget = m_ChildWidgets[index] as jhuapl.util.IWidget;

                if (currentWidget != null && currentWidget is jhuapl.util.IInteractive)
                {
                    jhuapl.util.IInteractive currentInteractive = m_ChildWidgets[index] as jhuapl.util.IInteractive;

                    handled = currentInteractive.OnMouseWheel(e);
                    if (handled)
                    {
                        return(handled);
                    }
                }
            }

            return(handled);
        }
예제 #3
0
        public bool OnMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            if (m_visible)
            {
                // if we're in the client area
                if (e.X >= this.AbsoluteLocation.X &&
                    e.X <= this.AbsoluteLocation.X + ClientSize.Width &&
                    e.Y >= this.AbsoluteLocation.Y &&
                    e.Y <= this.AbsoluteLocation.Y + NODE_HEIGHT)
                {
                    if (!m_isMouseOver)
                    {
                        this.OnMouseEnter(e);
                    }

//					m_isMouseOver = true;
                    handled = true;
                }
                else
                {
                    if (m_isMouseOver)
                    {
                        this.OnMouseLeave(e);
                    }

//					m_isMouseOver = false;
                }
            }
            else
            {
                m_isMouseOver = false;
            }

            // call all the children because they need to have a chance to detect mouse leaving.
            for (int i = 0; i < m_subNodes.Count; i++)
            {
                if (m_subNodes[i] is jhuapl.util.IInteractive)
                {
                    jhuapl.util.IInteractive currentInteractive = m_subNodes[i] as jhuapl.util.IInteractive;
                    if (currentInteractive.OnMouseMove(e))
                    {
                        handled = true;
                    }
                }
            }

            return(handled);
        }
예제 #4
0
        public bool OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            if (m_visible)
            {
                // if we're in the client area and lmb
                if (e.X >= this.AbsoluteLocation.X &&
                    e.X <= this.AbsoluteLocation.X + ClientSize.Width &&
                    e.Y >= this.AbsoluteLocation.Y &&
                    e.Y <= this.AbsoluteLocation.Y + NODE_HEIGHT)
                {
                    m_isMouseDown = true;
                    handled       = true;
                }
                else
                {
                    m_isMouseDown = false;
                }
            }

            // if mouse didn't come down on us, let the children try as we should be inside the top form client area
            if (!handled)
            {
                for (int i = 0; i < m_subNodes.Count; i++)
                {
                    if (m_subNodes[i] is jhuapl.util.IInteractive)
                    {
                        jhuapl.util.IInteractive currentInteractive = m_subNodes[i] as jhuapl.util.IInteractive;
                        handled = currentInteractive.OnMouseDown(e);
                    }

                    // if anyone has handled this, we're done
                    if (handled)
                    {
                        continue;
                    }
                }
            }

            return(handled);
        }
예제 #5
0
        /// <summary>
        /// Mouse move event handler.
        /// </summary>
        /// <param name="e">Event args</param>
        /// <returns>If this widget handled this event</returns>
        public bool OnMouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            int deltaX = e.X - m_LastMousePosition.X;
            int deltaY = e.Y - m_LastMousePosition.Y;

            m_LastMousePosition = new System.Drawing.Point(e.X, e.Y);

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            // Handle each child if we're in the client area
            if (e.X >= widgetLeft &&
                e.X <= widgetRight &&
                e.Y >= widgetTop &&
                e.Y <= widgetBottom)
            {
                for (int i = 0; i < m_ChildWidgets.Count; i++)
                {
                    if (m_ChildWidgets[i] is jhuapl.util.IInteractive)
                    {
                        jhuapl.util.IInteractive currentInteractive = m_ChildWidgets[i] as jhuapl.util.IInteractive;

                        if (currentInteractive.OnMouseMove(e))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #6
0
        /// <summary>
        /// Mouse down event handler.
        /// </summary>
        /// <param name="e">Event args</param>
        /// <returns>If this widget handled this event</returns>
        public bool OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            // Whether or not the event was handled
            bool handled = false;

            // Whether or not we're in the form
            bool inClientArea = false;

            // if we aren't active do nothing.
            if ((!m_visible) || (!m_enabled))
            {
                return(false);
            }

            int widgetTop    = this.Top;
            int widgetBottom = this.Bottom;
            int widgetLeft   = this.Left;
            int widgetRight  = this.Right;

            // if we're in the client area bring to front
            if (e.X >= widgetLeft &&
                e.X <= widgetRight &&
                e.Y >= widgetTop &&
                e.Y <= widgetBottom)
            {
                if (m_parentWidget != null)
                {
                    m_parentWidget.ChildWidgets.BringToFront(this);
                }

                inClientArea = true;
            }

            // if its the left mouse button check for UI actions (resize, drags, etc)
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                #region header dbl click

                // Check for header double click (if its shown)
                if (HeaderEnabled &&
                    e.X >= m_location.X &&
                    e.X <= AbsoluteLocation.X + m_size.Width &&
                    e.Y >= AbsoluteLocation.Y &&
                    e.Y <= AbsoluteLocation.Y + m_currHeaderHeight)
                {
                    if (DateTime.Now > m_LastClickTime.AddSeconds(0.5))
                    {
                        handled = true;
                    }
                    else
                    {
                        m_renderBody = !m_renderBody;
                    }
                    m_LastClickTime = DateTime.Now;
                }

                #endregion
            }

            // Store the current position
            m_LastMousePosition = new System.Drawing.Point(e.X, e.Y);

            // If we aren't handling this then let the children try if they are rendered
            if (!handled && inClientArea && m_renderBody)
            {
                for (int i = 0; i < m_ChildWidgets.Count; i++)
                {
                    if (!handled)
                    {
                        if (m_ChildWidgets[i] is jhuapl.util.IInteractive)
                        {
                            jhuapl.util.IInteractive currentInteractive = m_ChildWidgets[i] as jhuapl.util.IInteractive;
                            handled = currentInteractive.OnMouseDown(e);
                        }
                    }
                }
            }

            // If we resized or inside the form then consider it handled anyway.
            if (inClientArea)
            {
                handled = true;
            }

            return(handled);
        }
예제 #7
0
        public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            bool handled = false;

            if (m_visible)
            {
                // if we're in the client area
                if (e.X >= this.AbsoluteLocation.X &&
                    e.X <= this.AbsoluteLocation.X + ClientSize.Width &&
                    e.Y >= this.AbsoluteLocation.Y &&
                    e.Y <= this.AbsoluteLocation.Y + NODE_HEIGHT)
                {
                    if (m_isMouseDown)
                    {
                        // if we're in the expand arrow region
                        if ((e.X > this.AbsoluteLocation.X + m_xOffset) &&
                            (e.X < this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE))
                        {
                            this.Expanded = !this.Expanded;

                            // call helper routine if it exists
                            if (m_expandClickAction != null)
                            {
                                m_expandClickAction(e);
                            }
                        }
                        // else if we're supposed to use checkmark and we're in the activate/deactivate region
                        else if (m_enableCheck &&
                                 (e.X > this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE) &&
                                 (e.X < this.AbsoluteLocation.X + m_xOffset + NODE_ARROW_SIZE + NODE_CHECKBOX_SIZE))
                        {
                            this.Enabled = !this.Enabled;

                            // call helper routine if it exists
                            if (m_checkClickAction != null)
                            {
                                m_checkClickAction(e);
                            }
                        }
                        // Otherwise perform general LMB, RMB action
                        else if ((e.Button == System.Windows.Forms.MouseButtons.Left) && (m_leftClickAction != null))
                        {
                            m_leftClickAction(e);
                        }
                        else if ((e.Button == System.Windows.Forms.MouseButtons.Right) && (m_rightClickAction != null))
                        {
                            m_rightClickAction(e);
                        }

                        handled = true;
                    }
                }
            }

            // if mouse isn't over us, let the children try as we should be inside the top form client area
            if (!handled)
            {
                for (int i = 0; i < m_subNodes.Count; i++)
                {
                    if (m_subNodes[i] is jhuapl.util.IInteractive)
                    {
                        jhuapl.util.IInteractive currentInteractive = m_subNodes[i] as jhuapl.util.IInteractive;
                        handled = currentInteractive.OnMouseUp(e);
                    }

                    // if anyone has handled this, we're done
                    if (handled)
                    {
                        continue;
                    }
                }
            }

            // regardless reset mousedown point
            m_isMouseDown = false;

            return(handled);
        }