Eto Scroll bar style

you can further expand the ScrollablePanel here by overriding OnPaint event, MouseDown, MouseMove…etc

    class ScrollablePanel : Drawable
    {
        //variables here
        public ScrollablePanel(Control control)
        {
            _control = control;
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            OnSizeChanged(e);
            _control.Width = _displayFrameWidth - Padding.Horizontal;
            _layout = new PixelLayout() { };
            _layout.Add(_control, 0, _currentLocation);
            Content = _layout;
        }
        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);
            if (!activateScrollBar) return;

            var moveDelta = (int)e.Delta.Height * scrollFactor;
            _currentLocation += moveDelta;
            CheckScrollBarExceedsBounds(ref _currentLocation);

            _layout.Move(_control, new Point(0, _currentLocation));

        private bool CheckScrollBarExceedsBounds(ref int _location)
        {
            if (_location >= 1)
            {
                _location = 0;
                return true;
            }
            else if (_displayFrameHeight - _control.GetPreferredSize().Height - scrollBuffer > _location)
            {
                _location = _displayFrameHeight - (int)_control.GetPreferredSize().Height - scrollBuffer;
                return true;
            }
            else return false;
        }
4 Likes