Exploring the TimeCheck Application (Part 2)

Last week, in the Exploring the TimeCheck Application (Part 1) post, you saw an overview of what the TimeCheck application will do. Essentially, it’s a time management application that works by recording how you spend your time. Knowing how you spend your time has all sorts of benefits. To start this application, the user needs a method for signing into and out of the system. The main form (frmMain) is displayed when Windows starts. The user chooses a project from the list or types in a custom project, then chooses or types in an activity using this form.

TimeCheck0101

As you can see, this simple form provides the means to sign in or sign out (as needed). It also provides the means necessary to configure the application and to generate reports about activities. If the user clicks Exit when the application begins, the application records an entry in the event log and then exits. For now, let’s look at what you need to do to configure this form.

Control Property Value
Form1 (Name) frmMain
  AcceptButton btnSignIn
  CancelButton btnExit
  FormBorderStyle FixedDialog
  MaximizeBox False
  MinimizeBox False
  ShowInTaskbar False
  Size 300, 165
  Text TimeCheck
  Topmost True
ContextMenuStrip1 (Name) NotificationMenu
NotifyIcon1 (Name) ThisNotifyIcon
  ContextMenuStrip NotificationMenu
  Visible True
ToolTip1 (Name) toolTip1
Button1 (Name) btnSignIn
  AccessibleDescription Sign Into a Project
  Location 207, 12
  Size 75, 23
  TabIndex 0
  Text &Sign In
  ToolTip on toolTip1 Sign Into a Project
Button2 (Name) btnConfigure
  AccessibleDescription Configure the Application Features
  Location 207, 41
  Size 75, 23
  TabIndex 1
  Text &Configure
  ToolTip on toolTip1 Configure the Application Features
Button3 (Name) btnReport
  AccessibleDescription Request a Time Usage Report
  Location 207, 70
  Size 75, 23
  TabIndex 2
  Text &Report
  ToolTip on toolTip1 Request a Time Usage Report
Button4 (Name) btnExit
  AccessibleDescription Exit Without Signing In
  Location 207, 99
  Size 75, 23
  TabIndex 3
  Text &Exit
  ToolTip on toolTip1 Exit Without Signing In
Label1 (Name) lblProjectName
  AccessibleDescription Supply the Name of the Project
  Location 12, 9
  Size 71, 13
  TabIndex 4
  Text &Project Name
  ToolTip on toolTip1 Supply the Name of the Project
ComboBox1 (Name) cbProjectName
  Location 12, 25
  Size 189, 21
  TabIndex 5
Label2 (Name) lblWorkType
  AccessibleDescription Choose the Type of Task Performed
  Location 12, 49
  Size 72, 13
  TabIndex 6
  Text &Type of Work
  ToolTip on toolTip1 Choose the Type of Task Performed
ComboBox2 (Name) cbWorkType
  Location 12, 66
  Size 189, 21
  TabIndex 7

Both frmMain and ThisNotifyIcon have Icon properties that you must fill out. In this case, the application uses a red clock face with the hands set to 3:00. The icon is created using precisely the same technique as described for the GrabAPicture application in the “Exploring the GrabAPicture Application (Part 4)” post.

The NotificationMenu also requires special configuration. In this case, you see a context menu added to frmMain when you select the object. Here’s the entries you need to add to the ContextMenuStrip control.

TimeCheck0102

There isn’t anything fancy about this menu. It simply allows you to perform the tasks that you’d normally perform at the main dialog box. The special Open Window option displays frmMain when you need it (otherwise, the user simply sees an icon in the Notification Area).

You may wonder why NotificationMenu doesn’t include an option for signing out. Generally, the user will sign back into another project when signing out of the first one, except when ending the Windows session, in which case, the application automatically logs the user out. Leaving the Sign Out option off makes it less likely that a user will sign out of a project and then forget to sign into a new one as needed. Of course, you can always add the option when desired.

Next week you’ll see the form used to configure the application, frmConfigure. This form is actually going to appear in two different ways. Administrators will see the full set of configuration options we’ll discuss, while standard users will see a subset of the configuration options designed to meet their specific needs. Because of the duality of this form, you need to spend additional time designing it so that it works equally well for either user type. In the meantime, if you have any questions, please contact me at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the TimeCheck Application (Part 3).

 

Exploring the TimeCheck Application (Part 1)

The TimeCheck application is a utility that I’ve used over the years to track what I’m doing and when I’m doing it. By tracking my activities, I’ve been able to allocate funds for upgrades better and maximize my ROI. In addition, tracking my activities helps me understand how I work and provides me with ideas on how I can improve my efficiency. It’s a useful utility for tracking system time as well—to make it possible to calculate things like electrical usage and when it’s time for maintenance. I don’t see this as an enterprise tool. It’s more along the lines of something that an individual or small business would use. I know that larger businesses have complex application such as SCOM (System Center Operations Manager) to track such information.

I received a number of emails about the TimeCheck application we’re starting this week and have done some coding changes to my example to accommodate your requests. The application is written in C# and I’ve tried to simplify things as much as possible to ensure that the example is both fully functional and instructive. Here are the features that the TimeCheck application will have.

  • The user interface will allow the user to select a project and the type of work being done on that project.
  • A centralized configuration area for general items, such as project and work type lists.
  • A user-specific configuration area for items that affect a specific user, such as preferred project and work type.
  • A centralized location for XML-based log files.
  • Reporting features for individual users that are accessibly by members of the Administrators group.
  • The application will reside in the Notification Area to make accessing it easy, but keep it out of the way until needed.
  • The application will automatically request that the user log in when Windows starts.
  • The application will automatically log the user out when Windows stops.


Next week we’ll start looking at the user interface. In the meantime, are there any other features that you consider essential for this application? Let me know at John@JohnMuellerBooks.com. You can find the next post in this series at Exploring the TimeCheck Application (Part 2).

Exploring the TypingBuddy Application (Part 12)

This week’s programming series post is going to be a bit short. Last week (Exploring the TypingBuddy Application (Part 11)) you put the finishing touches on the basic TypingBuddy application. There are a number of useful additions that you could pursue, but many of them are straightforward enough that I’ll leave them in your capable hands.

 

  • Notification Area context menu updates for returning the timer to its starting point.
  • The option to display the remaining time in hours, minutes, and seconds, rather than in seconds.
  • The option to play sounds other than the default sounds included with the application.
  • Adding custom icons or pictures to the message box display.
  • Custom typing times based on the time of day.
  • Scheduled break times that override the standard typing time as needed.
  • An option to lock the system automatically when typing time is up (rather than simply display a message).


As with the GrabAPicture series, a number of you have asked me to put this entire series in an easier to use format. As with GrabAPicture, I’ll eventually put together an e-book for this series that includes:

 

  • All 12 posts for the series.
  • My personal series notes.
  • Some useful additions for the TypingBuddy application.
  • A URL for a downloadable copy of the application.

 

If there are any special additions you’d like to see in the e-book, let me know about them at John@JohnMuellerBooks.com. I’m always looking for interesting topics to cover in my books. Of course, letting me know what interests you will result in a better book.

Next week we’ll start another new application series. This application, TimeCheck, helps you track the use of your time during the day. You log into and out of projects in order to keep better track of how you’re using your time. This particular application has helped me improve my efficiency because I was able to use it to see where I waste time. In addition, I use the information obtained to do things like making buying decisions for new equipment and software based on how much I’ll actually use the new items.

The TimeCheck program has been with me for a long time—almost 25 years. The first version was written in assembler, but quickly proved hard to update. I wrote another version in C, but that version wasn’t quite what I wanted, so I reverted to the assembler version, until I rewrote the application yet again in Java. As my network grew and I saw the advantage of using automation with this application, I decided to rewrite it in its current form in C#. This version allows you to choose a storage location for the log files (including a network drive) and provides some interesting statistics. More importantly, it hides in the Notification Area to make it easier to keep track of how things are configured without cluttering the Taskbar.

 

Exploring the TypingBuddy Application (Part 11)

The TypingBuddy application is finally nearing completion. During the previous post, Exploring the TypingBuddy Application (Part 10), you discovered how the timing works within the application for controlling typing time. This week’s post will complete the basic TypingBuddy application. It consists of a few remaining event handlers for controls on frmMain. The three buttons in question, Save Settings (btnSet), Minimize Window (btnMinimize), and Change Messages (btnChangeMessages) have the following event handlers attached to their Click events.

private void btnSet_Click(object sender, System.EventArgs e)
{
   // Set the controls.
   TimeLeft = (Int32)TypingInterval.Value * 60;
 
   // Obtain the current settings.
   Settings.DisplayMessageIcon = chkShowIcon.Checked;
   Settings.PlaySound = chkPlaySound.Checked;
   Settings.RestInterval = (Int32)RestingValue.Value;
   Settings.TypingInterval = (Int32)TypingInterval.Value;
 
   // Save the settings.
   TBMessages.SaveSettings(Settings);
 
   // Start the timer.
   TypeTimer.Start();
}
 
private void btnMinimize_Click(object sender, System.EventArgs e)
{
   // Minimize the form.
   WindowState = FormWindowState.Minimized;
   ThisFrmMain.Hide();
}
 
private void btnChangeMessages_Click(object sender, EventArgs e)
{
   // Create the required form.
   frmMessages ManageMessages = new frmMessages();
 
   // Display the form.
   ManageMessages.ShowDialog(this);
 
   // Upon return from the form, make sure you reload the settings.
   Settings = TBMessages.LoadSettings();
}

When the user clicks Save Settings, the application begins by updating the amount of time left to the new time setting the user has provided. The application then obtains updates for all of the required properties in Settings, and then saves Settings to disk. Remember the Settings is a global variable that contains the application settings and also contains a list of custom messages that the user wants to use with the application. After Settings is saved, the application starts the typing timer by calling TypeTimer.Start().

One of the mistakes that developers make when creating an application that resides in the Notification Area is to hide the form. The btnMinimize_Click() event handler shows the proper way to handle things. You minimize the form and then hide it from view. This technique ensures that the user doesn’t see anything in the Taskbar or on screen.

Previous posts have described the entire process for creating and managing messages in detail. However, you still haven’t seen the call that starts the entire process. When the user clicks Change Messages, the application calls on the btnChangeMessages_Click() event handler. The event handler creates an instance of frmMessages, ManageMessages, and displays the form on screen. Remember that for reliability purposes, this process is pretty much self-contained. When the user closes the form, the event handler calls TBMessages.LoadSettings() to update Settings with the message changes that the user had made.

At this point, you have a copy of TypingBuddy as it exists today. Of course, application developers are always tweaking their applications to make them better. What sorts of changes can you suggest for TypingBuddy? Let me know at John@JohnMuellerBooks.com.

 

Exploring the TypingBuddy Application (Part 9)

In the Exploring the TypingBuddy Application (Part 8) post you discovered how the TypingBuddy form loads and closes. However, after the initial configuration, you might never see that form again because TypingBuddy loads itself in the Notification Area. The first thing to notice is that the Notification Area contains an icon for this application named ThisNotifyIcon. You can assign a default behavior to this icon by creating an event handler for the DoubleClick event named NotifyIcon_DoubleClick().  All that this event handler does is display the form as shown in the following code.

private void NotifyIcon_DoubleClick(object sender, EventArgs e)
{
   // Display the form.
   ThisFrmMain.Show();
   WindowState = FormWindowState.Normal;
}

When the user right clicks on the TypingBuddy icon in the notification, the application displays a menu containing options for opening the window, pausing the countdown, and exiting the application. Of course, you could easily add any other functionality required by your personal needs, including the ability to configure the application.

TypingBuddy0901

In order to create this menu, you must select the NotificationMenu component (added as part of the Exploring the TypingBuddy Application (Part 2) post) and click on the right pointing arrow that appears in the upper right corner of the control. You’ll see an Edit Menu link on a menu like this one shown here.

TypingBuddy0902

Clicking Edit Menu adds the context menu to the design area. You can then add the menu entries to it as shown here.

TypingBuddy0903

Each of these menu entries requires some configuration as shown in the following table.

Menu Property/Event Value/Event Handler
mnuOpen Text &Open Window
  Click NotifyIcon_DoubleClick()
mnuPause Text &Pause
  Click btnPause_Click()
mnuExit Text E&xit
  Click mnuExit_Click()

You’ve already seen the code for mnuOpen, which is the same code that executes when the user double clicks the icon. Here is the code you use for mnuPause and mnuExit.

bool IsPaused;   // Is the timer paused?
 
private void btnPause_Click(object sender, System.EventArgs e)
{
   if (IsPaused)
   {
      // Start the timer.
      IsPaused = false;
      TypeTimer.Start();
 
      // Display status information.
      btnPause.Text = "&Pause";
      mnuPause.Text = "&Pause";
   }
   else
   {
      // Stop the timer.
      IsPaused = true;
      TypeTimer.Stop();
 
      // Display status information.
      btnPause.Text = "&Restart";
      mnuPause.Text = "&Restart";
      ThisNotifyIcon.Text = "Timer is Paused";
   }
}
 
private void mnuExit_Click(object sender, System.EventArgs e)
{
   // Obtain the current settings.
   Settings.DisplayMessageIcon = chkShowIcon.Checked;
   Settings.PlaySound = chkPlaySound.Checked;
   Settings.RestInterval = (Int32)RestingValue.Value;
   Settings.TypingInterval = (Int32)TypingInterval.Value;
 
   // Save the settings.
   TBMessages.SaveSettings(Settings);
 
   // Exit the application.
   Close();
}

The btnPause_Click() event handler is actually shared with the Pause button on frmMain, so you’ll see it mentioned again. Because there are two distinctly different ways to pause the application, the code requires a semaphore (a shared variable) to maintain the state information. When the application is paused, selecting Restart will change the IsPaused variable, restart the timer, and change the captions for both the Pause button and the NotificationMenu menu to Pause. The reverse happens when the application is running—IsPaused is set to true, the timer is stopped, and the captions are changed to Restart.

When the user clicks Exit on the NotificationMenu, the application calls the mnuExit_Click() event handler. This event handler changes the Settings properties to match those of frmMain, and then saves the settings to disk. It then closes frmMain, which ends the application.

That’s almost it for the Notification Area code. There is one added feature for ThisNotifyIcon. It displays the remaining time when you hover the mouse over it. This feature is covered in next week’s post, which discusses the Timer_Tick() event handler. This event handler is quite complex because it has to consider issues like which message to display, which can vary depending on whether the user has chosen to use dates with the messages. In the meantime, let me know whether you have any questions about this part of the application at John@JohnMuellerBooks.com. You can find the next post in this series at Exploring the TypingBuddy Application (Part 10).

 

Exploring the TypingBuddy Application (Part 3)

The Exploring the TypingBuddy Application (Part 2) post describes the part of the user interface used to inform the user about the current application status. You also saw the configuration features found on frmMain. This post continues the discussion of the application configuration interface. In order to make TypingBuddy a little more interesting to use, the user requires some method of inputting custom messages and having them saved from session-to-session.

The first part of this interface is to provide some means of working with the group of messages—all of the messages that the user has defined. The frmMessages interface looks like this:

TypingBuddy0301

As you can see, the form provides a simple method of displaying the entire message list. You can click buttons to add, edit, and delete messages as needed. Clicking Close will close the form and return the user to TypingBuddy Settings (frmMain). Here are the settings for this form:

Control Property Value
Form3 (Name) frmMessages
  AcceptButton btnAdd
  CancelButton btnClose
  FormBorderStyle FixedDialog
  Size 290, 290
  Text Configure the Messages
ToolTip1 (Name) toolTip1
Button1 (Name) btnAdd
  AccessibleDescription Add a new entry.
  DialogResult OK
  Location 197, 12
  Size 75, 23
  TabIndex 0
  Text &Add
  ToolTip on toolTip1 Add a new entry.
Button2 (Name) btnEdit
  AccessibleDescription Edit the selected entry.
  Location 197, 41
  Size 75, 23
  TabIndex 1
  Text &Edit
  ToolTip on toolTip1 Edit the selected entry.
Button3 (Name) btnDelete
  AccessibleDescription Deletes the selected entry.
  Location 197, 70
  Size 75, 23
  TabIndex 2
  Text &Delete
  ToolTip on toolTip1 Deletes the selected entry.
Button4 (Name) btnClose
  AccessibleDescription Closes the dialog box.
  DialogResult Cancel
  Location 197, 99
  Size 75, 23
  TabIndex 3
  Text &Close
  ToolTip on toolTip1 Closes the dialog box.
Label1 (Name) lblMessages
  Location 12, 9
  Size 55, 13
  TabIndex 5
  Text &Messages
ListBox1 (Name) lstMessages
  AccessibleDescription Contains a list of messages to display.
  Location 12, 25
  Size 179, 255
  TabIndex 6
  ToolTip on toolTip1 Contains a list of messages to display.

Of course, the application also requires a detail form, frmAddEdit, that makes it possible to work with individual messages. This form has to serve a dual purpose: adding new messages and editing existing messages. Consequently, the code provides the means for modifying the way that the form works, but the designer provides just one view, the one used for adding new messages, as shown here:

TypingBuddy0302

This form contains every setting you can make for an individual message. Some of the settings could be considered ancillary, but they’re nice to have. For example, you could just assume that the user wants to display the message title as part of the message that the application displays, but having the choice allows the user to create more functional message titles that are descriptive, but not necessarily useful in the message title bar. The example uses basic system sounds, which will likely prove enough for most users, but an improvement would allow the user to add any sound desired. Some messages will only work at certain times of the year, so the application also lets the user assign a useful date to specific messages. Here are the settings for this form.

Control Property Value
Form4 (Name) frmAddEdit
  AcceptButton btnAdd
  CancelButton btnClose
  FormBorderStyle FixedDialog
  Size 290, 360
  Text Add a New Message
ToolTip1 (Name) toolTip1
Button1 (Name) btnAdd
  AccessibleDescription Adds the new item to the list.
  DialogResult OK
  Location 197, 12
  Modifiers Public
  Size 75, 23
  TabIndex 0
  Text &Add
  ToolTip on toolTip1 Adds the new item to the list.
Button2 (Name) btnClose
  AccessibleDescription Closes the form without making a change.
  DialogResult Cancel
  Location 197, 41
  Size 75, 23
  TabIndex 1
  Text &Close
  ToolTip on toolTip1 Closes the form without making a change.
Label1 (Name) lblTitle
  Location 12, 9
  Size 73, 13
  TabIndex 2
  Text &Message Title
TextBox1 (Name) txtTitle
  AccessibleDescription Contains the name of the message.
  Location 12, 25
  Modifiers Public
  Size 179, 20
  TabIndex 3
  Text My Message
  ToolTip on toolTip1 Contains the name of the message.
CheckBox1 (Name) chkShowTitle
  AccessibleDescription Determines whether the title is displayed.
  Location 12, 51
  Modifiers Public
  Size 76, 17
  TabIndex 4
  Text &Show Title
  ToolTip on toolTip1 Determines whether the title is displayed.
Label2 (Name) lblMessageText
  Location 12, 71
  Size 74, 13
  TabIndex 5
  Text Message &Text
TextBox2 (Name) txtMessageText
  AccessibleDescription Contains a description of what to do while resting.
  Location 12, 87
  Modifiers Public
  Multiline True
  Scrollbars Vertical
  Size 260, 100
  TabIndex 6
  ToolTip on toolTip1 Contains a description of what to do while resting.
Label3 (Name) lblSound
  Location 12, 190
  Size 78, 13
  TabIndex 7
  Text &Related Sound
ComboBox1 (Name) cbSound
  AccessibleDescription Determines which sound to play when displaying the message.
  Location 12, 206
  Modifiers Public
  Size 121, 21
  TabIndex 8
  ToolTip on toolTip1 Determines which sound to play when displaying the message.
CheckBox2 (Name) chkDateSpecific
  AccessibleDescription Determines whether the message has a timeframe.
  Location 12, 233
  Modifiers Public
  Size 76, 17
  TabIndex 9
  Text &Use Dates
  ToolTip on toolTip1 Determines whether the message has a timeframe.
Label4 (Name) lblStartDate
  Location 12, 253
  Size 69, 13
  TabIndex 10
  Text Starting &Date
DateTimePicker1 (Name) dtStartDate
  AccessibleDescription Defines the starting date for this message.
  Enabled False
  Location 12, 269
  Modifiers Public
  Size 200, 20
  TabIndex 11
  ToolTip on toolTip1 Defines the starting date for this message.
Label5 (Name) lblEndDate
  Location 12, 292
  Size 52, 13
  TabIndex 12
  Text &End Date
DateTimePicker1 (Name) dtEndDate
  AccessibleDescription Defines the ending date for this message.
  Enabled False
  Location 12, 308
  Modifiers Public
  Size 200, 20
  TabIndex 13
  ToolTip on toolTip1 Defines the ending date for this message.

At this point, you have the application designed. The next post in this series will explore the method used to store the user settings on disk. In the meantime, let me know if you have any questions about the application to this point at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the TypingBuddy Application (Part 4).

 

Exploring the TypingBuddy Application (Part 2)

In the previous post of this series, Exploring the TypingBuddy Application (Part 1), you considered why TypingBuddy is a useful application and some of the parameters required to create such an application. Of course, it’s always nice to think about how to put an application together, but actually working on the application is more educational. This post will begin exploring the application design by looking at a few of the forms used to display the application timing (the next post will discuss forms used for configuration purposes).

The first thing to understand is that this application won’t normally appear on screen at all until the typing time is done. The only exception the first time the application is used. In this case, the user sees the following message box stating that the application hasn’t been configured and then the main form appears on screen.

TypingBuddy0101

The default operation is for the application to start and immediately hide the main form. You’ll see an icon in the notification area. Right clicking this icon displays the following choices.

TypingBuddy0202

When the user selects Open Window, TypingBuddy displays the main form. Here’s how frmMain will appear.

TypingBuddy0203

I decided that this example would contain full accessibility settings from the outset, so there are some features you may not have worked with in the past. For example, in order for some screen readers to read the purpose of a particular control, you must provide a ToolTip control on your form. You’ll use the following configuration settings to create frmMain. (The icon is created using precisely the same technique as described for the GrabAPicture application in the “Exploring the GrabAPicture Application (Part 4)” post.)

Control Property Value
Form1 (Name) frmMain
  AcceptButton btnSet
  CancelButton btnQuit
  FormBorderStyle FixedDialog
  ShowInTaskbar False
  Size 298, 294
  Text TypingBuddy Settings
  WindowState Minimized
NotifyIcon1 (Name) ThisNotifyIcon
  Visible True
ContextMenu1 (Name) NotificationMenu
Timer1 (Name) TypeTimer
  Interval 1000
ToolTip1 (Name) toolTip1
Button1 (Name) btnSet
  AccessibleDescription Set the timer interval.
  Location 176, 12
  Size 104, 23
  TabIndex 0
  Text &Save Settings
  ToolTip on toolTip1 Set the timer interval.
Button2 (Name) btnPause
  AccessibleDescription Momentarily pause the timer.
  Location 176, 41
  Size 104, 23
  TabIndex 1
  Text &Pause
  ToolTip on toolTip1 Momentarily pause the timer.
Button3 (Name) btnMinimize
  AccessibleDescription Cause the window to disappear without exiting the program.
  Location 176, 70
  Size 104, 23
  TabIndex 2
  Text &Minimize Window
  ToolTip on toolTip1 Cause the window to disappear without exiting the program.
Button4 (Name) btnChangeMessages
  AccessibleDescription Configure the resting time messages.
  Location 176, 99
  Size 104, 23
  TabIndex 3
  Text &Change Messages
  ToolTip on toolTip1 Configure the resting time messages.
Button5 (Name) btnQuit
  AccessibleDescription Exit the program.
  DialogResult Cancel
  Location 176, 128
  Size 104, 23
  TabIndex 4
  Text &Quit
  ToolTip on toolTip1 Exit the program.
Label1 (Name) lblTimerValue
  Location 12, 9
  Size 158, 13
  TabIndex 5
  Text &Typing interval (in minutes):
NumericUpDown1 (Name) TypingInterval
  AccessibleDescription Enter the typing time in minutes.
  Location 12, 25
  Maximum 1200
  Size 120, 20
  TabIndex 6
  ToolTip on toolTip1 Enter the typing time in minutes.
  Value 60
Label2 (Name) lblRestingValue
  Location 12, 48
  Size 158, 13
  TabIndex 7
  Text &Resting interval (in minutes):
NumericUpDown2 (Name) RestingValue
  AccessibleDescription Enter the resting time in minutes.
  Location 12, 64
  Maximum 1200
  Size 120, 20
  TabIndex 8
  ToolTip on toolTip1 Enter the resting time in minutes.
  Value 10
Label3 (Name) lblTypingTime
  Location 12, 87
  Size 158, 13
  TabIndex 9
  Text Time Left (in Seconds):
TextBox1 (Name) txtTypingTime
  AccessibleDescription Displays the remaining time in seconds.
  Location 12, 103
  ReadOnly True
  Size 100, 20
  TabIndex 10
  Text
  ToolTip on toolTip1 Displays the remaining time in seconds.
CheckBox1 (Name) chkShowIcon
  AccessibleDescription Displays the icon on the message box.
  Location 12, 129
  Size 158, 17
  TabIndex 11
  Text Display Message Box &Icon
  ToolTip on toolTip1 Displays the icon on the message box.
CheckBox2 (Name) chkPlaySound
  AccessibleDescription Plays a sound when the message box opens.
  Location 12, 152
  Size 158, 17
  TabIndex 12
  Text Pla&y Sound
  ToolTip on toolTip1 Plays a sound when the message box opens.

Configuring the ContextMenu, NotificationMenu, is important. In order to perform this task, you must click the Edit Menu link in the lower part of the Properties window. When you click this link, the display will change as shown here (this menu is fully configured).

TypingBuddy0203a

As you can see, you simply type the menu options you want to create. The names of these three menu entries are mnuOpen, mnuPause, and mnuExit. Except for assigning each menu entry a (Name) and Text property, you won’t do anything with them for now. Later posts will describe how to work with this menu.

Of course, the purpose of TypingBuddy is to display a dialog box telling you that it’s time to stop typing for a while. The original version of this program used a simple MessageBox, but this approach has quite a few problems, not the least of which is that you can’t force a MessageBox to appear on top of everything else. It’s easy to miss the message to quit typing for a while. With this in mind, the latest version of TypingBuddy uses frmMessage to display the message to rest as shown here.

TypingBuddy0204

The configuration settings might be a little more complex than you might think. For one thing, this dialog box requires a separate timer for resting time. The following table shows the configuration settings for this dialog box.

Control Property Value
Form2 (Name) frmMessage
  AcceptButton btnContinue
  CancelButton btnQuit
  ControlBox False
  FormBorderStyle FixedDialog
  MinimizeBox False
  MaximizeBox False
  Size 290, 290
  Text Time to Rest
  Topmost True
Timer1 (Name) RestTimer
  Interval 1000
ToolTip1 (Name) toolTip1
Button1 (Name) btnContinue
  AccessibleDescription Displays the resting time or allows the program to continue.
  DialogResult OK
  Location 197, 12
  Size 75, 23
  TabIndex 0
  Text &Continue
  ToolTip on toolTip1 Displays the resting time or allows the program to continue.
Button2 (Name) btnQuit
  AccessibleDescription Exit the program.
  DialogResult Cancel
  Location 197, 41
  Size 75, 23
  TabIndex 1
  Text &Quit
  ToolTip on toolTip1 Exit the program.
Label1 (Name) lblMessage
  Location 12, 9
  Size 50, 13
  TabIndex 2
  Text &Message
TextBox1 (Name) txtMessage
  AccessibleDescription Displays the activity to pursue while resting.
  Location 12, 25
  Multiline True
  ReadOnly True
  Size 179, 225
  TabIndex 3
  Text Time to Rest! Take a break!
  ToolTip on toolTip1 Displays the activity to pursue while resting.

That’s it for this week. Next week, we’ll discuss forms you’ll need to create so that the user can design custom messages. Let me know if you have any question about these forms at John@JohnMuellerBooks.com. You can see the next post in this series at Exploring the TypingBuddy Application (Part 3).

 

Exploring the TypingBuddy Application (Part 1)

Many people find that they spend too much time in front of the monitor at once. If you’re like me and put in a 12 to 14 hour day, sitting in front of the monitor for an extended length of time can have significant detrimental effects. At one time, I was starting to suffer a little from muscle stress and eye strain. If I had continued the way I was going, I would have eventually had to deal with carpal tunnel syndrome and other nasty side effects of computer usage. The fact is, in order to stay healthy, you have to get up and move away from the computer screen regularly during the work day. If you maintain healthy work habits, you’ll find that you can actually work longer at the computer and that your work time will be significantly more productive. It’s because I understood the problems of computer use early that I developed TypingBuddy.

No one likes to be nagged. So, one of the goals for TypingBuddy was to make the application at least a little fun and relatively non-intrusive. Over the years, I’ve continued to add little perks to TypingBuddy to keep it fresh, but also to improve the overall application. The first version of TypingBuddy didn’t include very much and it displayed the same message every time, which proved boring. The application now provides a number of features that I didn’t originally include, such as the ability to define non-computer rest time tasks and a countdown timer for the off time as well as on time. For the purpose of this example, off time is the time that you spend doing something other than working at your computer. That means getting up from the chair and doing something physical for the most part. TypingBuddy can only suggest that you move around—only you can actually decide to do it. On time is the time that you spend working at your computer.

Experience has shown me that I personally need to take ten to fifteen minutes of off time after each hour of on time. So, I set TypingBuddy to display an alert after each hour. When I click the button acknowledging the alert, another countdown timer shows how much off time I have left. The alert provides me with a random task to perform, such as pet the dog, kiss my wife , feed wood to the wood stove, or walk around the house. An editor lets me type in any set of random tasks that I want. Because some of these random tasks, such as feed the wood stove, are only applicable to a specific time of year, I can also type in a date range for doing them so that TypingBuddy doesn’t tell me to feed the wood stove on a hot day in the summer or walk around the house in the middle of winter. A button titled, Another Task, lets me grab a different task when the current task isn’t applicable. I’ve typed in a wealth of interesting tasks to perform over the years in an effort to make TypingBuddy fun to use.

The information that you provide to TypingBuddy is stored in two places in the current version. I decided to use the Windows registry to store the TypingBuddy settings, such as the amount of off time and on time, when I originally designed the application. An XML database stores the alerts in the user’s personal data folder. I decided on changing the data location after I started working with XML files. One of the updates I’ve been considering for TypingBuddy is to remove the registry from the picture. As you saw from the GrabAPicture application I just finished, it’s possible to store everything in the user’s data folder and make it easier to back up as well. In fact, I’ll likely make this change before we get started on the actual construction of the application next week.

TypingBuddy has to be running constantly in order to do its job. Of course, you don’t want to see TypingBuddy unless it has an alert to display. Consequently, TypingBuddy resides in the Notification Area. When you hover the mouse over the TypingBuddy icon, you see the number of second left in the current on time. Right clicking the icon displays a menu of actions you can perform with TypingBuddy, such as displaying the TypingBuddy configuration dialog box or temporarily pausing TypingBuddy. The menu automatically changes as conditions change.

Of course, I’m always interested in your input, which is the purpose of this introductory blog post. What would you like to see in an application like TypingBuddy? Let me know your thoughts at John@JohnMuellerBooks.com. In the meantime, I’ll be adding a few more bits of polish to TypingBuddy before writing the initial design post next week. The next post in this series is Exploring the TypingBuddy Application (Part 2).