Code Coverage with Async Await

It may be a fools errand, but it is sometimes tempting to chase the elusive goal of achieving 100% code-coverage with unit tests.  I’m not going to argue the merits of using code coverage as part of your test strategy, but if you do want to accurately measure your code coverage, things get tricky with…

5

Mitigating Airspace Issues In WPF Applications

Introduction WPF offers a modern approach for building Windows applications, but it builds directly on Win32 – the traditional UI infrastructure in Windows. Because Win32 was developed in an era where CPU/GPU horsepower was much more limited than it is today, it utilizes a number of optimizations for rendering. These include using the “reverse painters…

16

Fun with floating point

Introduction WPF uses double-precision floating point numbers (double in C#) in much of its public API and it uses single-precision floating point for much of its internal rendering.  So floating point math is something we deal with constantly.  Oddly enough, I actually knew very little about the gory details until I recently tried to write…

3

Transparent Windows in WPF

Introduction WPF can obviously render transparent elements within its own window, but it also supports rendering the entire window with per-pixel transparency.  This feature comes with a few issues, which I’ll discuss in this post. Layered Windows Windows supports transparency at the HWND level through a feature called “layered windows“.  Layered windows are represented by…

7

Implementing A Custom BitmapSource

  Windows Imaging Component WPF uses the Windows Imaging Component (WIC) library to process bitmap data. WIC presents a data flow for bitmap processing that is both simple and powerful. The basic interface for bitmap processing in WIC is IWICBitmapSource. This interface provides a common way of accessing and linking together bitmaps, decoders, format converters,…

12

Blurry Bitmaps

Background: resolution independence WPF was designed from the start to be resolution independent.  So instead of designing your UI in terms of pixels, you are encouraged to use a physical measuring unit (like inches).  When you specify coordinates in WPF, you are actually using “measure units”, which are defined to be 1/96th of an inch. …

16

Multithreaded UI: HostVisual

Background: The WPF Threading Model In general, objects in WPF can only be accessed from the thread that created them.  Sometimes this restriction is confused with the UI thread, but this is not true, and it is perfectly fine for objects to live on other threads.  But it is not generally possible to create an…

20