[ engine demonstrations | engine overview | imnmotion.com | Stephen W. Cote ]
Demonstration #19 shows how to use Engine for Web Applications inside a Windows Vista Sidebar Gadget, along with the Account Manager .NET library.
This demonstration requires Windows Vista, and SQLExpress. SQLExpress must be installed prior to running this demonstration.
The gadget files and project source code for this demonstration binaries and source code for this demonstration are as follows.
Unzip the EngineGadgetDemo1.zip file into the Sidebar Gadgets directory: \Users\{user-name}\AppData\Local\Microsoft\Windows Sidebar\Gadgets
For example:
\Users\steve\AppData\Local\Microsoft\Windows Sidebar\Gadgets\Engine.gadget
Execute the reg.bat file to registred the GadgetExchange ActiveX control. This control hosts the AccountManager library, and also provides an alternate method to load the local XML files.
The main difference between using Engine for Web Applications on a Web page and a Sidebar Gadget is that the org.cote.js.xml library needs to be set to use gadget_mode. The default control value for gadget_control is Core.Gadget.GadgetXmlHttp, and does not need to be changed for this example. The base path must be specified using a file URI. The following example shows how to apply these settings.
var g_control = new ActiveXObject("Core.Gadget.GadgetExchange");
if(typeof ValidatePackage=="function" && ValidatePackage("org.cote.js.xml")){
// Set org.cote.js.xml to use 'gadget mode'
//
org.cote.js.xml.gadget_mode = 1;
// Fix the local path to use a URI syntax
//
org.cote.js.xml.gadget_base_path = "file:///" + g_control.ComponentPath.replace("\\","/");
}
The referenced Engine Gadget #1 uses the template features of Engine to encapsulate functionality for convenient deployment. This would conceivably be used to deliver common widgets and scripts to friends, or to quickly build up repositories of useful tools that could be encrypted and licensed using the Account Manager features, while simultaneously be very easy to build and deploy within the Engine Gadget.
At this point, the Engine for Web Applications code may be used as desired, and the g_gadget variable may be used to interact with the AccountManager library. Further Engine/Gadget examples will delve into using this interaction to create dynamic gadgets, and leveraging the Account Manager library to license and securely deploy gadget add-ons.
The screenshot screenshot_gadget_1.jpg shows the running gadget. It is very much a beginning example.