protected ScrollBar(ScrollBarOrientation orientation) { this._scrollBarOrientation = orientation; this._mouseTimer = new Timer(); this._mouseTimer.Tick += new EventHandler(this.MouseTimerTick); this._mouseTimer.Interval = 100; this._mouseTimer.Enabled = false; this._clickAction = ScrollBarHitRegion.None; this._minimum = 0; this._maximum = 100; this._largeChange = 10; this._smallChange = 1; this._value = 0; this._arrowButtonsLayout = ScrollBarArrowButtonsLayout.Edges; this._leftUpButton = null; this._leftUpButtonHighlight = null; this._leftUpButtonDisabled = null; this._leftUpButtonSize = 0x13; this._rightDownButton = null; this._rightDownButtonHighlight = null; this._rightDownButtonDisabled = null; this._rightDownButtonSize = 0x13; this._lowTrack = null; this._lowTrackHighlight = null; this._lowTrackDisabled = null; this._highTrack = null; this._highTrackHighlight = null; this._highTrackDisabled = null; this._trackClickBehavior = ScrollBarTrackClickBehavior.Scroll; this._thumb = null; this._thumbHighlight = null; this._thumbDisabled = null; this._minimumThumbSize = 11; this._maximumThumbSize = 0; this._thumbMargins = new MarginPadding(); this._extension = null; this._extensionSize = 13; this._extensionLocation = ScrollBarExtensionLocation.LeftTop; this._extensionVisible = true; this._backgroundBufferBitmap = null; this._backgroundBufferGraphics = null; this._backgroundValid = BackgroundValid.Invalid; this._backBufferBitmap = null; this._backBufferGraphics = null; this.DrawTrack = null; this.DrawArrowButton = null; this.DrawThumb = null; this.ValueChanged = null; this.MinimumReached = null; this.MaximumReached = null; }
protected override void OnMouseUp(MouseEventArgs e) { this._mouseTimer.Enabled = false; switch (this._clickAction) { case ScrollBarHitRegion.LeftUpArrow: this._backgroundValid |= BackgroundValid.LeftUpArrowInvalid; break; case ScrollBarHitRegion.RightDownArrow: this._backgroundValid |= BackgroundValid.RightDownArrowInvalid; break; case ScrollBarHitRegion.TrackLow: this._backgroundValid |= BackgroundValid.LowTrackInvalid; break; case ScrollBarHitRegion.TrackHigh: this._backgroundValid |= BackgroundValid.HighTrackInvalid; break; case ScrollBarHitRegion.Extension: if (this._extension != null) { this._extension.Mouse(ScrollBarExtensionBase.MouseAction.Up, e); } break; } this._clickAction = ScrollBarHitRegion.None; base.OnMouseUp(e); base.Invalidate(); }
protected override void OnMouseDown(MouseEventArgs e) { this._clickAction = this.HitTest(e.X, e.Y, out this._thumbPos); if (((this._clickAction == ScrollBarHitRegion.TrackLow) || (this._clickAction == ScrollBarHitRegion.TrackHigh)) && (this._trackClickBehavior == ScrollBarTrackClickBehavior.Jump)) { this._mouseX = base.Left - 1; this._mouseY = base.Top - 1; this._clickAction = ScrollBarHitRegion.Thumb; this.SetValueToMousePosition(e.X, e.Y); this._backgroundValid |= BackgroundValid.HighTrackInvalid | BackgroundValid.LowTrackInvalid; this._mouseX = e.X; this._mouseY = e.Y; } else { switch (this._clickAction) { case ScrollBarHitRegion.LeftUpArrow: this.Value -= this.SmallChange; this._mouseTimer.Enabled = true; this._backgroundValid |= BackgroundValid.LeftUpArrowInvalid; goto Label_01B7; case ScrollBarHitRegion.RightDownArrow: this.Value += this.SmallChange; this._mouseTimer.Enabled = true; this._backgroundValid |= BackgroundValid.RightDownArrowInvalid; goto Label_01B7; case ScrollBarHitRegion.TrackLow: this.Value -= this.LargeChange; this._mouseTimer.Enabled = true; this._backgroundValid |= BackgroundValid.LowTrackInvalid; goto Label_01B7; case ScrollBarHitRegion.TrackHigh: this.Value += this.LargeChange; this._mouseTimer.Enabled = true; this._backgroundValid |= BackgroundValid.HighTrackInvalid; goto Label_01B7; case ScrollBarHitRegion.Thumb: this._mouseX = e.X; this._mouseY = e.Y; goto Label_01B7; case ScrollBarHitRegion.Extension: if (this._extension != null) { this._extension.Mouse(ScrollBarExtensionBase.MouseAction.Down, e); } goto Label_01B7; } } Label_01B7: base.OnMouseDown(e); base.Invalidate(); }