

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.

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

- 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.

After this you have it in the list of simulator. Now you are ready to
communicate with the weather gadget.
- 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, m_sGadgetId, ScfSideShowGadget.ScfEndpointId, m_sGadgetFriendlyName, null, null, false, GadgetCachePolicies.KeepNewest, null);
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.
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
Dr.Luiji
Software Developer (Senior)
imagicle s.p.a.
Italy
Member
|
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, especially of Windows Vista/7, Windows Mobile and Windows Embedded.
I love challenges.
Skills:
- Language: C++ (VC6, VC8, VC9), C#, Java
- Platform: Windows (Win98, WinNT, Win2000, WinXP, Win2003, Vista, 7, Mobile, CE), .NET (.NET 2.0, .NET 3.0), .NETCF, .NET Micro, Android
- Technology: Win32, Visual Studio (VS2005, VS2010), MFC, COM, ADO, WinForms, WebForms, XML, CSS, MySql, Skype (API), WinAmp (API), CNG, Sidebar, Sideshow, gSOAP & Web Services, NSIS, OpenSSL, Tapi v2-3, Socket, Zlib, E-mail & SMTP, Crystal Reports, XML, HTML, Threads, Shell programming, FTP, TFTP, Registry, Alarm, NT Service, MailSlot, Splitter, Crypto++, id3lib, ResizableLib, etc.
I currently work and live in Italy.
Music I listen to: Slipknot, Dope, Tool, NIN, Korn, Dry Kill Logic, Godsmack, System of a Down, White Zombie, Pantera, Soil, RA, Mushroomhead, Slayer, Oteph, Therion, Machine head, Disturbed, Lamb of God, Type O Negative, and more.
|