msbg
msbg

Reputation: 4972

How to show progress in the System Tray

I am trying to display progress in the system tray. I use this:

    ProgressIndicator pi = new ProgressIndicator();
    SystemTray.ProgressIndicator = pi;
    SystemTray.ProgressIndicator.IsIndeterminate = false;

The problem I have is changing the Progress Indicator's maximum value. The default seems to be one, but I see no way of changing this. How would you do so?

Upvotes: 1

Views: 604

Answers (1)

Serdalis
Serdalis

Reputation: 10489

What the ProgressIndicator takes is a double value between 0 and 1.

If you want to put any other numbers into it (say 0 to 100) what you have to do is normalise the values, which will bring them into the range 0-1.

so for example you would do:

double progress = 0.0;
double max = 100.0;

progress = 0.0/max;  // = 0.0
pi.Value = progress;

progress = 50.0/max; // = 0.5
pi.Value = progress;

progress = 100.0/max; // = 1.0
pi.Value = progress;

and you would input the values between 0 and 1.

Here is a good little post about this feature.

Upvotes: 3

Related Questions