Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / WPF

WPF: Integrating our application with the Windows 7 Taskbar (I)

Rate me:
Please Sign up or sign in to vote.
4.50/5 (8 votes)
24 Jul 2010CPOL6 min read 43.3K   1.1K   24  
The taskbar of Windows 7 is one of the major changes in the Operating System, and brings many advantages.
Class MainWindow

#Region "Window Code"
    Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.None
        Me.TaskbarItemInfo.Overlay = Nothing
    End Sub
#End Region

#Region "Taskbar IconOverlay"
    Private Sub btnIconBlack_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconBlack.Click
        Me.TaskbarItemInfo.Overlay = CType(Resources("IconBlack"), ImageSource)
    End Sub

    Private Sub btnIconBlue_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconBlue.Click
        Me.TaskbarItemInfo.Overlay = CType(Resources("IconBlue"), ImageSource)
    End Sub

    Private Sub btnIconGreen_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconGreen.Click
        Me.TaskbarItemInfo.Overlay = CType(Resources("IconGreen"), ImageSource)
    End Sub

    Private Sub btnIconPink_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconPink.Click
        Me.TaskbarItemInfo.Overlay = CType(Resources("IconPink"), ImageSource)
    End Sub

    Private Sub btnIconRed_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconRed.Click
        Me.TaskbarItemInfo.Overlay = CType(Resources("IconRed"), ImageSource)
    End Sub

    Private Sub btnIconReset_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnIconReset.Click
        Me.TaskbarItemInfo.Overlay = Nothing
    End Sub
#End Region

#Region "Taskbar ProgressBar"
    Private Sub SlidValue_ValueChanged(ByVal sender As Object, ByVal e As System.Windows.RoutedPropertyChangedEventArgs(Of Double)) Handles SlidValue.ValueChanged
        Me.TaskbarItemInfo.ProgressValue = SlidValue.Value / 100
    End Sub

    Private Sub cmbEstilos_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles cmbEstilos.SelectionChanged
        Select Case DirectCast(e.AddedItems(0), System.Windows.Controls.ComboBoxItem).Content
            Case "Normal"
                SlidValue.IsEnabled = True
                Pbar.IsIndeterminate = False
                Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.Normal
            Case "Error"
                SlidValue.IsEnabled = True
                Pbar.IsIndeterminate = False
                Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.Error
            Case "Stop"
                SlidValue.IsEnabled = True
                Pbar.IsIndeterminate = False
                Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.Paused
            Case "Indeterminate"
                SlidValue.IsEnabled = False
                Pbar.IsIndeterminate = True
                Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.Indeterminate
            Case "None"
                SlidValue.IsEnabled = True
                Pbar.IsIndeterminate = False
                Me.TaskbarItemInfo.ProgressState = Shell.TaskbarItemProgressState.None
        End Select
    End Sub
#End Region
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Freelance Developer
Spain Spain
MVP Windows Platform Development 2014
MVP Windows Phone Development 2013
MVP Windows Phone Development 2012

Comments and Discussions