2013-03-20 42 views
1

我正在嘗試在系統托盤中顯示進度。我使用這個:如何在系統托盤中顯示進度

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

我遇到的問題是改變進度指示器的最大值。默認情況下似乎是一個,但我看不出改變這種情況的方法。你會怎麼做?

回答

3

ProgressIndicator需要的值是01之間的double值。

如果你想要把其他任何數字進去(比如0100),你必須做的是normalise值,這將使他們進入範圍0-1

因此,例如,你會怎麼做:

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; 

,你會輸入0 and 1之間的值。

Here is a good little post關於此功能。

+0

好吧,似乎很容易。 – msbg 2013-03-21 23:03:43