Pergunta

At the moment I have a queue system that places all of the links to download files from and it downloads them one by one.

What I have been trying to do is have not 1 but 2 progress bars. The top progress bar will be for the progress of the current file and the one below will be for the overall progress, before all the files finish downloaded.

I have tried to come up with ways to have this but I can't figure out how I would go about doing it.

What I have tried is this:

If Me.fileUrls.Count = 1 Then
    CProgressBarTotal.Value = Help.ProgPercent.Text
Else
    CProgressBarTotal.Value = Help.ProgPercent.Text / Me.fileUrls.Count
End If

And I realised after, that this wouldn't work. I also tried to think of other ways to do it but, I couldn't think of anything.

Does anyone know how I would be able to go about doing this? Thanks.

Foi útil?

Solução

You shouldn't need an if statement:

CProgressBarTotal.Value = (currentFileNumber / Me.fileUrls.Count + Help.ProgPercent.Text / 100 / Me.fileUrls.Count) * CProgressBarTotal.Maximum

Outras dicas

To have a second progress bar that tracks total bytes downloaded:

  1. Prior to showing the download screen, determine the total number of bytes to be downloaded. The specifics here depend on the download mechanism, but most FTP and HTTP servers will provide file sizes. In cases where they don't you'll have to make a reasonable estimate. Store this in an accessible member variable.

  2. Create an accessible member variable for the total number of bytes downloaded. Bind this to the same routine that updates your single-file progress, so that each download "tick" also accumulates the "number of bytes downloaded" field in addition to the percentage of the current file as it does now.

  3. Bind the total number of bytes to the "total percentage" progress bar maximum value. Bind the bytes downloaded counter to the position of the progress bar.

For extra points: Configure the bindings in a dynamic way, such that if a file is added to (or removed from) your download queue, the total number of bytes to download count is updated in real-time and the progress bar resets progress accordingly.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top