public void Draw(Graphics gr, Rectangle drawRect, Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation orientation) { if (this._borderStyle != ScrollBarBorderStyle.None) { Resco.Controls.ScrollBar.ScrollBar.DoDrawBorder(gr, this._borderStyle, this._borderColor, drawRect, Resco.Controls.ScrollBar.ScrollBar.BorderSide.All, System.Drawing.Color.Transparent); drawRect.Inflate(-1, -1); } if ((drawRect.Width > 0) && (drawRect.Height > 0)) { Region clip = gr.Clip; Region helperRegion = Resco.Controls.ScrollBar.ScrollBar.GetHelperRegion(); helperRegion.MakeEmpty(); helperRegion.Union(drawRect); gr.Clip = helperRegion; if (this._image != null) { if (this._imageLayout == ScrollBarThumbImageLayout.Tile) { int width = drawRect.Width; int height = drawRect.Height; Rectangle destRect = new Rectangle(drawRect.Left, drawRect.Top, this._image.Width, this._image.Height); for (int i = 0; i < height; i += this._image.Height) { for (int j = 0; j < width; j += this._image.Width) { gr.DrawImage(this._image, destRect, 0, 0, this._image.Width, this._image.Height, GraphicsUnit.Pixel, this._imageAttributes); destRect.X += this._image.Width; } destRect.X = drawRect.Left; destRect.Y += this._image.Height; } } else { Rectangle rectangle2; if (this._imageLayout == ScrollBarThumbImageLayout.Center) { rectangle2 = new Rectangle(drawRect.Left + ((drawRect.Width - this._image.Width) / 2), drawRect.Top + ((drawRect.Height - this._image.Height) / 2), this._image.Width, this._image.Height); } else { rectangle2 = drawRect; } gr.DrawImage(this._image, rectangle2, 0, 0, this._image.Width, this._image.Height, GraphicsUnit.Pixel, this._imageAttributes); } } else if (this._gradientColor.CanDraw()) { this._gradientColor.DrawGradient(gr, drawRect); } else { gr.FillRectangle(Resco.Controls.ScrollBar.ScrollBar.GetBrush(this._color), drawRect); } this.DoDrawGrip(gr, drawRect, orientation); gr.Clip = clip; } }
public void Draw(Graphics gr, Rectangle drawRect, Rectangle visibleRect, Rectangle trackRect, ScrollBarTrackType type, Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation orientation, System.Drawing.Color parentColor) { if (this._borderStyle != ScrollBarBorderStyle.None) { Resco.Controls.ScrollBar.ScrollBar.BorderSide all = Resco.Controls.ScrollBar.ScrollBar.BorderSide.All; if (orientation == Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation.Horizontal) { //all &= ~((type == ScrollBarTrackType.Low) ? 4 : 1); int temp = (int)all; temp &= ~((type == ScrollBarTrackType.Low) ? 4 : 1); all = (Resco.Controls.ScrollBar.ScrollBar.BorderSide)temp; } else { //all &= ~((type == ScrollBarTrackType.Low) ? 8 : 2); int temp = (int)all; temp &= ~((type == ScrollBarTrackType.Low) ? 8 : 2); all = (Resco.Controls.ScrollBar.ScrollBar.BorderSide)temp; } Resco.Controls.ScrollBar.ScrollBar.DoDrawBorder(gr, this._borderStyle, this._borderColor, drawRect, all, parentColor); drawRect.Inflate(-1, -1); if (orientation == Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation.Horizontal) { drawRect.Width++; if (type == ScrollBarTrackType.High) { drawRect.X--; } } else { drawRect.Height++; if (type == ScrollBarTrackType.High) { drawRect.Y--; } } } if ((this._image != null) || this._gradientColor.CanDraw()) { Rectangle destRect = drawRect; Region clip = null; if (this._trackLayout == ScrollBarTrackLayout.FixedToTrack) { destRect = trackRect; clip = gr.Clip; Region helperRegion = Resco.Controls.ScrollBar.ScrollBar.GetHelperRegion(); helperRegion.MakeEmpty(); helperRegion.Union(drawRect); gr.Clip = helperRegion; } if (this._image != null) { gr.DrawImage(this._image, destRect, new Rectangle(0, 0, this._image.Width, this._image.Height), GraphicsUnit.Pixel); } else { this._gradientColor.DrawGradient(gr, destRect); } if (this._trackLayout == ScrollBarTrackLayout.FixedToTrack) { gr.Clip = clip; } } else { gr.FillRectangle(Resco.Controls.ScrollBar.ScrollBar.GetBrush(this._color), drawRect); } }
private void DoDrawGrip(Graphics gr, Rectangle drawRect, Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation orientation) { if (this._gripStyle != ScrollBarThumbGripStyle.None) { if (this._gripStyle == ScrollBarThumbGripStyle.Image) { if (this._gripImage != null) { Rectangle destRect = new Rectangle(drawRect.Left + ((drawRect.Width - this._gripImage.Width) / 2), drawRect.Top + ((drawRect.Height - this._gripImage.Height) / 2), this._gripImage.Width, this._gripImage.Height); gr.DrawImage(this._gripImage, destRect, 0, 0, this._gripImage.Width, this._gripImage.Height, GraphicsUnit.Pixel, this._gripImageAttributes); } } else if (this._gripLines > 0) { drawRect.Inflate(-1, -1); if ((drawRect.Width > 0) && (drawRect.Height > 0)) { int width = (this._gripLines * 2) - 1; if (this._gripStyle == ScrollBarThumbGripStyle.Lines) { int left = drawRect.Left; int top = drawRect.Top; int num4 = 0; int num5 = 0; int num6 = 0; int num7 = 0; if (orientation == Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation.Horizontal) { if (width < drawRect.Width) { left += (drawRect.Width - width) / 2; } else { width = drawRect.Width; } num4 = 2; num7 = drawRect.Height - 1; } else { if (width < drawRect.Height) { top += (drawRect.Height - width) / 2; } else { width = drawRect.Height; } num5 = 2; num6 = drawRect.Width - 1; } Pen pen = Resco.Controls.ScrollBar.ScrollBar.GetPen(this._gripColor); for (int i = 0; i < width; i += 2) { gr.DrawLine(pen, left, top, left + num6, top + num7); left += num4; top += num5; } } else if (this._gripStyle == ScrollBarThumbGripStyle.Dots) { int num9 = 0; int height = 0; int num12 = drawRect.Left; int y = drawRect.Top; if (orientation == Resco.Controls.ScrollBar.ScrollBar.ScrollBarOrientation.Horizontal) { if (width < drawRect.Width) { num12 += (drawRect.Width - width) / 2; } else { width = drawRect.Width; } num9 = width; height = drawRect.Height; } else { if (width < drawRect.Height) { y += (drawRect.Height - width) / 2; } else { width = drawRect.Height; } num9 = drawRect.Width; height = width; } for (int j = 0; j < height; j += 2) { int x = num12; for (int k = 0; k < num9; k += 2) { Resco.Controls.ScrollBar.ScrollBar.DrawPixel(gr, this._gripColor, x, y); x += 2; } y += 2; } } } } } }