/// <summary> /// Initialize the backbuffer /// </summary> private void InitializePixelMap() { PixelMap = new Bitmap(Width, Height); GraphicsContainer = Graphics.FromImage(PixelMap); GraphicsContainer.Clear(BackgroundColor); Refresh(); }
protected override void Redraw() { RecalculateThumbBounds(); GraphicsContainer.Clear(BackgroundColor); float thumbCenter = ValueToPosition(Value); ThumbBounds.X = (int)(thumbCenter - ThumbBounds.Width / 2f); int margin = Height - ThumbBounds.Height; Rectangle visibleBounds = ThumbBounds; visibleBounds.X += margin / 2; visibleBounds.Width -= margin; GraphicsContainer.FillRectangle(ForegroundBrush, visibleBounds); }
/// <summary> /// Redraws the scrollbar into the backbuffer. /// </summary> protected override void Redraw() { RecalculateThumbBounds(); // Clear the buffer GraphicsContainer.Clear(BackgroundColor); // Get the correct thumb center point for the current value. float thumbCenter = ValueToPosition(Value); // Calculate the position of the thumb ThumbBounds.Y = (int)(thumbCenter - ThumbBounds.Height / 2f); // Determine the margin that applied in regards to the width. int margin = (Width - ThumbBounds.Width); // We now subtract the same margin from the height. // TODO: It would be nicer to have a set margin that is subtracted from the control height and included in all calculations. Rectangle visibleBounds = ThumbBounds; visibleBounds.Y += margin / 2; visibleBounds.Height -= margin; GraphicsContainer.FillRectangle(ForegroundBrush, visibleBounds); }