Click here to Skip to main content
13,089,433 members (59,172 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


16 bookmarked
Posted 15 Dec 2012

A Simple Punch Clock Applet

, 15 Dec 2012
Rate this:
Please Sign up or sign in to vote.


A couple years ago I wrote a piece of code that counted down to a particular event - you can read the article here.  After my current gig full time ended in September, I ended up getting involved in several different projects, all at the same time, and realized I really need a simple to use punch-clock application that would simply count how much time I'm spending on each project.  It seemed reasonable to use the same code base for the "Countdown Reminders" and modify it slightly to work as a punch clock instead.

Yes, this is a ridiculously short article, but you perhaps you'll find the application useful or give me some ideas on what you'd like to see added.  I have a few ideas that I discuss at the end.

Under the Hood

This section discusses the changes made to the Countdown Reminder code.

The User Interface

You can read the Countdown Reminders article for how the UI works - I made some minor modifications, eliminating the option to select fields, which resulted in a more brute force way of initializing the counter groups:

protected void CreateCounterGroups()
  int pos = 0;
  dayGroup = new Group("Days");
  hourGroup = new Group("Hours");
  minuteGroup = new Group("Minutes");
  secondGroup = new Group("Seconds");

  foreach (Group group in new List<Group>() { dayGroup, hourGroup, minuteGroup, secondGroup })
    group.Location = new Point(pos, 0);
    pos += group.Width;

  Width = 6 * Group.GroupWidth;

However, everything else is the same with regards to the presentation of the timers.

I did change the popup menu to include a "start" and "stop" option:

I also modified the data structure which is reflected in the Setup UI:

The Data Structure

The underlying data structure just has a description and time:

private static void CreateTable()
  counterTable = new DataTable("Counters");
  counterTable.Columns.Add("Index", typeof(Int32));
  counterTable.Columns.Add("Description", typeof(string));
  counterTable.Columns.Add("Time", typeof(long));

  counterView = new DataView(Program.counterTable);
  counterView.Sort = "Index";

Ideally, a DataSet should be used to support a second child table to record the start & stop date-time activity, but that's for a future version.

One Project at a Time

This hard-coded feature:

private void startToolStripMenuItem_Click(object sender, EventArgs e)

ensures that only one project at a time can be "punched in" - having time charged against it.

What Next ?

While there doesn't appear to be any applications like this on Code Project, there are nifty punch clock apps one can download for the smart phone as well as regular desktop apps, but I don't necessarily have my phone next to me all the time.  That said, there are a few features that are definitely needed:

  • Reports and charts of daily / weekly / monthly activity
  • Summary reports over a period of time for billing purposes
  • Merging data with other devices - for example, if I am working on my laptop on the train, I want to merge that information with the desktop app. based data?

So, it's a start, we'll see where it goes.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Marc Clifton
United States United States
Marc is the creator of two open source projects, MyXaml, a declarative (XML) instantiation engine and the Advanced Unit Testing framework, and Interacx, a commercial n-tier RAD application suite.  Visit his website,, where you will find many of his articles and his blog.

Marc lives in Philmont, NY.

You may also be interested in...

Comments and Discussions

Questionsmall codechange, big result Pin
MrDebug6522-Dec-12 21:20
memberMrDebug6522-Dec-12 21:20 
AnswerRe: small codechange, big result Pin
Marc Clifton27-Dec-12 3:12
protectorMarc Clifton27-Dec-12 3:12 
BugProcessing the hours Pin
Franz Babener19-Dec-12 23:53
memberFranz Babener19-Dec-12 23:53 
GeneralRe: Processing the hours Pin
Marc Clifton27-Dec-12 3:13
protectorMarc Clifton27-Dec-12 3:13 
Franz Babener wrote:
For me I fixed that changing the line to

Thanks for finding that!


General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170813.1 | Last Updated 15 Dec 2012
Article Copyright 2012 by Marc Clifton
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid