Click here to Skip to main content
6,306,412 members and growing! (23,755 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Applications     Intermediate

Weather Info

By CUShane

Weather Info uses web services on the .NET Compact Framework to display weather information on the Pocket PC.
C#, Windows, .NET CF, .NET, PocketPC 2002VS.NET2003, Dev
Posted:27 May 2004
Views:41,901
Bookmarked:22 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
10 votes for this article.
Popularity: 2.55 Rating: 2.55 out of 5
3 votes, 30.0%
1
2 votes, 20.0%
2
2 votes, 20.0%
3
2 votes, 20.0%
4
1 vote, 10.0%
5

Sample Image - weatherinfo.gif

Introduction

Weather Info came about because another weather program I had been using time bombed and the developer had disappeared. I sought out to learn about using web services on the .NET Compact Framework and ended up coming up with what I think is a very useful application for my first.

Implementation

This project contains a series of classes to implement the web service calls and the caching of data for offline use. WeatherInfoMain.cs contains all of the main code to implement the user interface. WeatherItem.cs contains the information for storing and serializing a web service response. WeatherCache.cs provides the mechanism for caching and retrieving WeatherItems, and Registry.cs contains the code for manipulating the Pocket PC registry.

Web Service Setup

Weather Info uses the weather data provided by EJSE. (Sorry to the non-US users, but this service only supports the United States.) I was actually pleasantly surprised at how simple it was to set up the web service request and to retrieve data from the service. One note: proxy configurations on the Pocket PC are problematic at best, so the application does not support the use of a proxy.

Pocket PC Registry

The application uses PInvoke to call the native Pocket PC registry handlers. I used the registry to store the ZIP code that the web service uses to retrieve the weather info.

Scrolling Forms

The other big challenge I faced in the application was developing a scrolling mechanism for when the user displayed the soft input panel and for the extended forecast. When the soft input panel is displayed, the viewable area shrinks by whatever the size of the selected input method is. To handle this, I developed all of the data as a series of panels and then dropped the panels into the main tab control. The scroll bars are displayed as necessary to allow the user to view the entire contents of the panel.

/// <summary>

/// Handles setting scroll bars and viewable areas

/// when the soft input panel is enabled or disabled

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void inputPanel1_EnabledChanged(object sender, System.EventArgs e)
{
    if(this.inputPanel1.Enabled)
    {
        //subtract SIP height from tab control height

        this.tabControl1.Height= 
          this.ClientRectangle.Height - this.inputPanel1.Bounds.Height;
        this.vScrollBarCurrent.Visible=true;
        this.vScrollBarAbout.Visible=true;
        this.panelAbout.Left=-(this.vScrollBarAbout.Width/2);
    }
    else
    {
        this.tabControl1.Height=this.ClientRectangle.Height;
        this.panelCurrent.Top=0;
        this.vScrollBarCurrent.Value=0;
        this.vScrollBarCurrent.Visible=false;
        this.panelAbout.Top=0;
        this.panelAbout.Left=0;
        this.vScrollBarAbout.Value=0;
        this.vScrollBarAbout.Visible=false;
    }
    int iCurrent=this.panelCurrent.Height-this.tabCurrent.Height;
    this.vScrollBarCurrent.Maximum=iCurrent+((iCurrent/10)/2);
    this.vScrollBarCurrent.LargeChange=iCurrent/10;
    this.vScrollBarCurrent.Height=this.tabCurrent.Height;
    int iExtended=this.panelExtended.Height-this.tabExtended.Height;
    this.vScrollBarExtended.Maximum=iExtended+((iExtended/10)/2);
    this.vScrollBarExtended.LargeChange=iExtended/10;
    this.vScrollBarExtended.Height=this.tabExtended.Height;
    int iAbout=this.panelAbout.Height-this.tabAbout.Height;
    this.vScrollBarAbout.Maximum=iAbout+((iAbout/10)/2);
    this.vScrollBarAbout.LargeChange=iAbout/10;
    this.vScrollBarAbout.Height=this.tabAbout.Height;
}

Required Libraries

Serialization support requires Compact Formatter.

Conclusion

I hope you enjoy using Weather Info. Updated versions can be found here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

CUShane


Member

Occupation: Software Developer (Senior)
Company: CNSI
Location: United States United States

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 11 of 11 (Total in Forum: 11) (Refresh)FirstPrevNext
GeneralHow to take zip code??? PinmemberMember 60874034:39 30 Apr '09  
GeneralHow to compile weather info. PinmemberMember 60874034:32 27 Apr '09  
AnswerRe: How to compile weather info. PinmemberCUShane5:45 27 Apr '09  
GeneralWeb Service Pinmemberscott_d10:33 17 Jun '05  
GeneralRe: Web Service PinmemberCUShane14:38 17 Jun '05  
GeneralRe: Web Service Pinmembersamsacheti1:57 6 Mar '07  
GeneralRe: Web Service PinmemberCUShane3:28 6 Mar '07  
GeneralRe: Web Service Pinmembersamsacheti7:01 6 Mar '07  
GeneralRe: Web Service PinmemberCUShane8:04 6 Mar '07  
GeneralBuild Error! Pinmemberjcynion21:31 24 Jun '04  
GeneralRe: Build Error! PinmemberCUShane4:13 28 Jun '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 May 2004
Editor: Smitha Vijayan
Copyright 2004 by CUShane
Everything else Copyright © CodeProject, 1999-2009
Web19 | Advertise on the Code Project