Click here to Skip to main content
13,147,050 members (57,559 online)
Click here to Skip to main content

Stats

27K views
925 downloads
23 bookmarked
Posted 24 Jul 2010

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

The taskbar of Windows 7 is one of the major changes in the Operating System, and brings many advantages.
WPF Icon Overlay And ProgressBar
bin
Debug
WPF Icon Overlay And ProgressBar.vshost.exe
WPF Icon Overlay And ProgressBar.vshost.exe.manifest
images
BlueToy.ico
FireToy.ico
GreenToy.ico
NinjaToy.ico
overlay.png
PinkToy.ico
progressbar.png
My Project
MyExtensions
WPF Icon Overlay And ProgressBar.vbproj.user
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Taskbar IconOverlay &amp; ProgressBar" Height="350" Width="525">
    
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo/>
    </Window.TaskbarItemInfo>
    
    <Window.Resources>
        <DrawingImage x:Key="IconRed">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/FireToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconGreen">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/GreenToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconBlue">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/BlueToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconPink">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/PinkToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
        <DrawingImage x:Key="IconBlack">
            <DrawingImage.Drawing>
                <ImageDrawing Rect="0,0,16,16" ImageSource="/WPF%20Icon%20Overlay%20And%20ProgressBar;component/images/NinjaToy.ico" />
            </DrawingImage.Drawing>
        </DrawingImage>
    </Window.Resources>
    
    <Grid>
        <Grid.Background>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                <GradientStop Offset="0" Color="Black"></GradientStop>
                <GradientStop Offset="1" Color="DarkGray"></GradientStop>
            </LinearGradientBrush>
        </Grid.Background>
        <TabControl Margin="12,6,12,12" Name="TabControl1">
            <TabItem Header="Taskbar IconOverlay" Name="TabItem1">
                <Grid>
                    <Grid.Background>
                        <ImageBrush ImageSource="pack://application:,,,/WPF Icon Overlay And ProgressBar;component/images/overlay.png" Stretch="Uniform" Opacity=".2" />
                    </Grid.Background>
                    <Grid.RowDefinitions>
                        <RowDefinition Height=".33*"></RowDefinition>
                        <RowDefinition Height=".33*"></RowDefinition>
                        <RowDefinition Height=".33*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                        <ColumnDefinition Width=".2*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    
                    <Label Grid.ColumnSpan="5" Grid.Row="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="24" Foreground="White"
                           Content="Select an image to overlay">
                    </Label>
                    
                    <Button Grid.Column="0" Grid.Row="1" Name="btnIconRed" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconRed}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="1" Grid.Row="1" Name="btnIconGreen" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconGreen}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="2" Grid.Row="1" Name="btnIconBlue" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconBlue}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="3" Grid.Row="1" Name="btnIconPink" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconPink}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>
                    <Button Grid.Column="4" Grid.Row="1" Name="btnIconBlack" Width="64" Height="64" Padding="0">
                        <Button.Content>
                            <Image Source="{StaticResource IconBlack}" Width="56" Height="56" Stretch="Uniform" Margin="0"></Image>
                        </Button.Content>
                    </Button>                    
                    
                    <Button Grid.ColumnSpan="5" Grid.Row="2" Name="btnIconReset" Width="125" Height="30">Reset Overlay</Button>
                </Grid>
            </TabItem>
            <TabItem Header="Taskbar ProgressBar" Name="TabItem2">
                <Grid>
                    <Grid.Background>
                        <ImageBrush ImageSource="pack://application:,,,/WPF Icon Overlay And ProgressBar;component/images/progressbar.png" Stretch="Uniform" Opacity=".2" />
                    </Grid.Background>
                    <Grid.RowDefinitions>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                        <RowDefinition Height=".25*"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="24" Foreground="White"
                           Content="Move the slider">
                    </Label>
                    
                    <ComboBox Grid.Row="1" Name="cmbEstilos" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <ComboBox.Items>
                            <ComboBoxItem Name="ItemNormal" Content="Normal"></ComboBoxItem>
                            <ComboBoxItem Name="ItemError" Content="Error"></ComboBoxItem>
                            <ComboBoxItem Name="ItemStop" Content="Stop"></ComboBoxItem>
                            <ComboBoxItem Name="ItemIndeterminate" Content="Indeterminate"></ComboBoxItem>
                            <ComboBoxItem Name="ItemNone" Content="None"></ComboBoxItem>
                        </ComboBox.Items>
                    </ComboBox>
                    
                    <ProgressBar Grid.Row="2" Name="Pbar" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                                 Minimum="0" Maximum="100" Value="{Binding Path=Value, ElementName=SlidValue}"></ProgressBar>
                    
                    <Slider Grid.Row="3" Name="SlidValue" Height="30" Width="Auto" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                            Minimum="0" Maximum="100" Value="50" SmallChange="1">
                    </Slider>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</Window>

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)

Share

About the Author

Josué Yeray Julián Ferreiro
Software Developer (Senior) Freelance Developer
Spain Spain
MVP Windows Platform Development 2014
MVP Windows Phone Development 2013
MVP Windows Phone Development 2012

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.170915.1 | Last Updated 24 Jul 2010
Article Copyright 2010 by Josué Yeray Julián Ferreiro
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid