Exploring the GrabAPicture Application (Part 2)

In the previous post, Exploring the GrabAPicture Application (Part 1), we discussed the basic parameters for the application—that it provides a means of changing the desktop wallpaper automatically, use online as well as local resources, and sports a command line interface (amongst other features). This post starts building the application.

You’ll start with the basic Windows Forms Application template. Rename the initial form as frmMain (this application will contain a number of forms) by right clicking the form’s entry in Solution Explorer and choosing Rename File from the context menu. This first form is the one that you’ll always see when you start the application from the command line. After you rename the initial form, add two more forms, frmAddEdit (used to add new entries and edit existing entries) and frmConfigure (used to display and manage the list of local and remote sources), by right clicking the project entry in Solution Explorer and choosing Add | New Item from the context menu. You saw the working version of these forms in the previous post.

 

I’m eliminating a few configuration features from the example for the sake of simplicity. For example, you should include tooltips with your version of the application to make it accessible. When the example is completely finished, you’ll be able to download the source code and see some of these additions for yourself.

Let’s begin with the design of frmMain.
Here’s how frmMain will appear.

GrabAPicture0201

This form lets the user type in the location of a piece of wallpaper and use it directly by typing something into Wallpaper Location, selecting a style in Style Selection, and clicking Set Value. The user can also click Random Sources to see a list of available wallpaper sources, which is actually the preferred method of interacting with the application because this technique lets the user save entries for future use. Close will close the form. The user can also use this form to choose whether to use local sources, remote sources, or both. The following table describes the control configuration for this form (add the controls to the form in the order shown to reduce the amount of configuration you must perform).

Control Property Value
Button1 (Name) btnOK
  DialogResult OK
  Location 208,8
  Modifiers Friend
  Size 104,23
  TabIndex 0
  Text Set &Value
Button2 (Name) btnConfigure
  Location 208,40
  Modifiers Friend
  Size 104,23
  TabIndex 1
  Text &Random Sources
Button3 (Name) btnCancel
  DialogResult Cancel
  Location 208,72
  Modifiers Friend
  Size 104,23
  TabIndex 2
  Text &Close
Label1 Location 8,8
  Modifiers Friend
  Size 144,23
  TabIndex 3
  Text &Wallpaper Location:
TextBox1 (Name) txtWallpaperURI
  Location 8,32
  Modifiers Friend
  Size 176,20
  TabIndex 4
GroupBox1 Location 8,64
  Modifiers Friend
  Size 192,100
  TabIndex 5
  Text Style Selection
RadioButton1 (Name) rbStretched
  Location 16,24
  Modifiers Friend
  Size 104,24
  TabIndex 6
  Text &Stretched
RadioButton2 (Name) rbCentered
  Location 16,48
  Modifiers Friend
  Size 104,24
  TabIndex 7
  Text &Centered
RadioButton3 (Name) rbTiled
  Location 16,72
  Modifiers Friend
  Size 104,24
  TabIndex 8
  Text &Centered
CheckBox1 (Name) cbLocal
  Location 8,176
  Modifiers Friend
  Size 184,24
  TabIndex 9
  Text Use Random &Local Sources
CheckBox2 (Name) cbRemote
  Location 8,208
  Modifiers Friend
  Size 184,24
  TabIndex 10
  Text &Use Random Remote Sources

Next time we’ll look at two other forms. The first helps the user manage local and remote sources. The second will provide the means for adding or editing individual entries. Let me know if you have any questions at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the GrabAPicture Application (Part 3).