 |
|
 |
Downloaded and ran the project. Compilation without problems and the test application looks fine. But... The VerticalProgressBar does not appear in the toolbox though the properties of the existing bars can be found and modified. So what's going wrong?
petrus bitbyter
|
|
|
|
 |
|
 |
Good tool. in VS2008 .NET not implemented. It's useful.
Works fine!!!
|
|
|
|
 |
|
 |
Is there a way to make this fill TOP DOWN?
ie.
0 at the TOP
-100 at the bottom
.value = 0 to -100
Otherwise, a great job.
modified on Monday, March 24, 2008 12:56 AM
|
|
|
|
 |
|
|
 |
|
 |
Nice article. Got my 5.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
 |
|
 |
Since you've ported it to .NET 2.0 you might want to look into the System.VisualStyles namespace, which provides tools to render controls in XP/Vista VisualStyles (when they are in use).
Your "classic" vertical progressbar would look out of place on a form with XP/Vista styled controls. Fortunately it does not take much work to do this... most of it is easy enough to guess with intellisense.
Basically you find a VisualStyleElement you want to draw using Intellisense, then make a new VisualStyleRenderer from it (pass the static VSE item in as an argument to the constructor) then you DrawBackground it over the area you want to paint. For the progressbar background you'd just specify the whole control bounds, although you might want to draw it horizontally onto a bitmap first, then rotate the bitmap and blit it onto your control for a proper vertical look.
VSRs also provide stuff like margins and padding information which would be helpful in positioning the bars inside this background.
Custom colored bars would be difficult, but you could experiment with hue/saturation shifting the graphic of the bars. Or you could just draw your own "classic" bars as normal on top of the themed background (and have another boolean option for themed bars maybe).
I hope you find my suggestions helpful. Just remember that all calls to VisualStyles stuff will fail if VisualStyles are not enabled by the user (you can check in VisualStylesInformation.IsUserEnabled... IsOSSupported isn't as important to check). In these cases you could simply draw the control as it's being drawn now.
|
|
|
|
 |
|
 |
Thank you all. I have updated the Vertical ProgressBar to VS 2005 & .NET 2.0 and fixed the bugs mentioned below.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. -- Martin Fowler
|
|
|
|
 |
|
 |
I am having trouble using the control. It keep giving me the error at compile time for not finding the BorderStyle,Style and color property. It also can't find the Styles and BorderStyles attribute. I am using VS 2005. Can any one help me out? Thanks.
Yen
|
|
|
|
 |
|
 |
It works all right if you derive this control from Control class. There is one tiny problem when it is derived from UserControl: one property generate warning as the derived one with the same name is hidden ("new" keyword recommended), but the real reason is that there is no need to derived it from the class UserControl which adds no functionality here and is mainly designed for visual programming. And cool developers like you and me rarely use it, right?
Sergey A Kryukov
|
|
|
|
 |
|
 |
A reason explanation would be:
You use Control if you are building a control that draws its content by overriding the paint event.
You use UserControl if you are building a control that is composed of other controls.
So yes a Control is better in this case.
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
 |
|
 |
You could even derive from ProgressBar I believe, and then you already have all the ProgressBar properties defined. If I did this I would add a boolean property called Vertical. Then I'd simply do my own drawing if Vertical is true (and block calling ProgressBar.OnPaint from my own OnPaint so the normal progressbar isn't drawn).
The big downside would be that any custom properties you put in would be expected to work for the normal progressbar, so you'd have to draw that too! But once you've written one drawing handler it wouldn't be too hard to turn it sideways again.
Your control looks fine as is, this is just an idea of how it could have been done another way. Maybe for a future control you could implement a similar idea (inherit from a more specific control).
|
|
|
|
 |
|
 |
The_Mega_ZZTer wrote: Your control looks fine as is
Not my control
WPF - Imagineers Wanted
Follow your nose using DoubleAnimationUsingPath
|
|
|
|
 |
|
 |
ProgressBar is sealed, so deriving from it is not an option.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Hi all,
In my C# project reference section add Word tlb with 11 th version(office 2003). if at client system we contain office 2007 or any other office version with different tlb versions.
So, what is solution for this problem.
thanks.
|
|
|
|
 |
|
 |
Hi Dear
I want use one ProgressBar that has Multiple Color at the same time,
In other words, 2 bar has a green and 3 bar has a blue and etc...
Please, Help me...
By.
|
|
|
|
 |
|
 |
Maybe you could create multiple bars, each has one color, and combine those bars together dynamically for your needs.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. -- Martin Fowler
|
|
|
|
 |
|
 |
Does it works under Visual Basic .Net??? should I have to add it as a reference? then how can I add the control into the form, because it doesn't apear in the toolbox panel.
Great job.
|
|
|
|
 |
|
 |
wrote: should I have to add it as a reference?
Yes. It should work just fine.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
 |
|
 |
You can make the standard progressbar vertical by using the API, specifically SetWindowLong / PBS_VERTICAL or by overriding CreateParams if you inherit System.Windows.Forms.ProgressBar
|
|
|
|
 |
|
 |
This code may help
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll")]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
const int GWL_STYLE = -16;
const int PBS_VERTICAL = 4;
private void SetVerticalStyle()
{
long windowLong = GetWindowLong(this.Handle, GWL_STYLE);
windowLong |= PBS_VERTICAL;
SetWindowLong(this.Handle, GWL_STYLE, (IntPtr)windowLong);
}
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ClassStyle |= PBS_VERTICAL;
return cp;
}
}
|
|
|
|
 |
|
 |
I found that it didn't work properly if the minimum value is set to anything above zero.
It works if you change the calculation for height in DrawBar() to:
height = (m_Value - m_Minimum) * this.Height / (m_Maximum - m_Minimum); // the bar height
Otherwise, great bit of code...
|
|
|
|
 |
|
 |
I'm stuck in an infinite loop. Check procedure drawClassicBar() in VerticalProgressBar.cs. Specifically, this line: for(int currentpos = y; currentpos > valuepos_y; currentpos -= blockheight+1). When blockheight = -1, the counter never decrements. This occurred while the user was resizing my usercontrol at runtime in a diagramming application I'm writing. The VerticalProgressBar is a constituent control on my usercontrol and is designed to be proportionally resized (horizontally and vertically) as the user resizes my usercontrol.
|
|
|
|
 |
|
 |
Hi,
Works fine.
Just add these 3 lines to avoid flickering when redrawing.
public VerticalProgressBar()
{
InitializeComponent();
// ***** avoid flickering
this.SetStyle(ControlStyles.AllPaintingInWmPaint,true);
this.SetStyle(ControlStyles.UserPaint,true);
this.SetStyle(ControlStyles.DoubleBuffer,true);
this.Name = "VerticalProgressBar";
this.Size = new Size(10, 120);
}
Yannick
|
|
|
|
 |
|
 |
Thank you for your comments.
|
|
|
|
 |