![]() |
Desktop Development »
Desktop Gadgets »
General
Intermediate
License: The Code Project Open License (CPOL)
Weather SideshowBy Dr.LuijiA SideShow application that communicates with a Weather webservice. |
C# 2.0, .NET, VistaVS2005, Dev
|
|
Advanced Search |
|
|
||||||||||||||||||


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:
At the end of this document, there are some links that will help you with installing the Microsoft VirtualSideShow.
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.
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.
The VirtualSideShow.exe has only the default item.

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.
Several options are offered:

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.
First of all you must have VirtualSideShow.exe opened as described above.

After this you have it in the list of simulator. Now you are ready to communicate with the weather gadget.
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'.
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. GadgetRegistration) to register and unregister the
gadget. Scf) to download data to the virtual device. 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.

This is the result that you can see in your SideShow or VirtualSideShow.
That's all.
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
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 Mar 2007 Editor: Sean Ewington |
Copyright 2007 by Dr.Luiji Everything else Copyright © CodeProject, 1999-2009 Web15 | Advertise on the Code Project |