public override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (ButtonDownSelected || ButtonUpSelected || ButtonDropDownSelected) { IgnoreDeactivation(); } if (ButtonDownSelected && ButtonDownEnabled) { _buttonDownPressed = true; ScrollDown(); } if (ButtonUpSelected && ButtonUpEnabled) { _buttonUpPressed = true; ScrollUp(); } if (ButtonDropDownSelected) { _buttonDropDownPressed = true; ShowDropDown(); } if (ThumbSelected) { _thumbPressed = true; _thumbOffset = e.Y - _thumbBounds.Y; } if ( ScrollType == ListScrollType.Scrollbar && ScrollBarBounds.Contains(e.Location) && e.Y >= ButtonUpBounds.Bottom && e.Y <= ButtonDownBounds.Y && !ThumbBounds.Contains(e.Location) && !ButtonDownBounds.Contains(e.Location) && !ButtonUpBounds.Contains(e.Location)) { //clicked the scroll area above or below the thumb if (e.Y < ThumbBounds.Y) { ScrollOffset(ContentBounds.Height); } else { ScrollOffset(-ContentBounds.Height); } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (Cursor == Cursors.SizeNWSE) { _resizeOrigin = new Point(e.X, e.Y); _resizeSize = Size; _resizing = true; } if (ButtonDownSelected || ButtonUpSelected) { IgnoreDeactivation(); } if (ButtonDownSelected && ButtonDownEnabled) { _buttonDownPressed = true; ScrollDown(); } if (ButtonUpSelected && ButtonUpEnabled) { _buttonUpPressed = true; ScrollUp(); } if (ThumbSelected) { _thumbPressed = true; _thumbOffset = e.Y - _thumbBounds.Y; } if ( ScrollBarBounds.Contains(e.Location) && e.Y >= ButtonUpBounds.Bottom && e.Y <= ButtonDownBounds.Y && !ThumbBounds.Contains(e.Location) && !ButtonDownBounds.Contains(e.Location) && !ButtonUpBounds.Contains(e.Location)) { if (e.Y < ThumbBounds.Y) { ScrollOffset(Bounds.Height); } else { ScrollOffset(-Bounds.Height); } } }
private CustomScrollBarPart HitTest(int x, int y) { if (DecreaseButtonBounds.Contains(x, y)) { return(CustomScrollBarPart.DecreaseButton); } if (IncreaseButtonBounds.Contains(x, y)) { return(CustomScrollBarPart.IncreaseButton); } if (DecreaseTrackBarBounds.Contains(x, y)) { return(CustomScrollBarPart.DecreaseTrackBar); } if (IncreaseTrackBarBounds.Contains(x, y)) { return(CustomScrollBarPart.IncreaseTrackBar); } if (ThumbBounds.Contains(x, y)) { return(CustomScrollBarPart.Thumb); } return(CustomScrollBarPart.None); }