iTuner is a WPF application with a minimal user interface. When started, iTuner presents itself as a notify icon in the Windows system tray. As iTunes playback begins, a notification window is displayed showing the current track information.
Clicking the notify icon opens the dashboard panel. Right-clicking the notify icon opens a context menu of common actions.
- Notify Icon
Apple was thoughtful enough to release a COM interface for iTunes; this is installed along with iTunes. Also available on their
is an SDK, which really just means a moderately adequate .chm help file. So once iTunes is installed, you simply need to add a reference to the iTunesLib Type Library in your project.
The first task peformed by iTuner is to determine if iTunes is active and if not then activate it. To determine if iTunes is active, we simply enumerate the processes on the system looking for the process name "iTunes". If found then we can continue.
However, if iTunes is not yet active, it may take a few seconds to fully initialize it so we want to display a splash screen to entertain the user while they're waiting. The splash screen is described a bit
The Controller class is a thin wrapper that encapsulates the an iTunesAppClass instance and provides easy binding points for our UI. Nothing fancy here, only simple C# properties and a basic implementation of INotifyPropertyChanged.
There are a couple of additional features of Controller. The lyrics discovery engine is maintained by Controller. There is also a one-second repeating timer that simply signals an OnPropertyChanged event for the current track. This drives updates for the UI,
partcularlly the TrackPanel control.
Visual Studio Project Configuration
iTuner contains some low level Win32 Interop code such as hot key registration, that does not work when hosted within the Visual Studio hosting process used for debugging. For this reason, you must disable this by modifying the project properties. In the iTuner.csproj
settings, I've unchecked the Enable the Visual Studio hosting process
Images and Artwork
All of the image files used in the iTuner application were captured and at least moderately modified using
. The .pdn files in the Images folder are native Paint.NET files.
The iTuner.exe assembly contains its own default application icon. It also contains an icon used for the Start menu Uninstall shortcut. Embedding multiple icons in a .NET executable is a straightforward process. The first icon in this .res file will appear
as the default app icon. Ed Poore wrote a nice
, more or less repeated here.
Copyright (c) 2010 Steven M. Cohn. All rights reserved.
- Create a new Native Resource Template from the File | New dialog box
- Right click anywhere in the designer, and select "Add Resource..."
- You can, at this point, import any resources you wish to embed, but we will import some icons, so click "Import..." and select the icon files. If you wish, you can change the ID associated with the resources in the Properties window.
- Now, we must save the resource template as a 32-bit Resource File. This is done via File | Save As..., making sure that "32-bit Resource File (*.res)" is selected in the "Save as type" box. Save it somewhere logical, e.g., in your project's
- Open up the Application tab of the Properties page of your project.
- In the "Resources" group box, change the selection to point to Resource File, and browse for the resource file you just saved.
- Once the previous step has been completed, Visual Studio will now embed the Win32 resource into the executable when it compiles. To see the changes, simply recompile the application.