void SetupHorizontalScrollButtonProperties(RenderElement container) { var scroll_button = new ScrollBarButton(10, this.Height, this); //create with default value scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue); int thumbPosX = CalculateThumbPosition() + minmax_boxHeight; scroll_button.SetLocation(thumbPosX, 0); container.AddChild(scroll_button); this.scrollButton = scroll_button; //---------------------------- EvaluateHorizontalScrollBarProperties(); //---------------------------- //3. drag scroll_button.MouseDrag += (s, e) => { //dragging ... //find x-diff Point pos = scroll_button.Position; //if vscroll bar then move only y axis int newXPos = (int)(pos.X + e.DiffCapturedX); //clamp! if (newXPos >= this.Width - (minmax_boxHeight + scrollButton.Width)) { newXPos = this.Width - (minmax_boxHeight + scrollButton.Width); } else if (newXPos < minmax_boxHeight) { newXPos = minmax_boxHeight; } //calculate value from position int currentMarkAt = (newXPos - minmax_boxHeight); this.scrollValue = (float)(onePixelFor * currentMarkAt); newXPos = CalculateThumbPosition() + minmax_boxHeight; scroll_button.SetLocation(newXPos, pos.Y); if (this.UserScroll != null) { this.UserScroll(this, EventArgs.Empty); } e.StopPropagation(); }; }
void SetupMinButtonProperties(RenderElement container) { ScrollBarButton min_button; if (this.ScrollBarType == ScrollBarType.Horizontal) { min_button = new ScrollBarButton(minmax_boxHeight, this.Height, this); } else { min_button = new ScrollBarButton(this.Width, minmax_boxHeight, this); } min_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray); min_button.MouseUp += (s, e) => this.StepSmallToMin(); container.AddChild(min_button); this.minButton = min_button; }
void SetupVerticalScrollButtonProperties(RenderElement container) { var scroll_button = new ScrollBarButton(this.Width, 10, this); //create with default value scroll_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkBlue); int thumbPosY = CalculateThumbPosition() + _minmax_boxHeight; scroll_button.SetLocation(0, thumbPosY); container.AddChild(scroll_button); _scrollButton = scroll_button; //---------------------------- EvaluateVerticalScrollBarProperties(); //---------------------------- //3. drag scroll_button.MouseDrag += (s, e) => { //dragging ... Point pos = scroll_button.Position; //if vscroll bar then move only y axis int newYPos = (int)(pos.Y + e.DiffCapturedY); //clamp! if (newYPos >= this.Height - (_minmax_boxHeight + _scrollButton.Height)) { newYPos = this.Height - (_minmax_boxHeight + _scrollButton.Height); } else if (newYPos < _minmax_boxHeight) { newYPos = _minmax_boxHeight; } //calculate value from position int currentMarkAt = (newYPos - _minmax_boxHeight); _scrollValue = (float)(_onePixelFor * currentMarkAt); newYPos = CalculateThumbPosition() + _minmax_boxHeight; scroll_button.SetLocation(pos.X, newYPos); if (this.UserScroll != null) { this.UserScroll(this, EventArgs.Empty); } e.StopPropagation(); }; }
void SetupMaxButtonProperties(RenderElement container) { ScrollBarButton max_button; if (this.ScrollBarType == ScrollBarType.Horizontal) { max_button = new ScrollBarButton(_minmax_boxHeight, this.Height, this); max_button.SetLocation(this.Width - _minmax_boxHeight, 0); } else { max_button = new ScrollBarButton(this.Width, _minmax_boxHeight, this); max_button.SetLocation(0, this.Height - _minmax_boxHeight); } max_button.BackColor = KnownColors.FromKnownColor(KnownColor.DarkGray); max_button.MouseUp += (s, e) => this.StepSmallToMax(); container.AddChild(max_button); _maxButton = max_button; }