TaskbarItemInfo.ProgressState Proprietà

Definizione

Ottiene o imposta un valore che indica il modo in cui viene visualizzato l'indicatore di stato nel pulsante della barra delle applicazioni.

public:
 property System::Windows::Shell::TaskbarItemProgressState ProgressState { System::Windows::Shell::TaskbarItemProgressState get(); void set(System::Windows::Shell::TaskbarItemProgressState value); };
public System.Windows.Shell.TaskbarItemProgressState ProgressState { get; set; }
member this.ProgressState : System.Windows.Shell.TaskbarItemProgressState with get, set
Public Property ProgressState As TaskbarItemProgressState

Valore della proprietà

Valore di enumerazione che indica il modo in cui viene visualizzato l'indicatore di stato nel pulsante della barra delle applicazioni. Il valore predefinito è None.

Esempio

Nell'esempio riportato di seguito viene illustrato come impostare la proprietà ProgressState nel codice. Lo stato viene impostato nel gestore di un BackgroundWorker.RunWorkerCompleted evento per indicare se l'attività in background è stata arrestata dall'utente, terminata con un errore o completata normalmente. Questo esempio fa parte di un esempio più grande fornito per la TaskbarItemInfo classe.

void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    // When the task ends, change the ProgressState and Overlay
    // of the taskbar item to indicate a stopped task.
    if (e.Cancelled == true)
    {
        // The task was stopped by the user. Show the progress indicator
        // in the paused state.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Paused;
    }
    else if (e.Error != null)
    {
        // The task ended with an error. Show the progress indicator
        // in the error state.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Error;
    }
    else
    {
        // The task completed normally. Remove the progress indicator.
        this.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.None;
    }
    // In all cases, show the 'Stopped' overlay.
    this.taskBarItemInfo1.Overlay = (DrawingImage)this.FindResource("StopImage");
}
Private Sub bw_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs)
    ' When the task ends, change the ProgressState and Overlay
    ' of the taskbar item to indicate a stopped task.
    If e.Cancelled = True Then
        ' The task was stopped by the user. Show the progress indicator
        ' in the paused state.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Paused
    ElseIf e.Error IsNot Nothing Then
        ' The task ended with an error. Show the progress indicator
        ' in the error state.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.Error
    Else
        ' The task completed normally. Remove the progress indicator.
        Me.taskBarItemInfo1.ProgressState = TaskbarItemProgressState.None
        ' In all cases, show the 'Stopped' overlay.
        Me.taskBarItemInfo1.Overlay = Me.FindResource("StopImage")
    End If
End Sub

Commenti

È possibile comunicare lo stato di avanzamento delle attività a esecuzione prolungata visualizzando un indicatore di stato in un pulsante della barra delle applicazioni di Windows 7. Il colore dell'indicatore ProgressState è determinato dalla proprietà, che contiene uno dei valori di TaskbarItemProgressState enumerazione. Quando è , l'indicatore ProgressState è Normalverde. Quando Paused, l'indicatore è giallo. Quando Error, l'indicatore è rosso. Per questi stati, la ProgressValue proprietà determina la quantità del pulsante della barra delle applicazioni riempita dall'indicatore di stato. ProgressValue viene ignorato per altri valori di ProgressState. Indeterminate mostra un indicatore verde pulsante sull'intera barra delle applicazioni. Non viene visualizzato alcun indicatore per None.

La figura seguente mostra l'indicatore di stato della barra delle applicazioni nello Normal stato.

Esempio di informazioni sull'elemento della barra delle applicazioni dell'elemento della barra delle
Indicatore di stato della barra delle applicazioni di Windows

Si applica a