Exemplo n.º 1
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            var horizontal = false;

            if (_hScrollBar.Visible && ModifierKeys == Keys.Control)
            {
                horizontal = true;
            }

            if (_hScrollBar.Visible && !_vScrollBar.Visible)
            {
                horizontal = true;
            }

            if (!horizontal)
            {
                if (e.Delta > 0)
                {
                    _vScrollBar.ScrollByPhysical(3);
                }
                else if (e.Delta < 0)
                {
                    _vScrollBar.ScrollByPhysical(-3);
                }
            }
            else
            {
                if (e.Delta > 0)
                {
                    _hScrollBar.ScrollByPhysical(3);
                }
                else if (e.Delta < 0)
                {
                    _hScrollBar.ScrollByPhysical(-3);
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            // ReSharper disable once ReplaceWithSingleAssignment.False
            var horizontal = false;

            if (HScrollBar.Visible && ModifierKeys == Keys.Control)
            {
                horizontal = true;
            }

            if (HScrollBar.Visible && !VScrollBar.Visible)
            {
                horizontal = true;
            }

            if (!horizontal)
            {
                float speed    = MouseWheelScrollSpeedV * e.Delta;
                int   speedInt = (int)Math.Min(1073741824, Math.Max(-1073741824, speed));
                if (speedInt == 0)
                {
                    speedInt = speed > 0 ? 1 : -1;
                }
                VScrollBar.ScrollByPhysical(speedInt);
            }
            else
            {
                float speed    = MouseWheelScrollSpeedH * e.Delta;
                int   speedInt = (int)Math.Min(1073741824, Math.Max(-1073741824, speed));
                if (speedInt == 0)
                {
                    speedInt = speed > 0 ? 1 : -1;
                }
                HScrollBar.ScrollByPhysical(speedInt);
            }
        }