public void Draw(Graphics gr, Rectangle drawRect, ScrollBarArrow type, System.Drawing.Color parentColor) { if (this._borderStyle != ScrollBarBorderStyle.None) { Resco.Controls.ScrollBar.ScrollBar.BorderSide all = Resco.Controls.ScrollBar.ScrollBar.BorderSide.All; if (!this._borderClosed) { switch (type) { case ScrollBarArrow.Left: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Right; break; case ScrollBarArrow.Right: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Left; break; case ScrollBarArrow.Up: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Down; break; case ScrollBarArrow.Down: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Up; break; } } Resco.Controls.ScrollBar.ScrollBar.DoDrawBorder(gr, this._borderStyle, this._borderColor, drawRect, all, parentColor); drawRect.Inflate(-1, -1); if (all != Resco.Controls.ScrollBar.ScrollBar.BorderSide.All) { if ((type == ScrollBarArrow.Left) || (type == ScrollBarArrow.Right)) { drawRect.Width++; if (type == ScrollBarArrow.Right) { drawRect.X--; } } else { drawRect.Height++; if (type == ScrollBarArrow.Down) { drawRect.Y--; } } } } if ((drawRect.Width > 0) && (drawRect.Height > 0)) { if (this._image != null) { gr.DrawImage(this._image, drawRect, new Rectangle(0, 0, this._image.Width, this._image.Height), GraphicsUnit.Pixel); } else if (this._gradientColor.CanDraw()) { this._gradientColor.DrawGradient(gr, drawRect); } else { gr.FillRectangle(Resco.Controls.ScrollBar.ScrollBar.GetBrush(this._color), drawRect); } Region clip = gr.Clip; Region helperRegion = Resco.Controls.ScrollBar.ScrollBar.GetHelperRegion(); helperRegion.MakeEmpty(); helperRegion.Union(drawRect); gr.Clip = helperRegion; this.DoDrawArrow(gr, drawRect, type); 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); } }
protected override void OnPaint(ScrollBarExtensionBase.DrawExtensionEventArgs e) { Rectangle bounds = e.Bounds; Graphics gr = e.Graphics; if (this._borderStyle != ScrollBarBorderStyle.None) { ScrollBarExtensionBase.ComponentLocation location = base.Location; Resco.Controls.ScrollBar.ScrollBar.BorderSide all = Resco.Controls.ScrollBar.ScrollBar.BorderSide.All; if (!this._borderClosed) { switch (location) { case ScrollBarExtensionBase.ComponentLocation.Left: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Right; break; case ScrollBarExtensionBase.ComponentLocation.Right: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Left; break; case ScrollBarExtensionBase.ComponentLocation.Top: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Down; break; case ScrollBarExtensionBase.ComponentLocation.Bottom: all &= ~Resco.Controls.ScrollBar.ScrollBar.BorderSide.Up; break; } } Resco.Controls.ScrollBar.ScrollBar.DoDrawBorder(gr, this._borderStyle, this._borderColor, bounds, all, e.ParentColor); bounds.Inflate(-1, -1); if (all != Resco.Controls.ScrollBar.ScrollBar.BorderSide.All) { switch (location) { case ScrollBarExtensionBase.ComponentLocation.Left: case ScrollBarExtensionBase.ComponentLocation.Right: bounds.Width++; if (location == ScrollBarExtensionBase.ComponentLocation.Right) { bounds.X--; } goto Label_00D6; } bounds.Height++; if (location == ScrollBarExtensionBase.ComponentLocation.Bottom) { bounds.Y--; } } } Label_00D6: if ((bounds.Width > 0) && (bounds.Height > 0)) { if (this._image != null) { gr.DrawImage(this._image, bounds, new Rectangle(0, 0, this._image.Width, this._image.Height), GraphicsUnit.Pixel); } else if (this._gradientColor.CanDraw()) { this._gradientColor.DrawGradient(gr, bounds); } else { gr.FillRectangle(Resco.Controls.ScrollBar.ScrollBar.GetBrush(this._color), bounds); } this.DrawLetters(gr, bounds); } base.OnPaint(e); }