Creating Vista® Gadgets: Using HTML, CSS and JavaScript with Examples in RSS, Ajax, ActiveX COM and Silverlight™by Rajesh Lal Publisher: Sams Pub Date: May 05, 2008 Print ISBN-10: 0-672-
Trang 1Creating Vista® Gadgets: Using HTML, CSS and JavaScript with Examples in RSS, Ajax, ActiveX (COM) and Silverlight™
by Rajesh Lal
Publisher: Sams Pub Date: May 05, 2008 Print ISBN-10: 0-672-32968-9 Print ISBN-13: 978-0-672-32968-5 Pages: 360
Table of Contents | Index
Overview
A one-stop resource for each aspect of designing and
developing Sidebar gadgets, perfect for anyone who wants tocreate killer gadgets
Explores one of the super cool features new to WindowsVista the Sidebar
It is a one-stop resource for each aspect of designing anddeveloping Sidebar gadgets, perfect for anyone who wants
to create killer gadgets
seen gadgets
Includes complete design instructions for four never-before-Windows Vista Sidebar is a panel located on the desktop of a PCwhere gadgets can be placed for easy access and reference.These gadgets are small, single-purpose applications, such asclocks, calendars, games, RSS notifiers, search tools, stock
tickers, etc, that reside on the Windows desktop and on theWindows Sidebar The book will be a tutorial to design and
develop a gadget It will provide ready-to-use samples using.NET, XML, CSS and AJAX After reading the book, a web
developer/designer will be confident enough to start developing
Trang 2useful Gadget sample "My Blogs" " Elaborate the architecturedesign constraint and implementation details for the sample "Detail the standard practices " Recheck the gadget created forstandard practices " Improvise and Improve with compare andcontrast " Add advanced samples with NET, AJAX and XHTML
Trang 3Creating Vista® Gadgets: Using HTML, CSS and JavaScript with Examples in RSS, Ajax, ActiveX (COM) and Silverlight™
by Rajesh Lal
Publisher: Sams
Pub Date: May 05, 2008
Print ISBN-10: 0-672-32968-9 Print ISBN-13: 978-0-672-32968-5 Pages: 360
Trang 4The Goal
Trang 5Design Considerations
Developing the Gadget
Chapter 10 Most Recent Used NET Projects—An ApplicationGadget
Trang 6Index
Trang 8Printed in the United States of AmericaFirst Printing April 2008
Trang 9trademarks or service marks have been appropriately
capitalized Sams Publishing cannot attest to the accuracy ofthis information Use of a term in this book should not be
regarded as affecting the validity of any trademark or servicemark
Warning and Disclaimer
Every effort has been made to make this book as complete and
as accurate as possible, but no warranty or fitness is implied.The information provided is on an "as is" basis The author andthe publisher shall have neither liability nor responsibility to anyperson or entity with respect to any loss or damages arisingfrom the information contained in this book
Bulk Sales
Sams Publishing offers excellent discounts on this book whenordered in quantity for bulk purchases or special sales For
Trang 10computer science and holds MCSD and MCAD titles
To read his Vista Gadget blog, go to
www.innovatewithgadgets.com
Trang 11Writing is a fascinating journey I would like to extend my
special thanks to Marc Clifton Todd Brakke, and Margo Cattswho were along with me on this journey They corrected,
annotated, criticized, and helped me at every step Thanks also
to Joshua Heyer (Shog9) and Rama Krishna for reviewing thisbook and for their invaluable advice I also want to add a note
of thanks to Dr Luiji for all the encouragement at the timeswhen I needed it
I am deeply grateful to Loretta Yates, acquisitions editor at
Sams/Que Publishing for her unmatched dedication to qualityand progressiveness, without which this book was never
possible Thanks also to Jennifer Gallant, Cindy Teeters, andRosemary Lewis from Pearson Technology Group
I would like to extend my appreciation to the folks from
Microsoft, for their time and effort to make this book complete
in every sense, especially Brian Teutsch, Daniel Moth, and
Annuska Perkins I would also like to thank Rick Kingslan, KarenWong, and Mark Schmidt
Last of all, I would like to mention my brothers Rakesh and
Rajeev, for all the wonderful things I have learned from them,and Simple and Shilpi for just being so wonderful And my
inspiration and my driving force Neelu
Trang 12As the reader of this book, you are our most important critic
and commentator We value your opinion and want to know
what we're doing right, what we could do better, what areasyou'd like to see us publish in, and any other words of wisdomyou're willing to pass our way
When you write, please be sure to include this book's title andauthor as well as your name and phone or email address I willcarefully review your comments and share them with the authorand editors who worked on the book
Trang 13Visit our website and register this book at informit.com/registerfor convenient access to any updates, downloads, or errata thatmight be available for this book
Trang 14With the broadest ever worldwide release of a PC operating
system, in 2007 Windows Vista opened the door to an era ofgadget development Gadgets, which reside on the WindowsVista Sidebar, are small, lightweight, and can be very usefulapplications The Sidebar is a brand new platform for innovationand it gives users a unique way to interact with information.This book is for people who want to create feature-rich and
professional-looking Vista Sidebar gadgets It's a guide for
designers, developers, and anyone else who has a basic
knowledge of HTML, CSS, and JavaScript and wants to leveragethis new and innovative platform It's for anyone who wants tocreate a gadget for his company, or for a programmer with agreat idea to implement on a Sidebar gadget platform, or evenfor a hobbyist programmer, who wants to try his hand on a
gadget platform This book is intended to give you ideas for
what you can do with this new platform and how you can do it.
What's in the Book
This book starts with a brief background on gadgets, and thengives a broad and clear view of the architecture of gadget
development Gadget design considerations are an importantpart of this book and they go side by side with almost all thechapters that deal with gadget development Once you've read
up on the concept and scope of gadget development, the bookhelps you create a gadget called MyBlog During this processthe text elaborates on the architecture, design constraints, andimplementation details for the gadget and then details somestandard practices applicable to all gadget development Thelast section deals with more advanced gadget examples thatutilize NET, XML, XHTML, CSS, Ajax, and Microsoft Silverlight.This book is divided into three broad sections
Section 1: The Foundation
Trang 15background of Sidebar gadgets The section explains the types
of gadgets, the architecture, and the technology behind the
gadget development The "Approach to Design" chapter helpsyou know the difference between a merely good-looking gadgetand a one that is professional, rich, and worth the space it
takes up on the user's desktop The last chapter discusses therevenue model of the gadget: what you need to know to sellyour gadgets
Section 2: Developing a Gadget
This section walks you through the standard development
process of a gadget It details the creation of the basic MyBlogGadget, which makes use of an RSS/Atom feed It also goesthrough best practices with the user interface, design
guidelines, and common assumptions The later chapters
improve on the basic gadget based on standard practices andalso deal with deploying and distributing a gadget
Section 3: Advanced Samples
The section deals with advanced samples You will be able tocreate advanced gadgets such as a Site Statistics Gadget, aRadio Gadget, and a YouTube Video Gadget All the samplesfollow standard patterns, making it easier to switch between thefeatures and functionality you want, when you want You willalso learn how to use ActiveX COM for creating a utility gadgetwith a sample Net Most Recent Used (MRU) Gadget The finalchapter shows you how to create a gadget with Microsoft
Silverlight You will also see how, in just a few minutes, to
create a Sidebar gadget with Microsoft Popfly
If you are a relatively new gadget developer, I would suggestyou to start with the first section If you have basic backgroundknowledge of gadgets and you just want to start with the step-by-step practical approach to gadget development, you can
directly start with the second section, "Developing a Gadget."The third section, "Advanced Samples," is for people who have
Trang 16developed a gadget and want to go beyond the basics of gadgetdevelopment Each chapter in the third section is actually anadvanced sample dealing with a particular type of gadget in ascenario of its own.
Trang 17With the broadest ever worldwide release of a PC operating
system, in 2007 Windows Vista opened the door to an era ofgadget development Gadgets, which reside on the WindowsVista Sidebar, are small, lightweight, and can be very usefulapplications The Sidebar is a brand new platform for innovationand it gives users a unique way to interact with information.This book is for people who want to create feature-rich and
professional-looking Vista Sidebar gadgets It's a guide for
designers, developers, and anyone else who has a basic
knowledge of HTML, CSS, and JavaScript and wants to leveragethis new and innovative platform It's for anyone who wants tocreate a gadget for his company, or for a programmer with agreat idea to implement on a Sidebar gadget platform, or evenfor a hobbyist programmer, who wants to try his hand on a
gadget platform This book is intended to give you ideas for
what you can do with this new platform and how you can do it.
What's in the Book
This book starts with a brief background on gadgets, and thengives a broad and clear view of the architecture of gadget
development Gadget design considerations are an importantpart of this book and they go side by side with almost all thechapters that deal with gadget development Once you've read
up on the concept and scope of gadget development, the bookhelps you create a gadget called MyBlog During this processthe text elaborates on the architecture, design constraints, andimplementation details for the gadget and then details somestandard practices applicable to all gadget development Thelast section deals with more advanced gadget examples thatutilize NET, XML, XHTML, CSS, Ajax, and Microsoft Silverlight.This book is divided into three broad sections
Section 1: The Foundation
Trang 18background of Sidebar gadgets The section explains the types
of gadgets, the architecture, and the technology behind the
gadget development The "Approach to Design" chapter helpsyou know the difference between a merely good-looking gadgetand a one that is professional, rich, and worth the space it
takes up on the user's desktop The last chapter discusses therevenue model of the gadget: what you need to know to sellyour gadgets
Section 2: Developing a Gadget
This section walks you through the standard development
process of a gadget It details the creation of the basic MyBlogGadget, which makes use of an RSS/Atom feed It also goesthrough best practices with the user interface, design
guidelines, and common assumptions The later chapters
improve on the basic gadget based on standard practices andalso deal with deploying and distributing a gadget
Section 3: Advanced Samples
The section deals with advanced samples You will be able tocreate advanced gadgets such as a Site Statistics Gadget, aRadio Gadget, and a YouTube Video Gadget All the samplesfollow standard patterns, making it easier to switch between thefeatures and functionality you want, when you want You willalso learn how to use ActiveX COM for creating a utility gadgetwith a sample Net Most Recent Used (MRU) Gadget The finalchapter shows you how to create a gadget with Microsoft
Silverlight You will also see how, in just a few minutes, to
create a Sidebar gadget with Microsoft Popfly
If you are a relatively new gadget developer, I would suggestyou to start with the first section If you have basic backgroundknowledge of gadgets and you just want to start with the step-by-step practical approach to gadget development, you can
directly start with the second section, "Developing a Gadget."The third section, "Advanced Samples," is for people who have
Trang 19developed a gadget and want to go beyond the basics of gadgetdevelopment Each chapter in the third section is actually anadvanced sample dealing with a particular type of gadget in ascenario of its own.
Trang 20This book is meant to be a definite, precise, and concrete guidefor gadget development By pruning redundant information andfiltering and highlighting the information that is more crucial,
we have tried to make it as comprehensive as possible Thisbook includes various features and conventions that help youget the most out of the book
Trang 21The book also uses the following boxes for importantinformation:
Note
A Note includes extra information to broaden yourunderstanding of a topic
Tip
A Tip provides alternative, shortcuts, or insiderinformation of the topic being discussed
Caution
A Caution warns you of potential traps and pitfalls
Trang 22The book has a supporting website where you can download allthe codes and gadgets The website also has blogs I have
written on Sidebar gadgets and some of my personal views ongadget development You are invited to check that site andcontact me personally You will also find errata and most
updated information there
Visit www.innovatewithgadgets.com
Trang 23In This Part
CHAPTER 1 Innovate with Windows VistaSidebar Gadgets
Trang 24Chapter 1 Innovate with Windows Vista Sidebar Gadgets
Gadgets offer a diverse range of functionality, from giving you
an at-a-glance view of your upcoming appointments, to listingonline contacts, to displaying a picture slideshow of your Flickraccount, to offering an easy way to control your media player.Gadgets can have any number of dedicated purposes As shown
in Figure 1.1, they can be clocks, calculators, games, stickynotes, and more
Figure 1.1 Gadgets can be placed anywhere on the Vista desktop, but most are organized on the Windows
Sidebar.
Trang 25The Windows Sidebar is a pane on the side of the Microsoft
Windows Vista desktop and is used to place and organize thegadgets You can easily customize the Windows Sidebar to suityour preference: always on top or resting below maximized
windows If you don't want to keep your gadgets on the
Windows Sidebar, you can drag them to your desktop and hidethe Sidebar The Windows Sidebar can also be activated fromthe icon in the system tray
Gadgets can have multiple instances, both in the Sidebar aswell as on the Windows desktop, and these can be configuredwith different settings For example, you can have two
instances of a Clock Gadget, one showing the current time forSan Diego, California and the other one for Paris, France
A Vista Sidebar gadget consists of HTML, CSS, JavaScript, andimage files, all coordinated to accomplish a variety of tasks Youcan host a mini web page, call a web service, integrate with abusiness application, or even call operating system APIs to
create a custom application
Technology Behind Gadgets
Gadgets are developed using standard web technologies,
namely HTML, CSS, and JavaScript, but they can also use
Trang 26advanced functionalities A gadget can be thought of as anHTML Application (HTA) with advanced features and properties.All the interfaces used in the gadget, the gadget main window,the settings page, as well as the flyout window, all are HTMLpages
A gadget can also use advanced plug-ins such as Adobe Flash,Windows Media Player, and Microsoft Silverlight Anything thatcan be hosted in a web page can be used in gadget
development
Figure 1.2 gives an overview of the technology and relatedplatforms used for gadget development Most of the
technologies overlap in a number of applications
Figure 1.2 Different types of applications require different technologies in gadget development.
[View full size image]
In the next section we discuss these technologies in more
detail
Trang 27aggregate data are quite popular nowadays because of theinteroperability advantage an XML file provides XML data isavailable all over the Internet in the form of RSS/atom
frquently accessed tools and features —Quick
information and shortcuts to frequently used features, tools,and applications are also among the attractive options fordeveloping gadgets You can use gadget APIs to developutilities, which exposes system functionalities such as
hardware information, files and folders, network, memory,CPU, and so on
Brief History of Gadgets
Windows XP includes a feature called Active Desktop, which
provides the functionality of hosting web pages and channelsbuilt with Microsoft's Channel Definition Format (CDF) on thedesktop This is significant because it provides some of the
features now found in desktop gadgets Vista Sidebar gadgetsare the logical evolution from Active Desktop
Note
Trang 28Need for lightweight applications
New dashboard-style presentation of data, which permitsaccess to a variety of different data sources and formats
Sidebar gadget technology is much more structured than ActiveDesktop and follows an extensible model It comes with a fullset of APIs to support rich and powerful applications
Trang 29In This Part
CHAPTER 1 Innovate with Windows VistaSidebar Gadgets
Trang 30Chapter 1 Innovate with Windows Vista Sidebar Gadgets
Gadgets offer a diverse range of functionality, from giving you
an at-a-glance view of your upcoming appointments, to listingonline contacts, to displaying a picture slideshow of your Flickraccount, to offering an easy way to control your media player.Gadgets can have any number of dedicated purposes As shown
in Figure 1.1, they can be clocks, calculators, games, stickynotes, and more
Figure 1.1 Gadgets can be placed anywhere on the Vista desktop, but most are organized on the Windows
Sidebar.
Trang 31The Windows Sidebar is a pane on the side of the Microsoft
Windows Vista desktop and is used to place and organize thegadgets You can easily customize the Windows Sidebar to suityour preference: always on top or resting below maximized
windows If you don't want to keep your gadgets on the
Windows Sidebar, you can drag them to your desktop and hidethe Sidebar The Windows Sidebar can also be activated fromthe icon in the system tray
Gadgets can have multiple instances, both in the Sidebar aswell as on the Windows desktop, and these can be configuredwith different settings For example, you can have two
instances of a Clock Gadget, one showing the current time forSan Diego, California and the other one for Paris, France
A Vista Sidebar gadget consists of HTML, CSS, JavaScript, andimage files, all coordinated to accomplish a variety of tasks Youcan host a mini web page, call a web service, integrate with abusiness application, or even call operating system APIs to
create a custom application
Technology Behind Gadgets
Gadgets are developed using standard web technologies,
namely HTML, CSS, and JavaScript, but they can also use
Trang 32advanced functionalities A gadget can be thought of as anHTML Application (HTA) with advanced features and properties.All the interfaces used in the gadget, the gadget main window,the settings page, as well as the flyout window, all are HTMLpages
A gadget can also use advanced plug-ins such as Adobe Flash,Windows Media Player, and Microsoft Silverlight Anything thatcan be hosted in a web page can be used in gadget
development
Figure 1.2 gives an overview of the technology and relatedplatforms used for gadget development Most of the
technologies overlap in a number of applications
Figure 1.2 Different types of applications require different technologies in gadget development.
[View full size image]
In the next section we discuss these technologies in more
detail
Trang 33aggregate data are quite popular nowadays because of theinteroperability advantage an XML file provides XML data isavailable all over the Internet in the form of RSS/atom
frquently accessed tools and features —Quick
information and shortcuts to frequently used features, tools,and applications are also among the attractive options fordeveloping gadgets You can use gadget APIs to developutilities, which exposes system functionalities such as
hardware information, files and folders, network, memory,CPU, and so on
Brief History of Gadgets
Windows XP includes a feature called Active Desktop, which
provides the functionality of hosting web pages and channelsbuilt with Microsoft's Channel Definition Format (CDF) on thedesktop This is significant because it provides some of the
features now found in desktop gadgets Vista Sidebar gadgetsare the logical evolution from Active Desktop
Note
Trang 34Need for lightweight applications
New dashboard-style presentation of data, which permitsaccess to a variety of different data sources and formats
Sidebar gadget technology is much more structured than ActiveDesktop and follows an extensible model It comes with a fullset of APIs to support rich and powerful applications
Trang 35In This Part
CHAPTER 1 Innovate with Windows VistaSidebar Gadgets
Trang 36Chapter 1 Innovate with Windows Vista Sidebar Gadgets
Gadgets offer a diverse range of functionality, from giving you
an at-a-glance view of your upcoming appointments, to listingonline contacts, to displaying a picture slideshow of your Flickraccount, to offering an easy way to control your media player.Gadgets can have any number of dedicated purposes As shown
in Figure 1.1, they can be clocks, calculators, games, stickynotes, and more
Figure 1.1 Gadgets can be placed anywhere on the Vista desktop, but most are organized on the Windows
Sidebar.
Trang 37The Windows Sidebar is a pane on the side of the Microsoft
Windows Vista desktop and is used to place and organize thegadgets You can easily customize the Windows Sidebar to suityour preference: always on top or resting below maximized
windows If you don't want to keep your gadgets on the
Windows Sidebar, you can drag them to your desktop and hidethe Sidebar The Windows Sidebar can also be activated fromthe icon in the system tray
Gadgets can have multiple instances, both in the Sidebar aswell as on the Windows desktop, and these can be configuredwith different settings For example, you can have two
instances of a Clock Gadget, one showing the current time forSan Diego, California and the other one for Paris, France
A Vista Sidebar gadget consists of HTML, CSS, JavaScript, andimage files, all coordinated to accomplish a variety of tasks Youcan host a mini web page, call a web service, integrate with abusiness application, or even call operating system APIs to
create a custom application
Technology Behind Gadgets
Gadgets are developed using standard web technologies,
namely HTML, CSS, and JavaScript, but they can also use
Trang 38advanced functionalities A gadget can be thought of as anHTML Application (HTA) with advanced features and properties.All the interfaces used in the gadget, the gadget main window,the settings page, as well as the flyout window, all are HTMLpages
A gadget can also use advanced plug-ins such as Adobe Flash,Windows Media Player, and Microsoft Silverlight Anything thatcan be hosted in a web page can be used in gadget
development
Figure 1.2 gives an overview of the technology and relatedplatforms used for gadget development Most of the
technologies overlap in a number of applications
Figure 1.2 Different types of applications require different technologies in gadget development.
[View full size image]
In the next section we discuss these technologies in more
detail
Trang 39aggregate data are quite popular nowadays because of theinteroperability advantage an XML file provides XML data isavailable all over the Internet in the form of RSS/atom
frquently accessed tools and features —Quick
information and shortcuts to frequently used features, tools,and applications are also among the attractive options fordeveloping gadgets You can use gadget APIs to developutilities, which exposes system functionalities such as
hardware information, files and folders, network, memory,CPU, and so on
Brief History of Gadgets
Windows XP includes a feature called Active Desktop, which
provides the functionality of hosting web pages and channelsbuilt with Microsoft's Channel Definition Format (CDF) on thedesktop This is significant because it provides some of the
features now found in desktop gadgets Vista Sidebar gadgetsare the logical evolution from Active Desktop
Note
Trang 40Need for lightweight applications
New dashboard-style presentation of data, which permitsaccess to a variety of different data sources and formats
Sidebar gadget technology is much more structured than ActiveDesktop and follows an extensible model It comes with a fullset of APIs to support rich and powerful applications