Brush brush;
RectangleF rectTemp, drawRect;
float textAreaSize;
Rectangle workingRect = Rectangle.Inflate(this.ClientRectangle, - _indentWidth, - _indentHeight);
float currentUsedPos = 0;
//==========================================================================
// Draw the background of the ProgressBar control.
//==========================================================================
brush = new SolidBrush(this.BackColor);
rectTemp = this.ClientRectangle;
e.Graphics.FillRectangle(brush, rectTemp);
brush.Dispose();
//==========================================================================
//==========================================================================
if(_orientation == Orientation.Horizontal)
{
currentUsedPos = _indentHeight;
//==========================================================================
// Get Height of Text Area
textAreaSize = e.Graphics.MeasureString(_maximum.ToString(), this.Font).Height;
if(_textTickStyle == TickStyle.TopLeft || _textTickStyle == TickStyle.Both)
{
//==========================================================================
// Draw the 1st Text Line.
//==========================================================================
drawRect = new RectangleF(workingRect.Left, currentUsedPos, workingRect.Width, textAreaSize);
drawRect.Inflate(- _trackerSize.Width/2, 0);
currentUsedPos += textAreaSize;
DrawTickTextLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, this.ForeColor, this.Font, _orientation);
//==========================================================================
}
if(_tickStyle == TickStyle.TopLeft || _tickStyle == TickStyle.Both)
{
//==========================================================================
// Draw the 1st Tick Line.
//==========================================================================
drawRect = new RectangleF(workingRect.Left, currentUsedPos, workingRect.Width, _tickHeight);
drawRect.Inflate(- _trackerSize.Width/2, 0);
currentUsedPos += _tickHeight + 1;
DrawTickLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, _tickColor, _orientation);
//==========================================================================
}
//==========================================================================
// Caculate the Tracker's rectangle
//==========================================================================
float currentTrackerPos;
if (_maximum == _minimum)
currentTrackerPos = workingRect.Left;
else
currentTrackerPos = (workingRect.Width - _trackerSize.Width) * (_value - _minimum)/(_maximum - _minimum) + workingRect.Left;
_trackerRect = new RectangleF(currentTrackerPos,currentUsedPos,_trackerSize.Width, _trackerSize.Height);// Remember this for drawing the Tracker later
//_trackerRect.Inflate(0,-1);
//==========================================================================
// Draw the Track Line
//==========================================================================
drawRect = new RectangleF(workingRect.Left , currentUsedPos + _trackerSize.Height/2 - _trackLineHeight/2, workingRect.Width, _trackLineHeight);
DrawTrackLine(e.Graphics, drawRect);
currentUsedPos += _trackerSize.Height;
//==========================================================================
if(_tickStyle == TickStyle.BottomRight || _tickStyle == TickStyle.Both)
{
//==========================================================================
// Draw the 2st Tick Line.
//==========================================================================
currentUsedPos += 1;
drawRect = new RectangleF(workingRect.Left, currentUsedPos, workingRect.Width, _tickHeight);
drawRect.Inflate(- _trackerSize.Width/2, 0);
currentUsedPos += _tickHeight;
DrawTickLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, _tickColor, _orientation);
//==========================================================================
}
if(_textTickStyle == TickStyle.BottomRight || _textTickStyle == TickStyle.Both)
{
//==========================================================================
// Draw the 2st Text Line.
//==========================================================================
// Get Height of Text Area
drawRect = new RectangleF(workingRect.Left, currentUsedPos, workingRect.Width, textAreaSize);
drawRect.Inflate(- _trackerSize.Width/2, 0);
currentUsedPos += textAreaSize;
DrawTickTextLine(e.Graphics, drawRect, _tickFrequency, _minimum, _maximum, this.ForeColor, this.Font, _orientation);
//==========================================================================
}
}
//==========================================================================
// Check for special values of Max, Min & Value
if (_maximum == _minimum)
{
// Draw border only and exit;
DrawBorder(e.Graphics);
return;
}
//==========================================================================
//==========================================================================
// Draw the Tracker
//==========================================================================
DrawTracker(e.Graphics, _trackerRect);
//==========================================================================
// Draw border
DrawBorder(e.Graphics);
//==========================================================================
// Draws a focus rectangle
//if(this.Focused && this.BackColor != Color.Transparent)
if(this.Focused)
ControlPaint.DrawFocusRectangle(e.Graphics, Rectangle.Inflate(this.ClientRectangle, -2, -2));
//==========================================================================