Archive for March, 2008

Getting Started with WPF

image

I don’t know about you, but it seems more difficult to get started with Windows Presentation Foundation (WPF) than it should be. I’ve been dabbling with it for a while, but I recently wanted to build a client-side application to track my ongoing projects and decided to resist the temptation to pump out another Windows Forms app and use the experience to get familiar with WPF.

This post is my recommendation on the best way I’ve found to ramp up on WPF.

I’ll likely make a few of these posts as I continue to find valuable resources. One thing I want to do is make a simple screencast that shows how to make a standard business-style application. With all the whiz-bang things WPF can do, it seems that real-world examples are hard to find. I’m less concerned with the sexy graphics aspects (animation, gradients, etc.) and more with the fact that Microsoft is putting all of its resources behind this and my bet is most new client-side GUI innovations (controls, tools, patterns, third party support) will happen here, not in WinForms.

Who are these posts for?

It will help if you are exactly like me! :) Who is that?

I’m starting from a strong background in .NET. By that I mean all technologies considered part of .NET 2.0. I have dabbled with the 3.0 technologies (WCF, WPF, LINQ, WF, etc.) but I am still ramping up on those. This means I have a good working knowledge of XML (which is a considerable help with WPF where most tools don’t talk code — they talk XAML).

I’m not a creative-type person. There is no doubt that designers love WPF and the designer-coder workflow is much better than it was before, but I won’t concentrate on design here. Also, “user experience” is a big part of WPF, but I’m just not approaching it from that angle yet.

Also, I tend to learn better by video, screencasts, and real code rather than articles. So, the resources below are weighted towards non-text.

Basics

  • WPF is the new (well, 2 or 3 year old) client-side development story for .NET. Windows Forms still exists, but from what I’ve seen any new development should strongly consider switching to WPF (see above). There are a few things missing that we have in Windows Forms (like a DataGrid/GridView) but those and much more are on their way (see this video from MIX08 for upcoming improvements).
  • WPF takes full advantage of Microsoft’s new way to express .NET code in XML. It’s called XAML (here is an overview that is worth a glance but the resources below are better).
  • Most of these resources assume you have installed (at a minimum) .NET Framework 3.5. Download and install here.

Great Resources (How To Learn It)

This is my version of the most efficient path for learning WPF. After these you will have a good understanding of how WPF works and some great examples to explore.

  • If you’re at all serious, go ahead and buy WPF Unleashed by Adam Nathan. Don’t really read it end-to-end, but you will reference it constantly while using the other resources here. It is very well done. Read the Amazon reviews for more praise. Chris Sells and Ian Griffith’s book is also good, but not as clear in my opinion.
  • I would start with these fantastic WPF Bootcamp videos (actually, the ones here are newer versions of the same material although I haven’t seen them yet — see Karsten’s blog entry below for a individual download links). Watch the first three videos (the keynote, lap around WPF, and lap around Blend) to get an overview of what WPF is all about. By all means, watch these on high speed (see the first sentence in this post for how to speed up videos — I couldn’t easily get the embedded versions to speed up so download them if you want to speed them up).
  • This post by jfo is a bit dated, but I found the attached Word document “WPF for those who know Windows Forms” to be a real gem (direct download link). It has information that I haven’t found aggregated anywhere else. Check the other links on that page, but that article is the great resource even if you aren’t coming from Windows Forms.
  • Watch the next two Bootcamp training videos by Ian Griffiths (or the equivalents in the newer videos). Really, really good. These will give you a solid base while whetting your appetite for some intermediate WPF functionality.
  • Kevin Moore’s Bag-o-Tricks (here) is bite-sized chunks of super cool WPF functionality. Tear into it, check out the code, and see how it works.
  • The Mix08 videos are largely for designers and the presentation layer. I haven’t seen any I would expressly recommend, but there is a lot of content here.

Other Resources

Most of these are highly recommended but they didn’t appeal to me like the Great Resources above.

Tools

Here are some tools that fill in the some gaps left by Visual Studio 2008 and WPF.

  • Microsoft Expression Blend - Awesome tool to develop WPF interfaces. It “blends” seamlessly with Visual Studio 2008 and makes design-time easier (general interface, animation, and lots more). It’s not free, but you can download the preview and beta versions for free. The latest as of now is the 2.5 March Preview (download here). Here’s some fantastic training videos for those interested in the design aspects of Blend.
  • XAMLPad (also see Kaxaml below) - A lightweight XAML editor where you can immediately see the results of your XAML. Kind of a sandbox for XAML like SnippetCompiler is for code. It comes as part of the Windows SDK. In my installation it can be found at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin .
  • Kaxaml - This is easier to install and has many more features than XAMLPad, but you might want XAMLPad anyway to follow most of the examples on the Web.
  • Snoop - Visually debug and inspect WPF applications at runtime (Spy++ for WPF).
  • Xceed DataGrid for WPF - Until Microsoft makes a DataGrid control you are stuck building your own out of a ListView in GridView mode, borrowing the WinForms grid (yuck), or using a third party grid. Xceed’s grid works well and the express edition is free within some boundaries. Infragistics has one too but I usually have bad experiences with their controls and there is no free version that I can see (disclaimer: I have not tried the Infragistics grid).

Blogs

There are a ton of WPF blogs, but these few are relatively active and have been the most helpful to me so far. Warning: once you start reading these blogs you are on your way down a slippery slope into WPF mastery that will eat up all your time. :)

  • Scott Guthrie - Microsoft head of .NET development, so this is the source of it all.
  • Josh Smith - Great teaching style on a wide range of WPF subjects.
  • Kevin Moore - The Bag-o-Tricks mentioned above and other insightful posts.
  • Ian Griffiths - Great in-depth .NET articles (not all WPF).
  • Dr. WPF - Lots of great info. No offense to the Dr, but the formatting and layout is a bit rough. I prefer to read this one in my RSS reader.
  • Karsten Januszewski - WPF training info but also a good source of WPF news and events. Check here for the 2008 Bootcamp videos and information that I mentioned above.

At this point you should have a ton of other resources to check out. WPF is huge and there is a lot to learn, but these resources should give you a solid start with WPF. Comment below if you have found anything else remarkable.

I also wanted to point out this other Getting Started post by Karsten. I really like the content but it is getting stale and the links are breaking.

Time stretching MP3 and other audio

Want to listen to that 8 hour audio book in 6 hours and not lose any details in the process?

I love Windows Media Player’s ability to speed up or slow down audio and video in real-time via its awesome Play Speed setting. This is commonly referred to as time stretching or changing tempo. If you listen to a lot of podcasts and audio books or watch a lot of instructional videos (like I do) this can save hours and hours in the long run.

The problem is that I like to listen to podcasts or audio books in the car, and I don’t have a fancy PC available to speed audio up in real-time. My Sansa e250 with Rockbox does lots of cool things, but alas it can’t speed up audio without the dreaded chipmunk effect.

I looked for a way to easily (and cheaply) time stretch my audio files, but mostly found a bunch of headaches. There are painful ways to do it with Audacity (open, apply filter, convert, save, etc.) and other audio editors. I think there’s a way to do it through WinAmp. There are also programs made to specifically convert audio like dbPoweramp, but I didn’t have much luck with that (and it’s not free).

My Solution

Here’s the best solution I’ve found so far (and I looked long and hard). It’s easy to setup and has worked super fantastically so far:

foobar2000 + SoundTouch DSP plug-in

1. Download and install foobar2000.

2. Download foo_dsp_soundtouch.dll from wherever you can find it (I got mine from here). This thing was a pain to find. You might also need the vc8 runtime files. They are included in the .NET runtime so might as well download and install that. Copy foo_dsp_soundtouch.dll to your foobar2000 components folder.

image

3. Drop an audio file (or a bunch of audio files) into foobar2000 (or use File -> Open). I’ll use an episode of the excellent Hanselminutes podcast as an example.

image

4. Choose a Convert option from the right-click context menu and set your encoding options (the ones in these pics work well for me).

image

image

5. Click OK and watch it churn out your sped up mp3(s).

Tips and Thoughts

I’ve been using 25% speed-up on audio books and informational podcasts and 12.5% on entertainment-related podcasts like Dawn and Drew. At 25% it’s easily listenable but you can really tell it’s sped up. At 12.5% you can really only tell if you listen to the original along side it. Also, I feel like I concentrate and pick up more (kind of a “flow” thing) when it is sped up.

Being able to drag and drop a bunch of files, right click once, and watch all the converted mp3s pop out is an amazing efficiency over some of the other methods I found.

So, let me know if you’ve found alternate solutions or can improve on this one (I haven’t tweaked many of the settings). And if you want to start looking forward to that hour-long drive to work in the morning, buy a cheap mp3 player and check some of these podcasts out.

So, this is my blog…

imageHello, World!  My name is Blake and I want to share things with you.  No, not those kinds of things.  Nice things.  Like knowledge.  I consider myself an accidental learner which means I stumble though information at various levels of efficiency and absorb stuff as I go.  That results in a lot of breadth without a lot of depth which is due to a bit of ADD and is sometimes a dangerous thing. :)

Professionally, I am employed by a company named TopCoder.  You might know them from their algorithm programming competitions (if you know C#, VB.NET, C++, or Java, I highly recommend them — super fun).  My work is on the software side of things.  We build enterprise software for customers using competitions through our member base.  I’m a project manager (sometimes architect) and have various responsibilities including launching some exciting and lucrative software design and development competitions.  I won’t talk about that much in this blog but comment if you are interested.

For fun, I’m mostly a nerd.  I do the normal geek stuff - read a lot of blogs, write a bunch of code (.NET mostly), and read a lot of books.  I also play some golf (not as much as I’d like) and watch some sports (again, not as much as I’d like). 

So, expect tech, sports, possibly a bit of politics, and whatever else is on my mind.

Welcome!