Create a UserControl.
The way I did mine was to have a "coloured"image and a "monochrome" version of the same picture, and then paint the appropriate parts of each so that the initially monochrome image changed to full colour as the progress completed, but it would be pretty simple to just draw a single image and use a transparent background for the rest.
This may help:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace UtilityControls
{
public partial class ProgressImage : UserControl
{
#region Constants
#endregion
#region Fields
#region Internal Fields
private Bitmap bComp;
private Bitmap bUncomp;
#endregion
#region Property Bases
private int min = 0;
private int value = 50;
private int max = 100;
private Image imageCompleted = null;
private Image imageUncompleted = null;
#endregion
#endregion
#region Properties
#region Visible Properties
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Description("Minimum value for progress"),
Category("Progress")]
public int Min
{
get { return min; }
set
{
min = value;
Invalidate();
}
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Description("Current value of progress"),
Category("Progress")]
public int Value
{
get { return this.value; }
set
{
this.value = value;
Invalidate();
}
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Description("Maximum value for progress"),
Category("Progress")]
public int Max
{
get { return max; }
set
{
max = value;
Invalidate();
}
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Description("Image to display in completed part of progress"),
Category("Display")]
public Image ImageCompleted
{
get { return imageCompleted; }
set
{
imageCompleted = value;
BuildImages();
Invalidate();
}
}
[Browsable(true),
EditorBrowsable(EditorBrowsableState.Always),
Description("Image to display in uncompleted part of progress"),
Category("Display")]
public Image ImageUncompleted
{
get { return imageUncompleted; }
set
{
imageUncompleted = value;
BuildImages();
Invalidate();
}
}
#endregion
#region Hide these properties
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool AllowDrop { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new AutoScaleMode AutoScaleMode { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool AutoScroll { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Size AutoScrollMargin { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new Size AutoScrollMinSize { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override bool AutoSize { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new AutoSizeMode AutoSizeMode { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override AutoValidate AutoValidate { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ImageLayout BackgroundImageLayout { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override ContextMenuStrip ContextMenuStrip { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public override RightToLeft RightToLeft { get; set; }
#endregion
#endregion
#region Regular Expressions
#endregion
#region Enums
#endregion
#region Constructors
public ProgressImage()
{
InitializeComponent();
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
BuildImages();
}
#endregion
#region Events
#region Event Constructors
#endregion
#region Event Handlers
private void ProgressImage_Paint(object sender, PaintEventArgs e)
{
Graphics graphics = e.Graphics;
DoHorizontalImageReveal(graphics);
}
private void ProgressImage_Resize(object sender, EventArgs e)
{
BuildImages();
}
#endregion
#endregion
#region Public Methods
#endregion
#region Private Methods
private void DoHorizontalImageReveal(Graphics graphics)
{
int border = (Width * value) / (max - min);
int remain = Width - border;
if (bComp != null)
{
graphics.DrawImageUnscaledAndClipped(bComp, new Rectangle(0, 0, border, Height));
}
if (bUncomp != null)
{
graphics.DrawImage(bUncomp, new Rectangle(border, 0, remain, Height), new Rectangle(border, 0, remain, Height), GraphicsUnit.Pixel);
}
}
private void BuildImages()
{
bComp = BuildImage(imageCompleted, Width, Height);
bUncomp = BuildImage(imageUncompleted, Width, Height);
}
private Bitmap BuildImage(Image image, int width, int height)
{
if (image == null)
{
return null;
}
return new Bitmap(image, width, height);
}
#endregion
}
}
[edit]I HATE F***ING MARKDOWN! Leave my code alone you stupid pile of cr@p![/edit]