Пример #1
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 IInteractive)
                    {
                        IInteractive currentInteractive = m_subNodes[i] as IInteractive;
                        bool         subHandled         = currentInteractive.OnMouseUp(e);
                        if (subHandled)
                        {
                            handled = true;
                        }
                    }

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

            // regardless reset mousedown point
            m_isMouseDown = false;

            return(handled);
        }
Пример #2
0
        public bool OnMouseUp(System.Windows.Forms.MouseEventArgs e)
        {
            if (!Visible)
            {
                return(false);
            }

            bool handled = false;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                if (m_IsDragging)
                {
                    m_IsDragging = false;
                }
            }

            bool inClientArea = false;

            if (e.X >= ClientLocation.X &&
                e.X <= ClientLocation.X + m_Size.Width &&
                e.Y >= ClientLocation.Y &&
                e.Y <= ClientLocation.Y + m_Size.Height)
            {
                inClientArea = true;
            }

            if (inClientArea)
            {
                if (!m_HideHeader && isPointInCloseBox(new System.Drawing.Point(e.X, e.Y)))
                {
                    Visible = false;
                    handled = true;
                }
            }

            for (int i = 0; i < m_ChildWidgets.Count; i++)
            {
                if (m_ChildWidgets[i] is IInteractive)
                {
                    IInteractive currentInteractive = m_ChildWidgets[i] as IInteractive;
                    handled = currentInteractive.OnMouseUp(e);
                }
            }

            if (!handled && inClientArea)
            {
                handled = true;
            }

            if (isResizingTop)
            {
                isResizingTop = false;
            }
            if (isResizingBottom)
            {
                isResizingBottom = false;
            }
            if (isResizingLeft)
            {
                isResizingLeft = false;
            }
            if (isResizingRight)
            {
                isResizingRight = false;
            }
            if (isResizingUL)
            {
                isResizingUL = false;
            }
            if (isResizingUR)
            {
                isResizingUR = false;
            }
            if (isResizingLL)
            {
                isResizingLL = false;
            }
            if (isResizingLR)
            {
                isResizingLR = false;
            }

            return(handled);
        }