This article is about a small Windows application that runs on the user's desktop and that can be configured and used to launch various applications.
This application is something that I wrote last week to explain the concepts of WinForms development to someone. I was initially planning to go with the usual
data entry type forms but since I only had to deal with form concepts and not data, I decided to develop this application. Also,
to make it a little interesting we
decided to get our user interface designed in such a way that it can be user as a drawer.
Using the code
The application in the initial state shows 16 launch spaces.
Each launch space can be configured by right clicking on the image and can be hooked with any application/file. In case a file is being selected,
the default program selected on the user machine will open that file.
Once applications are configured, the launcher app will look like:
This application runs hidden on the right border of the primary display and can be pulled on the screen by
the click of a button and then can be pushed back when done.
I have not tested it on an extended desktop so perhaps users with extended desktops will have to make some small changes in the code to put it on the secondary display.
The user interface
The user interface mainly contains three forms. One is the
MainForm that contains all the tiles, the second one is the small
HandleFrom that keeps
itself stuck to the main form. This handle is to draw/undraw the main form on and off the screen. The third form is the
dialog that lets the user to configure the launcher spaces with the desired apps and images.
The functionality of the application is very simple and can be summarized in the following steps:
- The application reads a data store (which is an XML file) to check for launcher configurations.
- If the file exists it will use that file.
- If the file does not exist it will create this file with the default values.
- Then data read from this XML is used to configure each tile in the MainForm.
- If the user right clicks and selects to configure/reconfigure the tile then the XML will be updated and the
MainForm will also be refreshed to reflect the changes.
- The user can launch any application by double clicking on the tile.
The classes involved here are:
Let us try to understand what each class is doing here:
LauncherItem: This class holds the path of the application that needs to be launched, the image location of the
tile image, and the display name for the application tile.
ItemManager: This class hold the collection of
LauncherItems and keeps the mapping of launcher items with the
tiles on MainForm. This class also has the functionality of saving and reloading this collections in
the form of XML so that configurations can be remembered between application runs.
SlidingController: This class does all the math and functionality required for sliding in and out of the forms and the repositions on
the handle form on the screen.
Note: The application is configured to have only one instance running at a time.
Points of interest
This small application is written just for the purpose of explaining Windows Forms development. The article itself does not contain any explanation on
Forms but gives a brief introduction to the application and pointers on how to use the code. But I hope someone
could find some bits and pieces of this application useful. I am ready to enhance the application and make changes to improve it and add more functionality, so suggestions are most welcome.
- 11 April 2012: First version.