Originally Posted by
Jason
Find it for me /daum
Here we go :D
Applicable code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace ProgressBarTest
{
class CProgressBar : ProgressBar
{
Font font = new Font(new FontFamily("Segoe UI"), 8);
int _value = 0;
int fillWidth = 0;
new public int Value { get { return _value; } set { _value = value; recalculateSize(); } }
protected override void OnSizeChanged(EventArgs e) { base.OnSizeChanged(e); recalculateSize(); }
void recalculateSize()
{
fillWidth = (int)((float)this.Width / this.Maximum * _value);
}
public CProgressBar()
{
this.SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(Brushes.Red, e.ClipRectangle);
e.Graphics.FillRectangle(Brushes.YellowGreen, new Rectangle(e.ClipRectangle.X, e.ClipRectangle.Y, fillWidth, e.ClipRectangle.Height));
e.Graphics.DrawString("freedompeace ; example of custom progressbar in .NET 4. :D", font, Brushes.Black, new PointF(e.ClipRectangle.X, e.ClipRectangle.Y));
}
}
}
I've also attached the project I made.