Calculate circular Progressbar time C# (Windows Forms)

Asked

Viewed 292 times

0

I have the following circular Progressbar, the idea is that it be decremented second by second, so far so good. However, I need the bar to always start complete (circling the circle 100%) and the value will be given by the user, so it can be 120 minutes, 90 minutes, and so on... I want to make the bar decrease with the exact time it will take to arrive in 0 minutes.

For example, if the user enters with the value 26 minutes, the bar has to take exactly 26 minutes to reach the 0.

Any idea how to make this exact calculation?

Note: I am using Timer.

ProgressBar circular

  • The total time is minutos*60 every second the full percentage is segundos_decorridos / (minutos*60). If you want to go from 100 to 0, just reverse 1-percentagem_completa

1 answer

1

Simple, set the range of the timer for 1 second.

Assign the value of progressBar as [minutos escolhido pelo usuário] * 60

At each tick of timer, decreases a value of progressBar

Browser other questions tagged

You are not signed in. Login or sign up in order to post.