I'm downloading a collection of files, and I'd like to display progress in a progress bar. It's simple to display overall progress by setting the maximum value of the progress bar to the total size of all the files, and by setting the current position to the size downloaded so far.
What I'd like to do is separate the progress bar into segments, with each section representing a different file in the collection.
Is this possible? How would I do it?
If you know the total size of the files to be downloaded, and you know the total size of the files downloaded so far, then you can just set .Maximum to the total size of the files, and .Position to the total downloaded so far. No need to worry about how the size is split between the files.
Or did you mean that you want tick marks on the progress bar according to the size of each file?
I think the easiest way would be to make a UserControl, drop a ProgressBar on it, override the UserControl's OnPaint() and draw your lines.
I think a UserControl would be a little easier to deal with than drawing right on the form. The coordinates would be easier to handle plus it'd be easier to reuse it in another application.
Set the max value to 100. Then for each file that is downloaded do 100*(file_size/total_download_size) and add them together. Once you have the value of them added together, set the progress bar's value. Update the value each time a file finishes downloading.
You can use two progress bars one for each file and one for total. Or if you want tick marks: Simple solution is to add some lines under or above that bar.