Tag: c#

  • SetDPI Utility Version 2

    View source on GitHub. A couple of years ago I made a small command-line program for setting the DPI/PPI of PNG files. I used the System.Drawing.Bitmap class (i.e. GDI+) to set this property, which had the unfortunate side effect of producing relatively bloated files. Given that the chunk specifying this property is only 21 bytes […]

  • Image Background Remover Tool

    View source on GitHub. Inspired by Window Clippings, my preferred screenshot tool (which unfortunately crashes a lot under Windows 8 RTM), I wrote a small program for making image backgrounds transparent. It comes with a command-line interface and a basic GUI (pictured above). The GUI supports dragging-and-dropping images, and you can switch the black and […]

  • Pixel-perfect Multi-DPI Images in WPF (Part 3)

    View source on GitHub. In Part 1 of this series, I discussed the problem of displaying different bitmap images at different DPIs in WPF. In Part 2, I proposed a solution using multi-frame TIFFs and two simple markup extensions. In this final post I will present a basic program that takes multiple images (PNG recommended), […]

  • P/Invoke and ChooseFont (Comdlg32.dll)

    Mister Goodcat wrote a good article a little while ago about using P/Invoke in Silverlight 5 to display the native font chooser dialog with the ChooseFont function. I couldn’t get the code working for a 64-bit executable, however, as the definition of the CHOOSEFONT structure on MSDN he used as a basis for the managed […]

  • Retrieving Windows 8 Theme Colours

    See also: Windows 8 Theme Colours Reference. Windows 8 doesn’t offer developers access to system theme colours, unlike its cousin, Windows Phone. Even for a version 1 product, this seems like a strange omission. Then again, we still don’t have a working public API for retrieving the Aero glass colour (or whatever we call it […]

  • Windows 7-style Notification Area Applications in WPF: Recap & Sample

    View source on GitHub. Over the past month I’ve looked at how to implement a Windows 7-style notification area application in WPF. I covered 6 different topics: Part 1: Removing Border Resize Part 2: Notify Icon Position – Windows 7 Part 3: Taskbar Position Part 4: Multiple Monitors & Working Area Part 5: Fixing Aero […]

  • Windows 7-style Notification Area Applications in WPF: Part 6 (Notify Icon Position: Pre-Windows 7)

    View source on GitHub. In Part 2 of this series I demonstrated how to use the Shell_NotifyIconGetRect function to find the position of a notify icon. This function is new to Windows 7, however, and we must find a different solution for earlier versions of Windows. This turns out to be quite difficult. A post […]

  • Windows 7-style Notification Area Applications in WPF: Part 5 (Fixing Aero Borders)

    View source on GitHub. An issue that came to my attention only recently is that the borders of WPF (update: WPF is not actually to blame) windows without captions/title-bars (that is, with ResizeMode set to ‘CanResize’ and WindowStyle set to ‘None’) are drawn incorrectly when the DWM (read: Aero Glass) is enabled. Specifically, the upper […]

  • Windows 7-style Notification Area Applications in WPF: Part 4 (Multiple Monitors)

    View source on GitHub. At the end of Part 3 in this series, I noted that the window positioning logic depends on accurately getting the bounds of the monitor where the notify icon is located. Specifically, we require the bounds of the working area (the space on the monitor excluding the taskbar and other docked […]

  • Windows 7-style Notification Area Applications in WPF: Part 3 (Taskbar Position)

    View source on GitHub. In the previous post in this series, I showed how to find the location of a notify icon by implementing the new Windows 7 Shell32.dll function Shell_NotifyIconGetRect in managed code for use with the System.Windows.Forms.NotifyIcon class. In this post, I will look at how to accurately position a window above (or […]