TechnicalArchitectureWorx

The (Unofficial) ITWorx Technical Architecture Blog

  • a

Archive for November 5th, 2006

How to create a Vista Sidebar Gadget.

Posted by archworx on November 5, 2006

I was asked to create a quick POC (proof of concept) for a MS Windows Vista sidebar gadget. I did the usual Live.com search and discovered a few posts.

An interesting post was by a guy called Daniel Moth. It had lots of useful information, but unfortunately it just didn’t work for me. There seems to be something missing in the xml file accompanying the gadget, as well as some rubbish text in the file, so your gadget won’t work but you won’t get an error.

I found a more uptodate sample on MSDN. This was also on Daniel Moth’s blog, so many thanks to him.

Now here is my version of the hello world sidebar gadget.

Step 1:

Create the following HTML file:

<html>
<head>
 <title>Hello, World!</title>
 <style>
  body {
   width:130;
   height:50;
  }
 </style>
</head>
<body>
 <span id=”gadgetContent” style=”font-family: Tahoma; font-size: 10pt;”>Hello, World!</span>
</body>
</html>

Call it HelloWorld.html

Step 2:

Create the following XML file:

<?xml version=”1.0″ encoding=”utf-8″ ?>
<gadget>
    <name>Hello World!</name>
    <namespace>Example.You</namespace>
    <version>1.0</version>
    <author name=”Your Name”>
        <info url=”
www.example.com” />
    </author>
    <copyright>2006</copyright>
    <description>My first gadget</description>
    <hosts>
        <host name=”sidebar”>
            <base type=”HTML” apiVersion=”1.0.0″ src=”HelloWorld.html” mce_src=”HelloWorld.html” />
            <permissions>full</permissions>
            <platform minPlatformVersion=”0.3″ />
        </host>
    </hosts>
</gadget>

Call this file Gadget.xml

Step 3:

Create a folder called Helloworld.Gadget

Step 4:

1.Simply copy”%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets” and paste in Windows explorer address bar.
2. When you get to that folder Copy and Paste the “HelloWorld.Gadget” folder there.

Step 5:

Add the gadget to your Sidebar and your done !

That’s how easy it was to create a sidebar gadget. Obviously, you want your gadget to do more than just display “HelloWorld”. You have infinite possibilities. Anything that con be done with DHTML or .NET can be done on a sidebar, you just have to make sure you have the right permissions.

How do I create a gadget with .NET?

If you check out the MSDN link you should find it there, and if I get something done soon, I’ll surely post it.

Also check out the Gadget team blog.

Anyway, that’s it for now, Happy developing!

Posted in MSamy, Programming, Vista | 52 Comments »

Refactoring

Posted by archworx on November 5, 2006

The first practice of extreme programming we are going to discuss is Refactoring. It is the process of changing an existing body of code, changing its internal structure without changing its external behavior. Keeping each refactor (change) small ensures the system is restructured while reducing the chances of things going wrong. Constantly refactoring your code eliminates any duplication and keeps your code-base simple and easy to read and manage. For me it’s always a sign you need to refactor when you find yourself copying and pasting code from one class to another.

There are refactoring tools in most IDEs to make it easier for developers to perform this task; common supported tasks usually include renaming of classes and variables, extracting methods, organizing code and much more. Check your IDE and find out how it can help you refactor and make you life easier and your code cleaner.

Posted in Extreme Programming, Nader | 1 Comment »