コード例 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (ShowSizingGrip && SizingGripBounds.Contains(e.X, e.Y))
            {
                Cursor = Cursors.SizeNWSE;
            }
            else if (Cursor == Cursors.SizeNWSE)
            {
                Cursor = Cursors.Default;
            }

            if (_resizing)
            {
                int dx = e.X - _resizeOrigin.X;
                int dy = e.Y - _resizeOrigin.Y;

                int w = _resizeSize.Width + dx;
                int h = _resizeSize.Height + dy;

                if (w != Width || h != Height)
                {
                    Width  = w;
                    Height = h;
                    UpdateItemsBounds();
                    Invalidate();
                }
            }
        }
コード例 #2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (ShowSizingGrip && SizingGripBounds.Contains(e.X, e.Y))
            {
                Cursor = Cursors.SizeNWSE;
            }
            else if (Cursor == Cursors.SizeNWSE)
            {
                Cursor = Cursors.Default;
            }

            if (_resizing)
            {
                int dx = e.X - _resizeOrigin.X;
                int dy = e.Y - _resizeOrigin.Y;

                int w = _resizeSize.Width + dx;
                int h = _resizeSize.Height + dy;

                if (w != Width || h != Height)
                {
                    Size = new Size(w, h);
                    if (WrappedDropDown != null)
                    {
                        WrappedDropDown.Size = Size;
                    }
                    int contentHeight = Bounds.Height - OwnerRibbon.DropDownMargin.Vertical - _sizingGripBounds.Height;
                    if (contentHeight < _fullContentBounds.Height)
                    {
                        _scrollBarEnabled = true;
                        if (-_offset + contentHeight > _fullContentBounds.Height)
                        {
                            _offset = contentHeight - _fullContentBounds.Height;
                        }
                    }
                    else
                    {
                        _scrollBarEnabled = false;
                    }

                    SetBounds();
                    Invalidate();
                }
            }

            if (ButtonDownPressed && ButtonDownSelected && ButtonDownEnabled)
            {
                ScrollOffset(-1);
            }

            if (ButtonUpPressed && ButtonUpSelected && ButtonUpEnabled)
            {
                ScrollOffset(1);
            }

            bool upCache    = _buttonUpSelected;
            bool downCache  = _buttonDownSelected;
            bool thumbCache = _thumbSelected;

            _buttonUpSelected   = _buttonUpBounds.Contains(e.Location);
            _buttonDownSelected = _buttonDownBounds.Contains(e.Location);
            _thumbSelected      = _thumbBounds.Contains(e.Location) && ScrollBarEnabled;

            if ((upCache != _buttonUpSelected) ||
                (downCache != _buttonDownSelected) ||
                (thumbCache != _thumbSelected))
            {
                Invalidate();
            }

            if (ThumbPressed)
            {
                int newval = e.Y - _thumbOffset;

                if (newval < ScrollMinimum)
                {
                    newval = ScrollMinimum;
                }
                else if (newval > ScrollMaximum)
                {
                    newval = ScrollMaximum;
                }

                ScrollValue = newval;
                Invalidate();
            }
        }