Bagikan melalui


TaskbarItemInfo.ProgressState Properti

Definisi

Mendapatkan atau mengatur nilai yang menunjukkan bagaimana indikator kemajuan ditampilkan di tombol taskbar.

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

Nilai Properti

Nilai enumerasi yang menunjukkan bagaimana indikator kemajuan ditampilkan di tombol taskbar. Default adalah None.

Contoh

Contoh berikut menunjukkan cara mengatur properti ProgressState dalam kode. Status diatur dalam handler BackgroundWorker.RunWorkerCompleted peristiwa untuk menunjukkan apakah tugas latar belakang dihentikan oleh pengguna, diakhiri dengan kesalahan, atau diselesaikan secara normal. Contoh ini adalah bagian dari contoh yang lebih besar yang disediakan untuk TaskbarItemInfo kelas .

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

Keterangan

Anda dapat mengkomunikasikan kemajuan tugas jangka panjang dengan menampilkan indikator kemajuan di tombol taskbar Windows 7. Warna indikator ditentukan oleh ProgressState properti , yang berisi salah TaskbarItemProgressState satu nilai enumerasi. ProgressState Ketika adalah Normal, indikator berwarna hijau. Ketika Paused, indikator berwarna kuning. Ketika Error, indikator berwarna merah. Untuk status ini, ProgressValue properti menentukan berapa banyak tombol taskbar yang diisi oleh indikator kemajuan. ProgressValue diabaikan untuk nilai lain dari ProgressState. Indeterminate memperlihatkan indikator hijau berpulsing di seluruh tombol taskbar. Tidak ada indikator yang ditampilkan untuk None.

Ilustrasi berikut ini memperlihatkan indikator kemajuan taskbar dalam status Normal .

Sampel Info Item Taskbar Sampel
Indikator Kemajuan Bilah Tugas Windows

Berlaku untuk