Since I talk with many people who aren't finnish, I've sometimes had some problems with their timezones and such. You know, sometimes it's useful to know what time it is somewhere else.You could of course just open up google and look up a page with the time for the place or change the windows timezone temporarily so the clock would show the correct time there... But that's kind of annoying and time consuming, so I came up with a solution: Display a second configurable clock in the system tray!
Problem
So what do we need? Only a little bit of C# code and a vision.I had this simple idea: Since an application can display an icon in the tray, why not just display two icons instead of one - Hours in the first icon, minutes in the second icon.All you need to do is generate some icons on the run for the numbers and make sure they show next to each other in the tray, in the correct order. A simple interface for changing the hour and minute offset would be useful too.
Solution
Solution
Creating an interface is easy in Visual Studio 2005. The icon generation and ordering in the tray was the only small challenge.I found out you can easily generate icons by creating a Bitmap on the run in the app. Just draw some numbers to it and use Icon.FromHandle(bitmap.GetHicon()).Getting the icons show up in the correct order was equally simple: You just need to toggle their visibility in the tray off and then back on again in the correct order.
Files
Files
As usual, here are both the source code and the executable file for the application. TrayClock executable (zip, 5kB)TrayClock source (zip, 13kB)When you start the program, you get the configuration screen where you can set the offset from current time. Add a - in the front for negative offset. After setting the time you can hide the configuration screen by clicking the minimize icon. To get back into the configuration, just doubleclick on either of the icons in the tray.I've tested the program and it runs fine for hours and hours - until the screensaver kicks in, which will cause the icons in the tray to disappear because of a GDIException which I was unable to solve... You just have to restart it after that or if you can fix it, let me know!