Windows7 / VS2010 / WPF 4 Demo App

The other day I finished up a small demo app that I was writing over at www.codeproject.com which covers several of the new Windows7 features such as TaskBars/JumpLists.

The finished article looks like this

 

start2

start4

start5

task

The idea behind this demo app is actually very simple, I wanted to show how to use the Managed Extensibility Framework (MEF) to add in a bunch of Pixel Shaders that were inside a separate assembly. I also use some of the new .NET 4.0 goodies such as Dynamic and ExpandoObject.

The demo app also show cases how to use the new System.Windows.Shell namespace.

In case you are wondering here is how you would create a JumpList using the new System.Windows.Shell namespace.

JumpList jumpList = new JumpList();
JumpList.SetJumpList(Application.Current, jumpList);

JumpTask jumpTask = new JumpTask();
jumpTask.Title = "IE";
jumpTask.CustomCategory = 
    "Keep Notes";
jumpTask.ApplicationPath = 
    @"C:Program FilesInternet Exploreriexplore.exe";
String systemFolder = 
    Environment.GetFolderPath(
        Environment.SpecialFolder.System);
jumpTask.IconResourcePath = 
    @"C:Program FilesInternet Exploreriexplore.exe";
jumpTask.IconResourceIndex = 0;
jumpTask.Arguments = "pixel shaders";
jumpList.JumpItems.Add(jumpTask);
jumpList.Apply();

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

And here is how you can create a TaskBar that can interact with your application code, again using the new System.Windows.Shell namespace.

<Window x:Class="MefFX.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MefFX" Height="600" Width="800">


    <Window.TaskbarItemInfo>
        <TaskbarItemInfo
            ProgressState="Normal" 
            Description="Some text"
            ThumbnailClipMargin=
        "{Binding RelativeSource=
            {RelativeSource FindAncestor, 
                    AncestorType={x:Type Window}}, 
            Path=BorderThickness}">
            <TaskbarItemInfo.ThumbButtonInfos>
                <ThumbButtonInfo
                   Click="SearchForPixelShadersInside_Click"
                    DismissWhenClicked="False"
                    ImageSource="Images/ie.png" />
                <ThumbButtonInfo Command="{Binding AboutCommand}"
                    DismissWhenClicked="False"
                    ImageSource="Images/about.png" />
            </TaskbarItemInfo.ThumbButtonInfos>
        </TaskbarItemInfo>


    </Window.TaskbarItemInfo>


....
....
....
....

</Window>

 

This TaskBar is obviously done in WPF4.0 using XAML but it would be easy enough to do in WinForms using the TaskbarItemInfo class which is in the new System.Windows.Shell namespace.

Anyway the full article explains all this and a lot more in a lot more detail, so if you feel inclined to have a read through of that, the full article is available over at this link:

http://www.codeproject.com/KB/WPF/MefFX.aspx

Enjoy
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Advertisements

5 thoughts on “Windows7 / VS2010 / WPF 4 Demo App

  1. I was looking for a blog like this before,you got really great information here,I am pleased to check it,Keep it up.Thanks

  2. That’s really true said,i am some how agree with what you said.

  3. Andrew Powell says:

    I love this exert “easy enough to do” regarding Winforms and using the TaskbarItemInfo class. Can you provide an example of how easy this is?

    I’ve been combing msdn and the popular answer sites looking for how this might even be remotely easy. It would seem that the class has a direct dependency on WPF, The System.Windows.Application class and the System.Windows.Window class. I’ve not yet found a method to derrive an instance of Window from Form, nor how to instantiate Applcation.

    So please, do enlighten me. Cheers

  4. Andrew Powell says:

    Very aware of the Codepack. Perhaps you should rephrase this sentence, as it indicates there is a method to use the native api:

    “it would be easy enough to do in WinForms using the TaskbarItemInfo class which is in the new System.Windows.Shell namespace.”

    If you’re unaware of a means to use that class in that namespace with Winforms, then that statement is rather misleading.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: