コード例 #1
0
        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);
        }
コード例 #2
0
        /// <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);
        }