Click here to Skip to main content
Click here to Skip to main content

Weather Sideshow

, 28 Mar 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
A SideShow application that communicates with a Weather webservice.

SideShowLogo Image

WeatherSideShow Image

Contents

Introduction

This article explains the power of a new Vista feature, the SideShow. The goal of this article is to use the Sideshow, with as few steps as possible. To demonstrate this, I will get data from a web service. After this article you can use the Gadget Class to retrieve data either from your database or from your program or from the systems, whatever you prefer.

When I developed the article, the framework was in beta.

The environment I used to test it:

  • Windows Vista 5384 (Beta2) Eng.
  • Windows Vista 5600 Eng.
  • Windows Vista Business Ita.

At the end of this document, there are some links that will help you with installing the Microsoft VirtualSideShow.

Background

The Microsoft Windows SideShow Platform is a new feature developed for Microsoft Windows Vista that enables developers to create new applications and extend existing ones specifically for devices with small displays and limited interaction models. Applications designed to work with the platform are referred to as gadgets. The devices supported by the platform include, but are not limited to: displays attached to a laptop, front panel computer displays, displays embedded in keyboards, cell phones, digital picture frames, and other display devices.

Driver and simulator

To compile the code, you must install the SideShow SDK Beta, which is currently available from Microsoft here.

To run the binary you need to obtain two files, a driver and an emulator, which shipped with the Vista SDK.

After installation, you will find the emulator driver (WindowsSideShowVirtualDevice.exe) and emulator (VirtualSideShow.exe) in the 'C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin' directory.

Execute windowsSideShowvirtualdevice.exe /regserver first and VirtualSideShow.exe right after.

In the Control Panel, open Windows SideShow, now you can see the Simulator installed as shown in the picture after.

 Control Panel- Windows SideShow Image

The VirtualSideShow.exe has only the default item.

 VirtualSideShow - Delault Image

When you use my demo and click register, it adds a new item to the list. Then you can run the demo program WeatherSideShow.exe, contained in the demo download.

Info: Note that to see the sample run on the SideShow you must have VirtualSideShow.exe open.

Using the VirtualSideShow

Several options are offered:

 Keypad VirtualSideShow Image

  • the arrow keys to navigate the menu
  • the OK button to enter the gadget and it's menu
  • the backspace to go back

Launching and registering WeatherSideShow.exe adds a new item on VirtualSideShow called 'Weather SideShow Gadget'.

The inside menu shows a menu with two items, the first is the data received from WS, the second is the data stored in the application.

Using the binary

First of all you must have VirtualSideShow.exe opened as described above.

  • Open my application.
  • In the app: Register the gadget with the Register button.
  • In Vista: Now if all is well, you can activate the gadget from the SideShow menu in the control panel.  Keypad VirtualSideShow Image
  • After this you have it in the list of simulator. Now you are ready to communicate with the weather gadget.

     Keypad VirtualSideShow Image
  • In the app: You must use the button 'Get Country' to add the country and city using the web services to combobox. It may take a minute depending on your connection speed.
  • Then you can select the country and city you like and see if the data for the selected item is available.

If you want you can use the timer to refresh automatically and save all selected data.

The SideShow is refreshed every time the 'auto timer' starts and every time you click 'Check weather of saved data'.

Using the code

I have created this project as a C# windows application.

With this application you can retrieve all the cities and countries from the web services I used. Select one and test if your city has weather data.

If you like, you can set a timer to refresh the app and the SideShow automatically.

You can save your data and use it in the next session.

The code follows these ideas:

  • MySideShowGadget: a class that communicates with SideShow.
  • the registry to save and store data.
  • A class for the global weather webservice, and an XML parser to 'translate' data to SideShow.
  • A class (GadgetRegistration) to register and unregister the gadget.
  • A class (Scf) to download data to the virtual device.
  • A timer for automatic refresh.

Here I describe only the calls I used for the SideShow.

Info: I used a free webservice from WebserviceX.NET. If the server is busy and you get the error, "service unavailable", you can see if it's working here.

All the necessary code for the SideShow is in MySideShowGadget. All other classes are used for retriving data and manipulating it.

I used a Guid m_sGadgetId for registering and unregistering the gadget and more important to create ScfSideShowGadget.

MySideShowGadget uses the ScfSideShowGadget Class to add data into the SideShow pages. I added some methods but the most important are:

  • Register:

    To register the gadget I used the class GadgetRegistration as described below, with comments. With the GadgetRegistration.Register, the new gadget is added to the SideShow list.

    GadgetRegistration.Register(
    false,                                    //Only for this account
    m_sGadgetId,                              //GUID
    ScfSideShowGadget.ScfEndpointId,          //EndPoint
    m_sGadgetFriendlyName,                    //Name to Display
    null,                                     //command to start
    null,                                     //the ico
    false,                                    //online info
    GadgetCachePolicies.KeepNewest,           //the Cache policy
    null);                                    //the property page
    
  • Unregister:

    To unregister the gadget. Deletes the gadget from the SideShow list.

    GadgetRegistration.Unregister(false, m_sGadgetId);
    
  • DefaultContent:

    To display text at a glance. I used the method AddGlanceContent to add content. This method adds a string that can be displyed in the description of the gadget in the SideShow menu. I added "Updated on: {0:D}\n {0:T}", DateTime.Now"

    m_oScfSideShowGadget.AddGlanceContent("some text do display");
    
  • DownloadDataToDevice:

    The data stored into the application is copied to the SideShow. This method use AddGlanceContent and AddContent to add a page to SideShow display.

    m_oScfSideShowGadget.AddContent(MyXMLPage);
    

    AddContent adds/modifies a page to the content. This method requires an XML string. You can use a xml page directly or use the scf class. You must use it to add all the pages required for the SideShow. In my case, I used it four times.

    Add Body: This is the first use of Scf class. On first use, the scf requires the body be set with Scf.Body. This method takes as input the menu and items:

    sContentXml = Scf.Body(
                  Scf.Menu(1, "Weather gadget menu", ScfSelectAction.Target,
                  Scf.Item(2, "See Last weather of " + m_sCity + ", " + 
    
    m_sCountry),
                  Scf.Item(3, "See all the option")));
    

    Here you can see that I have added the body, one menu and two items inside the gadget.

    Add pages: the second time you use scf call Scf.Content method with the id that you have inserted in the body. In this example I've added a picture and more text:

    Scf.Content(
                2, "Weather of " + m_sCity + ", " + m_sCountry,
                Scf.Txt(ScfAlign.Left, true, Color.Black, m_lblWind + " " + 
    
    m_txtWind),
                Scf.Txt(ScfAlign.Left, true, Color.Black, m_lblVisibility + " " + 
    
    m_txtVisibility),
                Scf.Txt(ScfAlign.Left, true, Color.Black, m_lblSkyCondition + " " + 
    
    m_txtSkyConditions),
                Scf.Txt(ScfAlign.Left, true, Color.Black, m_lblTemperature + " " + 
    
    m_txtTemperature),
                Scf.Txt(ScfAlign.Left, true, Color.Black, m_lblHumidity + " " + 
    
    m_txtHumidity));
    

    Use this method to add all the pages.

This is the sample I share that copies data to SideShow.

WeatherSideShow Image

This is the result that you can see in your SideShow or VirtualSideShow.

Screenshot - WeatherSideShow2.GIF

That's all.

Points of Interest

I've yet to find code on the internet that runs like the author said. If you have problems in compiling or executing the project, please leave a post.

Microsoft help, installing VirtualSideShow:

MSDN help, Scf Members

History

  • 28 Mar 07 - Third release, article update
  • 14 Mar 07 - Second release, article update
  • 28 Jan 07 - First release

License

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

Share

About the Author

Dr.Luiji
Software Developer (Senior) Welcome Italia spa
Italy Italy
Bertoneri Luigi, alias Dr.Luiji
Bachelor of Science in Computer Science, year 2K - University of Pisa (Italy).
 
I'm a developer with more than 10 years of experience. I like the new technology, Windows, iOS and Android.
I love challenges.
 
Skills:
- Language: Android, Objective-C, C++, C#, Java
- Platform: Windows, .NET
- Technology: Too much...
 
I currently work and live in Italy.
Music I listen to: Tool, Slipknot, NIN, Korn, Perfect Circle, Dry Kill Logic, Godsmack, and more.
Follow on   Twitter

Comments and Discussions

 
GeneralExcelent PinmvpAbhijit Jana17-Jul-09 12:28 
GeneralRe: Excelent PinmemberDr.Luiji9-Oct-09 1:18 
GeneralGood Article! PinmemberNizZ82-Mar-08 13:06 
GeneralRe: Good Article! Pinmember Dr.Luiji 2-Mar-08 22:26 
GeneralGood article and gadget Pinmembermarcasselin1-May-07 3:31 
AnswerRe: Good article and gadget PinmemberDr.Luiji1-May-07 5:13 
GeneralDidn't work PinmemberJoeIsTheMan14-Mar-07 8:09 
QuestionRe: Didn't work PinmemberDr.Luiji14-Mar-07 10:01 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411022.1 | Last Updated 28 Mar 2007
Article Copyright 2007 by Dr.Luiji
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid