Two color progress bar or somesuch

I'm looking for a component or control or something that I can use to visually display the times when something can or cannot occur. For example, a process will only run from 8 p.m. to 4 a.m. The user can adjust the exact times. I want to graphically show this. It would look something like:

************************

Except that it would be a solid line instead of asterisks. Any ideas? It's kind of like a progress bar but with two colors and some extra properties.

Thanks,

[724 byte] By [PaulSQL] at [2007-12-24]
# 1

check this out for coloring progress bars:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;323116 - this one examples how to create a smooth custom progress bar

http://www.codeproject.com/cs/miscctrl/colorprogressbar.asp

pretty much requires I think, overriding the Graphics/paint event. NoBugz, and others, would be more experts in this area than myself

ahmedilyas at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Check out the Gradient Animation control provided by the open Source Ascend.Net tools.
OmegaMan at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
You want an owner drawn slider bar not progress bar.
JRQ at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Nah, use the Paint event of a Panel control and draw the lines with the e.Graphics.DrawLine() method. If you need code, tell us what language you use.

nobugz at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
I use C#. Thanks.
PaulSQL at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
Add a new class to your project, then paste this code:

using System;
using System.Drawing;
using System.Windows.Forms;

class TimeLine : Panel {
private TimeSpan mStart = new TimeSpan(8, 0, 0); // Default: 8am
private TimeSpan mEnd = new TimeSpan(16,0,0); // Default: 4pm
public TimeSpan TimeStart {
get { return mStart; }
set { mStart = value; Invalidate(); }
}
public TimeSpan TimeEnd {
get { return mEnd; }
set { mEnd = value; Invalidate(); }
}
protected override void OnPaint(PaintEventArgs e) {
// Paint time line, 6am to 6pm. Calculate pixel positions
long totalTick = new TimeSpan(12, 0, 0).Ticks;
long startTick = mStart.Ticks - new TimeSpan(6, 0, 0).Ticks;
if (startTick < 0) startTick = 0;
long endTick = mEnd.Ticks - new TimeSpan(6, 0, 0).Ticks;
if (endTick > totalTick) endTick = totalTick;
if (startTick > endTick) startTick = endTick;
int w = this.Width - 10; // 5 pixel space and start and end
int sx = 5 + (int)(w * startTick / totalTick);
int ex = 5 + (int)(w * endTick / totalTick);
// Draw it
Pen gpen = new Pen(Color.LightGreen, 3);
Pen rpen = new Pen(Color.Red, 3);
int y = this.Height / 2;
e.Graphics.DrawLine(gpen, 5, y, sx, y);
e.Graphics.DrawLine(rpen, sx, y, ex, y);
e.Graphics.DrawLine(gpen, ex, y, w + 5, y);
// Allow app to paint of top of this:
base.OnPaint(e);
}
}

This should get you started, there's a gazillion doodads you can add. Good luck!

nobugz at 2007-10-8 > top of Msdn Tech,Windows Forms,Windows Forms General...