Example #1
0
        private void InvalidatePart(CustomScrollBarPart area)
        {
            switch (area)
            {
            case CustomScrollBarPart.DecreaseButton:
                Invalidate(DecreaseButtonBounds);
                break;

            case CustomScrollBarPart.IncreaseButton:
                Invalidate(IncreaseButtonBounds);
                break;

            case CustomScrollBarPart.DecreaseTrackBar:
                Invalidate(DecreaseTrackBarBounds);
                break;

            case CustomScrollBarPart.IncreaseTrackBar:
                Invalidate(IncreaseTrackBarBounds);
                break;

            case CustomScrollBarPart.Thumb:
                Invalidate(ThumbBounds);
                break;
            }
        }
        protected override void RenderPart(CustomScrollBarPart part, Orientation scrollBarOrientation, Graphics graphics, Rectangle bounds, bool isEnabled, bool isHovered, bool isPressed)
        {
            if (bounds.Width <= 0 || bounds.Height <= 0)
            {
                return;
            }

            switch (part)
            {
            case CustomScrollBarPart.DecreaseButton:
                switch (scrollBarOrientation)
                {
                case Orientation.Horizontal:
                    RenderLeftArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                case Orientation.Vertical:
                    RenderUpArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                default:
                    throw new ArgumentException();
                }
                break;

            case CustomScrollBarPart.DecreaseTrackBar:
                RenderTrackBar(graphics, bounds);
                break;

            case CustomScrollBarPart.Thumb:
                switch (scrollBarOrientation)
                {
                case Orientation.Horizontal:
                    RenderHorizontalThumb(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                case Orientation.Vertical:
                    RenderVerticalThumb(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                default:
                    throw new ArgumentException();
                }
                break;

            case CustomScrollBarPart.IncreaseTrackBar:
                RenderTrackBar(graphics, bounds);
                break;

            case CustomScrollBarPart.IncreaseButton:
                switch (scrollBarOrientation)
                {
                case Orientation.Horizontal:
                    RenderRightArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                case Orientation.Vertical:
                    RenderDownArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                    break;

                default:
                    throw new ArgumentException();
                }
                break;
            }
        }
Example #3
0
 public virtual void Render(
     Orientation scrollBarOrientation, bool isEnabled, Graphics graphics, Rectangle clipRectangle,
     Rectangle decreaseButtonBounds, Rectangle decreaseTrackBarBounds, Rectangle thumbBounds, Rectangle increaseTrackBarBounds, Rectangle increaseButtonBounds,
     CustomScrollBarPart hoveredPart, CustomScrollBarPart pressedPart)
 {
     if (pressedPart != CustomScrollBarPart.None)
     {
         hoveredPart = pressedPart;
     }
     if (decreaseButtonBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.DecreaseButton,
             scrollBarOrientation,
             graphics,
             decreaseButtonBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.DecreaseButton,
             pressedPart == CustomScrollBarPart.DecreaseButton);
     }
     if (decreaseTrackBarBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.DecreaseTrackBar,
             scrollBarOrientation,
             graphics,
             decreaseTrackBarBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.DecreaseTrackBar,
             pressedPart == CustomScrollBarPart.DecreaseTrackBar);
     }
     if (thumbBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.Thumb,
             scrollBarOrientation,
             graphics,
             thumbBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.Thumb,
             pressedPart == CustomScrollBarPart.Thumb);
     }
     if (increaseTrackBarBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.IncreaseTrackBar,
             scrollBarOrientation,
             graphics,
             increaseTrackBarBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.IncreaseTrackBar,
             pressedPart == CustomScrollBarPart.IncreaseTrackBar);
     }
     if (increaseButtonBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.IncreaseButton,
             scrollBarOrientation,
             graphics,
             increaseButtonBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.IncreaseButton,
             pressedPart == CustomScrollBarPart.IncreaseButton);
     }
 }
Example #4
0
 protected abstract void RenderPart(CustomScrollBarPart part, Orientation scrollBarOrientation, Graphics graphics, Rectangle bounds, bool isEnabled, bool isHovered, bool isPressed);
Example #5
0
 private void InvalidatePart(CustomScrollBarPart area)
 {
     switch(area)
     {
         case CustomScrollBarPart.DecreaseButton:
             Invalidate(DecreaseButtonBounds);
             break;
         case CustomScrollBarPart.IncreaseButton:
             Invalidate(IncreaseButtonBounds);
             break;
         case CustomScrollBarPart.DecreaseTrackBar:
             Invalidate(DecreaseTrackBarBounds);
             break;
         case CustomScrollBarPart.IncreaseTrackBar:
             Invalidate(IncreaseTrackBarBounds);
             break;
         case CustomScrollBarPart.Thumb:
             Invalidate(ThumbBounds);
             break;
     }
 }
Example #6
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     if(PressedPart != CustomScrollBarPart.None)
     {
         if(PressedPart == CustomScrollBarPart.Thumb)
         {
             if(EndScroll(_mouseDownPoint, e.Location))
             {
                 Invalidate();
             }
             var value = ClampValue(ThumbPositionToValue());
             if(Value != value)
             {
                 _value = value;
                 OnValueChanged();
             }
             OnScroll(ScrollEventType.ThumbPosition, _trackValue, value);
             OnScroll(ScrollEventType.EndScroll, value, value);
         }
         else
         {
             if(_timer.Enabled)
             {
                 _timer.Enabled = false;
                 OnScroll(ScrollEventType.EndScroll, Value, Value);
             }
         }
         PressedPart = CustomScrollBarPart.None;
     }
     base.OnMouseUp(e);
 }
Example #7
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     switch(e.Button)
     {
         case MouseButtons.Left:
             PressedPart = HitTest(e.X, e.Y);
             _mouseDownPoint = e.Location;
             switch(PressedPart)
             {
                 case CustomScrollBarPart.DecreaseButton:
                 case CustomScrollBarPart.DecreaseTrackBar:
                 case CustomScrollBarPart.IncreaseTrackBar:
                 case CustomScrollBarPart.IncreaseButton:
                     OnTimerTick(_timer, EventArgs.Empty);
                     _timer.Interval = 400;
                     _timer.Enabled = true;
                     break;
                 case CustomScrollBarPart.Thumb:
                     _trackValue = Value;
                     OnScroll(ScrollEventType.ThumbTrack, _trackValue, _trackValue);
                     BeginScroll(_mouseDownPoint);
                     break;
             }
             break;
     }
     base.OnMouseDown(e);
 }
Example #8
0
 public virtual void Render(
     Orientation scrollBarOrientation, bool isEnabled, Graphics graphics, Rectangle clipRectangle,
     Rectangle decreaseButtonBounds, Rectangle decreaseTrackBarBounds, Rectangle thumbBounds, Rectangle increaseTrackBarBounds, Rectangle increaseButtonBounds,
     CustomScrollBarPart hoveredPart, CustomScrollBarPart pressedPart)
 {
     if(pressedPart != CustomScrollBarPart.None)
     {
         hoveredPart = pressedPart;
     }
     if(decreaseButtonBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.DecreaseButton,
             scrollBarOrientation,
             graphics,
             decreaseButtonBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.DecreaseButton,
             pressedPart == CustomScrollBarPart.DecreaseButton);
     }
     if(decreaseTrackBarBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.DecreaseTrackBar,
             scrollBarOrientation,
             graphics,
             decreaseTrackBarBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.DecreaseTrackBar,
             pressedPart == CustomScrollBarPart.DecreaseTrackBar);
     }
     if(thumbBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.Thumb,
             scrollBarOrientation,
             graphics,
             thumbBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.Thumb,
             pressedPart == CustomScrollBarPart.Thumb);
     }
     if(increaseTrackBarBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.IncreaseTrackBar,
             scrollBarOrientation,
             graphics,
             increaseTrackBarBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.IncreaseTrackBar,
             pressedPart == CustomScrollBarPart.IncreaseTrackBar);
     }
     if(increaseButtonBounds.IntersectsWith(clipRectangle))
     {
         RenderPart(
             CustomScrollBarPart.IncreaseButton,
             scrollBarOrientation,
             graphics,
             increaseButtonBounds,
             isEnabled,
             hoveredPart == CustomScrollBarPart.IncreaseButton,
             pressedPart == CustomScrollBarPart.IncreaseButton);
     }
 }
Example #9
0
 protected abstract void RenderPart(CustomScrollBarPart part, Orientation scrollBarOrientation, Graphics graphics, Rectangle bounds, bool isEnabled, bool isHovered, bool isPressed);
Example #10
0
        protected override void RenderPart(CustomScrollBarPart part, Orientation scrollBarOrientation, Graphics graphics, Rectangle bounds, bool isEnabled, bool isHovered, bool isPressed)
        {
            if(bounds.Width <= 0 || bounds.Height <= 0) return;

            switch(part)
            {
                case CustomScrollBarPart.DecreaseButton:
                    switch(scrollBarOrientation)
                    {
                        case Orientation.Horizontal:
                            RenderLeftArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        case Orientation.Vertical:
                            RenderUpArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        default:
                            throw new ArgumentException();
                    }
                    break;
                case CustomScrollBarPart.DecreaseTrackBar:
                    RenderTrackBar(graphics, bounds);
                    break;
                case CustomScrollBarPart.Thumb:
                    switch(scrollBarOrientation)
                    {
                        case Orientation.Horizontal:
                            RenderHorizontalThumb(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        case Orientation.Vertical:
                            RenderVerticalThumb(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        default:
                            throw new ArgumentException();
                    }
                    break;
                case CustomScrollBarPart.IncreaseTrackBar:
                    RenderTrackBar(graphics, bounds);
                    break;
                case CustomScrollBarPart.IncreaseButton:
                    switch(scrollBarOrientation)
                    {
                        case Orientation.Horizontal:
                            RenderRightArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        case Orientation.Vertical:
                            RenderDownArrow(graphics, bounds, isEnabled, isHovered, isPressed);
                            break;
                        default:
                            throw new ArgumentException();
                    }
                    break;
            }
        }