Esempio n. 1
0
        /// <summary>
        /// Called when the mouse pointer is moved over the non-client area of the form.
        /// </summary>
        protected internal virtual void OnMouseMove(ref Message m)
        {
            // Check for hovered and pressed buttons
            if (Control.MouseButtons != MouseButtons.Left)
            {
                if (_pressedButton != null)
                {
                    _pressedButton.Pressed = false;
                    _pressedButton         = null;
                }
            }
            CaptionButton button = CommandButtonByHitTest((HitTest)m.WParam);

            if (_hoveredButton != button && _hoveredButton != null)
            {
                _hoveredButton.Hovered = false;
            }
            if (_pressedButton == null)
            {
                if (button != null)
                {
                    button.Hovered = true;
                }
                _hoveredButton = button;
            }
            else
            {
                _pressedButton.Pressed = (button == _pressedButton);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Called when the mouse pointer is leaving the non-client area of the form.
 /// </summary>
 protected internal virtual void OnMouseLeave()
 {
     if (_pressedButton != null)
     {
         _pressedButton.Pressed = false;
     }
     if (_hoveredButton != null)
     {
         _hoveredButton.Hovered = false;
         _hoveredButton         = null;
     }
 }
Esempio n. 3
0
        protected internal override bool OnMouseUp(Message m)
        {
            if (!IsProcessNcArea)
            {
                return(false);
            }

            // do we have a pressed button?
            if (PressedButton != null)
            {
                // get button at wparam
                CaptionButton button = CommandButtonByHitTest((HitTest)m.WParam);
                if (button == null)
                {
                    return(false);
                }

                if (button.Pressed)
                {
                    switch (button.HitTest)
                    {
                    case HitTest.HTCLOSE:
                        SkiningForm.Close();
                        return(true);

                    case HitTest.HTMAXBUTTON:
                        if (SkiningForm.WindowState == FormWindowState.Maximized)
                        {
                            SkiningForm.WindowState = FormWindowState.Normal;
                            SkiningForm.Refresh();
                        }
                        else if (SkiningForm.WindowState == FormWindowState.Normal ||
                                 SkiningForm.WindowState == FormWindowState.Minimized)
                        {
                            SkiningForm.WindowState = FormWindowState.Maximized;
                        }
                        break;

                    case HitTest.HTMINBUTTON:
                        SkiningForm.WindowState = SkiningForm.WindowState == FormWindowState.Minimized
                                                          ? FormWindowState.Normal
                                                          : FormWindowState.Minimized;
                        break;
                    }
                }

                PressedButton.Pressed = false;
                PressedButton.Hovered = false;
                PressedButton         = null;
            }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// Redraws the non client area.
        /// </summary>
        /// <param name="invalidateBuffer">if set to <c>true</c> the buffer is invalidated.</param>
        /// <returns>true if the original painting should be suppressed otherwise false.</returns>
        protected internal virtual bool OnNcPaint(bool invalidateBuffer)
        {
            if (!IsProcessNcArea)
            {
                return(false);
            }
            bool result = false;

            try
            {
                SkinningFormPaintData paintData = CreatePaintData();

                // create painting meta data for caption buttons
                if (_captionButtons.Count > 0)
                {
                    paintData.CaptionButtons = new CaptionButtonPaintData[_captionButtons.Count];
                    for (int i = 0; i < _captionButtons.Count; i++)
                    {
                        CaptionButton          button     = _captionButtons[i];
                        CaptionButtonPaintData buttonData = new CaptionButtonPaintData()
                        {
                            BaseData = new PaintDataBase(_basePaintParas._bufferGraphics.Graphics, button.Bounds),
                            Pressed  = button.Pressed,
                            Hovered  = button.Hovered,
                            Enabled  = button.Enabled,
                            HitTest  = button.HitTest
                        };
                        paintData.CaptionButtons[i] = buttonData;
                    }
                }

                // paint
                result = OnNcPaint(paintData);

                // render buffered graphics
                if (_basePaintParas._bufferGraphics != null)
                {
                    _basePaintParas._bufferGraphics.Render(_basePaintParas._g);
                }
            }
            catch (System.Exception)
            {
                result = false;
            }

            _basePaintParas.Reset();
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Called when the mouse pointer is over the non-client area of the form and a mouse button is pressed.
        /// </summary>
        protected internal virtual bool OnMouseDown(ref Message m)
        {
            CaptionButton button = CommandButtonByHitTest((HitTest)m.WParam);

            if (_pressedButton != button && _pressedButton != null)
            {
                _pressedButton.Pressed = false;
            }
            if (button != null)
            {
                button.Pressed = true;
            }
            _pressedButton = button;
            if (_pressedButton != null)
            {
                m.Result = (IntPtr)1;
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
        /// <summary>
        /// Performs the non client HitTest
        /// </summary>
        /// <param name="m">The Message</param>
        /// <returns>true if the orginal handler should be suppressed otherwise false.</returns>
        protected internal virtual bool OnNcHitTest(ref Message m)
        {
            if (!IsProcessNcArea)
            {
                return(false);
            }

            Point     point      = new Point(m.LParam.ToInt32());
            Rectangle rectScreen = _systemInfoBase.ScreenRect;;
            Rectangle rect       = rectScreen;

            // custom processing
            if (rect.Contains(point))
            {
                Size borderSize = _systemInfoBase.BorderSize;
                rect.Inflate(-borderSize.Width, -borderSize.Height);

                // let form handle hittest itself if we are on borders
                if (!rect.Contains(point))
                {
                    return(false);
                }

                Rectangle rectCaption = rect;
                rectCaption.Height = _systemInfoBase.CaptionHeight;

                // not in caption -> client
                if (!rectCaption.Contains(point))
                {
                    m.Result = (IntPtr)(int)HitTest.HTCLIENT;
                    return(true);
                }

                // on icon?
                if (_systemInfoBase.IsHasMenu)
                {
                    Rectangle rectSysMenu = rectCaption;
                    rectSysMenu.Size = SystemInformation.SmallIconSize;
                    if (rectSysMenu.Contains(point))
                    {
                        m.Result = (IntPtr)(int)HitTest.HTSYSMENU;
                        return(true);
                    }
                }

                // on Button?
                Point         pt        = new Point(point.X - rectScreen.X, point.Y - rectScreen.Y);
                CaptionButton sysButton = CommandButtonFromPoint(pt);
                if (sysButton != null)
                {
                    m.Result = (IntPtr)sysButton.HitTest;
                    return(true);
                }

                // on Caption?
                m.Result = (IntPtr)(int)HitTest.HTCAPTION;
                return(true);
            }
            m.Result = (IntPtr)(int)HitTest.HTNOWHERE;
            return(true);
        }