Smart Space 11.1.1: Creating Your First Smart Space Gadget

"Hello World" Example

This section describes how to create a Smart Space gadget that displays the toast message "Hello World" on your computer. The gadget can be created using either C# or VB.NET. To create the example:

Open Visual Studio and select File > New > Project.

From Visual C# (or Visual Basic), Templates, click Smart Space Gadget.

Optional: Update the gadget name, the location and the solution name, and click OK.

Enter a namespace, and click Finish.

Tip: If you change the namespace later, you must edit the type field in the configuration.xml file to match.

From the Solution Explorer, double-click gadget.cs (or Gadget.vb).

Select View > Code.

At the top of the file under the using (or Imports) statements, add the following line of code:

Visual Basic


Imports Oracle.SmartSpace.Sdk.Services

C#


using Oracle.SmartSpace.Sdk.Services;

Tip: This code imports Smart Space Services namespace to allow for more convenient coding.

Select View > Designer.

From the Toolbox, drag a button onto the form and click the button once to select it.

In the Properties window, set the following properties:

  1. Name to displayToastButton
  2. Text to Display Toast Message
  3. Width to 145

Tip: Click the Size property, then update the Width.

Double-click the Display Toast Message button to add an event handler for the Click event. The Code Editor will open with the insertion point placed within the event handler.

Insert this code at the cursor:

Visual Basic


Me.Services.ToastManager.Show("Hello World!")

C#


this.Services.ToastManager.Show("Hello world!");

To save, select File > Save.

Debugging and Testing

Use debug to run your code.

Tip: You must have the Smart Space client installed and running on your computer to debug.

Tip: If you run without debugging, you cannot test your gadget in the Smart Space client.

Select Debug > Start Debugging. Your gadget appears in the Smart Space palette.

Double-click the gadget to add it to a Smart Space desktop.

To test the Hello World! example, click Display Toast Message The toast message Hello World! appears in the bottom right corner of your screen.

Select Debug > Stop Debugging.

Building

After you create, debug and test a gadget you can build it within Visual Studio, which makes it available for publishing.

From Visual Studio Solution Explorer, right-click the gadget and select Build Gadget.

Specify a location to store the gadget. The gadgetname.SmartSpaceGadget file is created, where gadgetname is the name of your gadget.

To make this gadget available to users, publish it to an existing Smart Space installation. Please see "Publishing a Gadget or Service" in the "Administrator's Help" document in Smart Space Online Help.