/// <summary> /// Draws the background. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawBackground( Graphics g, Rectangle rect, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.VERTICAL) { DrawBackgroundVertical(g, rect); } else { DrawBackgroundHorizontal(g, rect); } }
public static ScrollBar Factory(ScrollBarOrientation orientation, int length, ScrollViewer parent) { if (length < 3) { throw new ArgumentOutOfRangeException("A ScrollBar must be at least 3 cells long!"); } ScrollBar s; if (orientation == ScrollBarOrientation.HORIZONTAL) { s = new ScrollBar(length, 1); } else if (orientation == ScrollBarOrientation.VERTICAL) { s = new ScrollBar(1, length); } else { throw new InvalidEnumArgumentException(); } s.Orientation = orientation; s.Length = length; s.Viewer = parent; return(s); }
/// <summary> /// Draws the thumb. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { if (g == null) throw new ArgumentNullException("g"); if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect) || state == ScrollBarState.Disabled) return; Color color; switch (state) { case ScrollBarState.Hot: color = foreColorHot; break; case ScrollBarState.Pressed: color = foreColorPressed; break; default: color = foreColor; break; } switch (orientation) { case ScrollBarOrientation.Vertical: DrawThumbVertical(g, rect, color); break; default: DrawThumbHorizontal(g, rect, color); break; } }
/// <summary> /// Draws the channel ( or track ). /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The scrollbar state.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawTrack( Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.Width <= 0 || rect.Height <= 0 || state != ScrollBarState.PRESSED || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.VERTICAL) { DrawTrackVertical(g, rect); } else { DrawTrackHorizontal(g, rect); } }
/// <summary> /// Draws the thumb. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawThumb( Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect) || state == ScrollBarState.DISABLED) { return; } if (orientation == ScrollBarOrientation.VERTICAL) { DrawThumbVertical(g, rect, state); } else { DrawThumbHorizontal(g, rect, state); } }
/// <summary> /// Draws an arrow button. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param> /// <param name="arrowUp">true for an up arrow, false otherwise.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawArrowButton( Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.VERTICAL) { DrawArrowButtonVertical(g, rect, state, arrowUp); } else { DrawArrowButtonHorizontal(g, rect, state, arrowUp); } }
/// <summary> /// Adjusts the thumb grip according to the specified <see cref="ScrollBarOrientation"/>. /// </summary> /// <param name="rect">The rectangle to adjust.</param> /// <param name="orientation">The scrollbar orientation.</param> /// <param name="gripImage">The grip image.</param> /// <returns>The adjusted rectangle.</returns> /// <remarks>Also rotates the grip image if necessary.</remarks> private static Rectangle AdjustThumbGrip( Rectangle rect, ScrollBarOrientation orientation, Image gripImage) { Rectangle r = rect; r.Inflate(-1, -1); if (orientation == ScrollBarOrientation.VERTICAL) { r.X += 3; r.Y += (r.Height / 2) - (gripImage.Height / 2); } else { gripImage.RotateFlip(RotateFlipType.Rotate90FlipNone); r.X += (r.Width / 2) - (gripImage.Width / 2); r.Y += 3; } r.Width = gripImage.Width; r.Height = gripImage.Height; return(r); }
public void DrawScrollBar(Graphics g, ScrollBarOrientation orientation) { switch (orientation) { case ScrollBarOrientation.Horizontal: if (!_isHorizontalVisible) { break; } // Background var backgroundRect = new RectangleF(new PointF(0, _clientSize.Height - ScrollBarWidth_), new SizeF(_clientSize.Width - GetScrollBarWidth(ScrollBarOrientation.Vertical), ScrollBarWidth_)); g.FillRectangle(ScrollBarBackgroundColor, backgroundRect); // Arrows g.DrawLines(ScrollBarArrow, new PointF(11, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4), new PointF(6, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 2), new PointF(11, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 3)); g.DrawLines(ScrollBarArrow, new PointF(_clientSize.Width - GetScrollBarWidth(ScrollBarOrientation.Vertical) - ArrowLength_ + 6, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4), new PointF(_clientSize.Width - GetScrollBarWidth(ScrollBarOrientation.Vertical) - ArrowLength_ + 11, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 2), new PointF(_clientSize.Width - GetScrollBarWidth(ScrollBarOrientation.Vertical) - ArrowLength_ + 6, _clientSize.Height - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 3)); // Slider g.FillRectangle(ScrollBarColor, GetSliderRect(ScrollBarOrientation.Horizontal)); break; case ScrollBarOrientation.Vertical: if (!_isVerticalVisible) { break; } // Background var backgroundRect1 = new RectangleF(new PointF(_clientSize.Width - ScrollBarWidth_, 0), new SizeF(ScrollBarWidth_, _clientSize.Height - GetScrollBarWidth(ScrollBarOrientation.Horizontal))); g.FillRectangle(ScrollBarBackgroundColor, backgroundRect1); // Arrows g.DrawLines(ScrollBarArrow, new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4, 11), new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 2, 6), new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 3, 11)); g.DrawLines(ScrollBarArrow, new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4, _clientSize.Height - GetScrollBarWidth(ScrollBarOrientation.Horizontal) - ArrowLength_ + 6), new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 2, _clientSize.Height - GetScrollBarWidth(ScrollBarOrientation.Horizontal) - ArrowLength_ + 11), new PointF(_clientSize.Width - ScrollBarWidth_ + ScrollBarWidth_ / 4 * 3, _clientSize.Height - GetScrollBarWidth(ScrollBarOrientation.Horizontal) - ArrowLength_ + 6)); // Slider g.FillRectangle(ScrollBarColor, GetSliderRect(ScrollBarOrientation.Vertical)); break; } }
public RectangleF GetSliderRect(ScrollBarOrientation orientation) { var sliderPosition = GetSliderPosition(orientation); switch (orientation) { case ScrollBarOrientation.Horizontal: if (!_isHorizontalVisible) { return(default); } return(new RectangleF(new PointF(sliderPosition, _clientSizeWithoutBar.Height), new SizeF(_horizontalSliderSize, ScrollBarWidth_ - 1)));
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; }
public int GetScrollBarWidth(ScrollBarOrientation orientation) { switch (orientation) { case ScrollBarOrientation.Horizontal: return(_isHorizontalVisible ? ScrollBarWidth_ : 0); case ScrollBarOrientation.Vertical: return(_isVerticalVisible ? ScrollBarWidth_ : 0); default: throw new InvalidOperationException($"Unsupported orientation: {orientation}."); } }
/// <summary> /// Draws the background. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> private void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation orientation) { if (g == null) throw new ArgumentNullException("g"); if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) return; switch (orientation) { case ScrollBarOrientation.Vertical: DrawBackgroundVertical(g, rect); break; default: DrawBackgroundHorizontal(g, rect); break; } }
/// <summary> /// Draws the background. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> private void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.Vertical) { DrawBackgroundVertical(g, rect); } else { DrawBackgroundHorizontal(g, rect); } }
/// <summary> /// Draws the thumb. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarState"/> of the thumb.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> private void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect) || state == ScrollBarState.Disabled) { return; } if (orientation == ScrollBarOrientation.Vertical) { DrawThumbVertical(g, rect, state); } else { DrawThumbHorizontal(g, rect, state); } }
public void DrawThumb(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { switch (state) { case ScrollBarState.Disabled: case ScrollBarState.Normal: case ScrollBarState.Active: g.FillRectangle(ThumbBrush, rect); break; case ScrollBarState.Pressed: g.FillRectangle(ThumbPressedBrush, rect); break; default: g.FillRectangle(ThumbHoverBrush, rect); break; } }
public ScrollBar(ScrollBarOrientation orientation) { this.Orientation = orientation; this.baseImage = new ImageBox(); base.AddChildLast(this.baseImage); this.barImage = new ImageBox(); base.AddChildLast(this.barImage); switch (this.Orientation) { case ScrollBarOrientation.Horizontal: base.Width = this.defaultScrollBarHorizontalWidth; base.Height = this.defaultScrollBarHorizontalHeight; this.baseImage.Image = new ImageAsset(SystemImageAsset.ScrollBarHorizontalBackground); this.baseImage.Width = this.defaultScrollBarHorizontalWidth; this.baseImage.Height = this.defaultScrollBarHorizontalHeight; this.baseImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ScrollBarHorizontalBackground); this.baseImage.ImageScaleType = ImageScaleType.NinePatch; this.barImage.Image = new ImageAsset(SystemImageAsset.ScrollBarHorizontalBar); this.barImage.Width = this.defaultScrollBarHorizontalWidth; this.barImage.Height = this.defaultScrollBarHorizontalHeight; this.barImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ScrollBarHorizontalBar); this.barImage.ImageScaleType = ImageScaleType.NinePatch; return; case ScrollBarOrientation.Vertical: base.Width = this.defaultScrollBarVerticalWidth; base.Height = this.defaultScrollBarVerticalHeight; this.baseImage.Image = new ImageAsset(SystemImageAsset.ScrollBarVerticalBackground); this.baseImage.Width = this.defaultScrollBarVerticalWidth; this.baseImage.Height = this.defaultScrollBarVerticalHeight; this.baseImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ScrollBarVerticalBackground); this.baseImage.ImageScaleType = ImageScaleType.NinePatch; this.barImage.Image = new ImageAsset(SystemImageAsset.ScrollBarVerticalBar); this.barImage.Width = this.defaultScrollBarVerticalWidth; this.barImage.Height = this.defaultScrollBarVerticalHeight; this.barImage.NinePatchMargin = AssetManager.GetNinePatchMargin(SystemImageAsset.ScrollBarVerticalBar); this.barImage.ImageScaleType = ImageScaleType.NinePatch; return; default: return; } }
/// <summary> /// Draws the grip of the thumb. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawThumbGrip( Graphics g, Rectangle rect, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } // get grip image using (Image gripImage = GetGripNomalBitmap()) //Properties.ScrollBarResources.GripNormal) { // adjust rectangle and rotate grip image if necessary Rectangle r = AdjustThumbGrip(rect, orientation, gripImage); // adjust alpha channel of grip image using (ImageAttributes attr = new ImageAttributes()) { attr.SetColorMatrix( new ColorMatrix(new float[][] { new[] { 1F, 0, 0, 0, 0 }, new[] { 0, 1F, 0, 0, 0 }, new[] { 0, 0, 1F, 0, 0 }, new[] { 0, 0, 0, .8F, 0 }, new[] { 0, 0, 0, 0, 1F } }), ColorMatrixFlag.Default, ColorAdjustType.Bitmap ); // draw grip image g.DrawImage(gripImage, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, attr); } } }
public void MoveSliderBy(ScrollBarOrientation orientation, float value) { SetSliderPosition(orientation, GetSliderPosition(orientation) + value); }
public UIScrollBar(ScrollBarOrientation orientation = ScrollBarOrientation.Vertical) { Orientation = orientation; string arrowResource = string.Empty; Vector2 sliderSize = Vector2.Zero; switch (orientation) { case ScrollBarOrientation.Vertical: sliderSize = new Vector2(0, 20); arrowResource = "graphics/arrow_down"; break; case ScrollBarOrientation.Horizontal: sliderSize = new Vector2(20, 0); arrowResource = "graphics/arrow_left"; break; } AutoSize = false; scrollStep = 0.02f; Color = new Color(240, 240, 240); Alpha = 1f; DrawBounds = true; sliderBackground = new UIPanel(); sliderBackground.Color = new Color(240, 240, 240); sliderBackground.Alpha = 1f; sliderBackground.InputMoved += sliderBackground_MouseMoved; sliderBackground.InputPressed += sliderBackground_MousePressed; slider = new UIPanel(); slider.Color = new Color(205, 205, 205); slider.Alpha = 1f; slider.AutoSize = false; slider.AbsorbPointer = false; slider.Size = sliderSize; //slider.InputDown += sliderBackground_MousePressed; arrowA = new UIButton(); var arrowAImg = new UIImage(arrowResource); arrowAImg.Color = new Color(96, 96, 96); arrowAImg.AddConstraint(Edge.Dock, arrowA, Edge.Dock); arrowA.Tag = "bla"; arrowA.AddDecoration(arrowAImg); arrowA.PointedColor = new Color(190, 190, 190); arrowA.PressedColor = new Color(120, 120, 120); arrowA.HighlightZoom = false; arrowA.InputDown += arrowA_MouseHeld; arrowB = new UIButton(); var arrowBImg = new UIImage(arrowResource); arrowBImg.Color = new Color(96, 96, 96); arrowBImg.AddConstraint(Edge.Dock, arrowB, Edge.Dock); arrowB.AddDecoration(arrowBImg); arrowB.PointedColor = new Color(190, 190, 190); arrowB.PressedColor = new Color(120, 120, 120); arrowB.HighlightZoom = false; arrowB.InputDown += arrowB_MouseHeld; switch (orientation) { case ScrollBarOrientation.Vertical: arrowAImg.SpriteEffect = SpriteEffects.FlipVertically; arrowA.AddConstraint(Edge.Horizontal | Edge.Top, this, Edge.Horizontal | Edge.Top); arrowB.AddConstraint(Edge.Horizontal, this, Edge.Horizontal); arrowB.AddConstraint(Edge.Bottom, this, Edge.Bottom); sliderBackground.AddConstraint(Edge.Horizontal, this, Edge.Horizontal); sliderBackground.AddConstraint(Edge.Top, arrowA, Edge.Bottom); sliderBackground.AddConstraint(Edge.Bottom, arrowB, Edge.Top); slider.AddConstraint(Edge.Top, sliderBackground, Edge.Top, ConstraintCategory.Initialization); slider.AddConstraint(Edge.Horizontal, sliderBackground, Edge.Horizontal); break; case ScrollBarOrientation.Horizontal: arrowBImg.SpriteEffect = SpriteEffects.FlipHorizontally; arrowA.AddConstraint(Edge.Vertical | Edge.Left, this, Edge.Vertical | Edge.Left); arrowB.AddConstraint(Edge.Vertical, this, Edge.Vertical); arrowB.AddConstraint(Edge.Right, this, Edge.Right); sliderBackground.AddConstraint(Edge.Vertical, this, Edge.Vertical); sliderBackground.AddConstraint(Edge.Left, arrowA, Edge.Right); sliderBackground.AddConstraint(Edge.Right, arrowB, Edge.Left); slider.AddConstraint(Edge.Left, sliderBackground, Edge.Left, ConstraintCategory.Initialization); slider.AddConstraint(Edge.Vertical, sliderBackground, Edge.Vertical); break; } AbsorbPointer = false; //base.AbsorbPointer = true; //slider.AbsorbPointer = true; //arrowDown.AbsorbPointer = true; //arrowUp.AbsorbPointer = true; sliderBackground.AbsorbPointer = true; AddChild(arrowA); AddChild(arrowB); AddChild(sliderBackground); AddChild(slider); }
public void DrawTrack(Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { g.FillRectangle(TrackBrush, rect); }
public void DrawBackground(Graphics g, Rectangle rect, ScrollBarOrientation orientation) { g.FillRectangle(BackgroundBrush, rect); }
/// <summary> /// Adjusts the thumb grip according to the specified <see cref="ScrollBarOrientation"/>. /// </summary> /// <param name="rect">The rectangle to adjust.</param> /// <param name="orientation">The scrollbar orientation.</param> /// <param name="gripImage">The grip image.</param> /// <returns>The adjusted rectangle.</returns> /// <remarks>Also rotates the grip image if necessary.</remarks> private static Rectangle AdjustThumbGrip( Rectangle rect, ScrollBarOrientation orientation, Image gripImage) { Rectangle r = rect; r.Inflate(-1, -1); if (orientation == ScrollBarOrientation.Vertical) { r.X += 3; r.Y += (r.Height / 2) - (gripImage.Height / 2); } else { gripImage.RotateFlip(RotateFlipType.Rotate90FlipNone); r.X += (r.Width / 2) - (gripImage.Width / 2); r.Y += 3; } r.Width = gripImage.Width; r.Height = gripImage.Height; return r; }
/// <summary> /// Draws the grip of the thumb. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawThumbGrip( Graphics g, Rectangle rect, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } // get grip image using (Image gripImage = GUI.Properties.Resources.GripNormal) { // adjust rectangle and rotate grip image if necessary Rectangle r = AdjustThumbGrip(rect, orientation, gripImage); // adjust alpha channel of grip image using (ImageAttributes attr = new ImageAttributes()) { attr.SetColorMatrix( new ColorMatrix(new float[][] { new[] { 1F, 0, 0, 0, 0 }, new[] { 0, 1F, 0, 0, 0 }, new[] { 0, 0, 1F, 0, 0 }, new[] { 0, 0, 0, .8F, 0 }, new[] { 0, 0, 0, 0, 1F } }), ColorMatrixFlag.Default, ColorAdjustType.Bitmap ); // draw grip image g.DrawImage(gripImage, r, 0, 0, r.Width, r.Height, GraphicsUnit.Pixel, attr); } } }
/// <summary> /// Creates a new instance of the ScrollBar class /// </summary> /// <param name="value">The value of the ScrollBar</param> /// <param name="minValue">The minimum value of the ScrollBar</param> /// <param name="maxValue">The maximum value of the ScrollBar</param> /// <param name="orientation">The orientation of the ScrollBar</param> /// <param name="isReversed">Wether the ScrollBar is reversed or not</param> public ScrollBar(float value, float minValue, float maxValue, ScrollBarOrientation orientation, bool isReversed = false) { val = value; min = minValue; max = maxValue; this.orientation = orientation; isReversed = IsReversed; Size = orientation == ScrollBarOrientation.Horizontal ? new Vector2(100f, 16f) : new Vector2(16f, 100f); }
public void DrawThumbGrip(Graphics g, Rectangle rect, ScrollBarOrientation orientation) { //-- Don't draw a grip. //g.FillRectangle(ThumbGripBrush, rect); }
/// <summary> /// Draws an arrow button. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param> /// <param name="arrowUp">true for an up arrow, false otherwise.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawArrowButton( Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.Vertical) { DrawArrowButtonVertical(g, rect, state, arrowUp); } else { DrawArrowButtonHorizontal(g, rect, state, arrowUp); } }
public void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation) { switch (state) { case ScrollBarArrowButtonState.UpDisabled: case ScrollBarArrowButtonState.UpNormal: case ScrollBarArrowButtonState.UpActive: case ScrollBarArrowButtonState.DownDisabled: case ScrollBarArrowButtonState.DownNormal: case ScrollBarArrowButtonState.DownActive: g.FillRectangle(ArrowButtonsBrush, rect); break; case ScrollBarArrowButtonState.UpPressed: case ScrollBarArrowButtonState.DownPressed: g.FillRectangle(ArrowButtonsPressedBrush, rect); break; default: g.FillRectangle(ArrowButtonsHoverBrush, rect); break; } }
/// <summary> /// Draws an arrow button. /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The <see cref="ScrollBarArrowButtonState"/> of the arrow button.</param> /// <param name="arrowUp">true for an up arrow, false otherwise.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> private void DrawArrowButton(Graphics g, Rectangle rect, ScrollBarArrowButtonState state, bool arrowUp, ScrollBarOrientation orientation) { if (g == null) throw new ArgumentNullException("g"); if (rect.IsEmpty || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) return; Color color; switch (state) { case ScrollBarArrowButtonState.UpHot: case ScrollBarArrowButtonState.DownHot: color = arrowColorHot; break; case ScrollBarArrowButtonState.UpPressed: case ScrollBarArrowButtonState.DownPressed: color = arrowColorPressed; break; default: color = arrowColor; break; } switch (orientation) { case ScrollBarOrientation.Vertical: DrawArrowButtonVertical(g, rect, color, arrowUp); break; default: DrawArrowButtonHorizontal(g, rect, color, arrowUp); break; } }
/// <summary> /// Draws the channel ( or track ). /// </summary> /// <param name="g">The <see cref="Graphics"/> used to paint.</param> /// <param name="rect">The rectangle in which to paint.</param> /// <param name="state">The scrollbar state.</param> /// <param name="orientation">The <see cref="ScrollBarOrientation"/>.</param> public static void DrawTrack( Graphics g, Rectangle rect, ScrollBarState state, ScrollBarOrientation orientation) { if (g == null) { throw new ArgumentNullException("g"); } if (rect.Width <= 0 || rect.Height <= 0 || state != ScrollBarState.Pressed || g.IsVisibleClipEmpty || !g.VisibleClipBounds.IntersectsWith(rect)) { return; } if (orientation == ScrollBarOrientation.Vertical) { DrawTrackVertical(g, rect); } else { DrawTrackHorizontal(g, rect); } }
/// <summary> /// Creates a new instance of the ScrollBar class /// </summary> /// <param name="orientation">The orientation of the ScrollBar</param> /// <param name="isReversed">Wether the ScrollBar is reversed or not</param> public ScrollBar(ScrollBarOrientation orientation, bool isReversed = false) : this(0f, 0f, 10f, orientation, isReversed) { }