Figure 1 - Web Thermometer
The Web Thermometer uses the same method as the WhatIsTheWeather application, GetTemperatureAndCondition, to extract the temperature from a stream on the weather.com site. The thermometer shows the temperature in both Centigrade and Fahrenheit and handles a range from 0 to 212 degrees Fahrenheit. The zip code is hard coded into the application as 10001 (NY City), so you'll need to adjust this to obtain the temperature for your area. The temperature is updated every ten minutes with a built in timer. The weather condition and temperature is shown as an icon in the upper left hand corner so that when the thermometer is minimized you can see the temperature on the task bar.
The Web Thermometer uses GDI+ to draw its values. Below is the code for drawing the thermometer tube. This code draws two parallel lines and draws an arc at the top and bottom in order to create the tube. A set of tick marks are then drawn on either side of the thermometer. The left side shows centigrade and the right side shows Fahrenheit. The level is calculated from the temperature and painted as a filled rectangle between the two parallel lines.
Improvements
It probably wouldn't be a bad idea to allow entry of the zip code in a popup menu, and then make the zip code persistent. I was thinking it would also be nice to have a tool tip come up with a number based on the position of the mouse over the thermometer. Enjoy the weather!
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: