Szerkesztés

Megosztás a következőn keresztül:


TaskbarItemInfo.ProgressState Property

Definition

Gets or sets a value that indicates how the progress indicator is displayed in the taskbar button.

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

Property Value

An enumeration value that indicates how the progress indicator is displayed in the taskbar button. The default is None.

Examples

The following example shows how to set the ProgressState property in code. The state is set in the handler of a BackgroundWorker.RunWorkerCompleted event to indicate whether the background task was stopped by the user, ended with an error, or completed normally. This example is part of a larger example provided for the TaskbarItemInfo class.

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

Remarks

You can communicate the progress of long-running tasks by displaying a progress indicator in a Windows 7 taskbar button. The color of the indicator is determined by the ProgressState property, which contains one of the TaskbarItemProgressState enumeration values. When the ProgressState is Normal, the indicator is green. When Paused, the indicator is yellow. When Error, the indicator is red. For these states, the ProgressValue property determines how much of the taskbar button is filled by the progress indicator. ProgressValue is ignored for other values of ProgressState. Indeterminate shows a pulsing green indicator across the entire taskbar button. No indicator is shown for None.

The following illustration shows the taskbar progress indicator in the Normal state.

Taskbar Item Info Sample
Windows Taskbar Progress Indicator

Applies to