Why do we need a new calendar application?
Have you ever wished you could change a national holiday but were too lazy to run for president? Well, here's just the thing. This class is easy to use in any .NET environment written in VB2008, and provides your applications with a handy no fuss calendar which will show you today's date when you launch it and allows the user to select any of three view modes, for any year or month. You've probably seen a dozen of these and may not be impressed. OK, so it is a simple application, and I won't crow about it, but it is also a handy day-book that can be programmed to remind you of whatever it is you have to do that day for any day of any year. Think you might forget your Aunt Selma's wedding anniversary after she sent you that $10 in the mail over the winter holidays? Or your wife won't forgive you if you forget hers? Maybe you've got bills to pay, a junior soccer car-pool which you volunteered for, or if you simply don't want to miss the episode of the Gilmore Girls where Rory hosts her first DAR function because you have to see her one more time in her 1940's USO uniform! Well, now you can stop worrying and schedule it in your agenda. Simply click on the day, write down the time and leave yourself a message, and this application will remind you.
You don't care? Alright, well, here's something that might interest you. You can program your kid's soccer schedule on it. Create a 'new Schedule', call it 'Marsha's Soccer', add every date into your new schedule, and this application will highlight the dates on your calendar. And! If you're so inclined, you can make the 5th of July 'Hangover Day' so that you can invite the in-laws for a bit of the Hair of the Dog.
Using the Code
As promised, this application is easy to use. You'll need to instantiate the class and then put the
Panel that holds the calendar) on your form or wherever you want it. All of the code that you need to run is in the button event handler of cLibTestAgenda, which I show here:
Private Sub btnShowCalendar_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnShowCalendar.Click
Dim formCalendar As Form = New Form()
cLibCalendar = New classCalendar(mainroot)
cLibCalendar.myForm = formCalendar
formCalendar.Top = 10
formCalendar.Left = 10
formCalendar.Visible = True
You don't have to set the variable
cLibCalendar.myForm equal to the form just instantiated, but by doing so, you're telling your calendar to resize the form whenever the display mode changes. In this example, the panel
MyPnl is added to the form and then resized. You can call
resizeForm() whenever you want, but only really need to do it here because if you don't, most of the calendar dates won't be visible. Aside from that, there's really only the
cLibCalendar.PopUpReminder() call which needs explaining, and is optional. What this does is it pops up that day's agenda if there is one. So, if your user has something scheduled for that day, then the entire day's agenda will appear when this call is made. Simple enough?
There's no user's handbook, but you'll find that it is easy enough to use.
This screen capture shows you the year 2009. You'll first notice that the 3rd of May is highlighted, and you'll also note that this date corresponds to the date selected above (year, month, day). Shown on the left are the two menu items, Holiday Editor and Selected Schedules. The Selected Schedules option toggles your view of the listbox which allows you to select which schedules you want to use, e.g., American Holidays, Canadian Holidays, Marsha's Soccer Schedule, or I Wish These Were Real Holidays, holiday schedules.
The Schedule Editor which you can see in the top image above gives you the option to create a new schedule of holidays or edit an existing one by adding, changing, or deleting marked days on that schedule. The checkbox 'Static date' lets you choose between setting a specific date like Aunt Selma's anniversary or your wife's birthday, or you can set a non-static date like 'the third Monday in July' or 'the last Wednesday in November', and so forth. Just be sure to save your changes, and you'll see it works pretty good and is all pretty much user-friendly.
All the schedules which you have selected will appear highlighted in red on your calendar. If you view the calendar in display-month mode, those dates will not only appear in red but the actual holidays' names will also be written on those dates. Letting your mouse cursor hover over one of these dates will popup a label telling you what's so special about those dates, and clicking any calendar date will bring forward your agenda for that day.
The agenda can act as an alarm too. So, if you want to remind yourself on Tuesday March 17th to call your mother at 11h30 because she forgot your date of birth, then you click on that date on the calendar and your agenda for that day will appear. It'll be blank at first, so you'll have to write in what you want: "11h30 Call mom because she forgot my date of birth". The application will open the agenda, unscramble it, then reorder all the alarms, check every minute of that day to see if it is time to tell you, and then at 11h30, it will warn you with the message "Call mom because she forgot my date of birth".
The program sorts the alarms as follows:
- It looks for the letter 'h' and determines if this is a time unit, e.g., 11h30 or 13h (24 hour time).
- Finds the next 'newline' character, and puts the text after the time and before the next newline into the same structure element as the time.
- Sorts all these chronologically so you don't have to write them in any specific order.
- Deletes all those that precede the current time.
- Tests the next one with the current time, and warns you when these times are the same.
This scheme has its drawbacks, but it is quick to use and was easy to code. Just don't write something like "11h30 remember to meet Marsha at the soccer field at 12h" because then, it'll set another alarm at 11h30 and a second time 12h for no good reason. I may get around to writing the whole thing with programmable process launches so that the user can say "run myInternetRadio" or "play soundbyte 'Get up.mp3'" and have it all work in a way similar to the way HTML works or some other idea, but for now, this is what I've got, and you're welcome to do whatever you like to it.