Scf.Body Method
Converts an ScfElement object graph into an XML string usable for Simple Content Format content.
Namespace: Microsoft.SideShow.SimpleContentFormat
Assembly: Microsoft.SideShow (in microsoft.sideshow.dll)
Usage
Syntax
'Declaration
Public Shared Function Body ( _
content As ScfElement _
) As String
public static string Body (
ScfElement content
)
public:
static String^ Body (
ScfElement^ content
)
public static String Body (
ScfElement content
)
public static function Body (
content : ScfElement
) : String
Parameters
- content
An ScfElement object graph created by calling other Scf methods.
Return Value
A String that can be used for Simple Content Format content.
Example
This example code demonstrates how to create a basic SideShow gadget that sends Simple Content Format XML strings to connected devices by using the static methods of the Scf class. The Body method is used in this example to convert Dialog, Menu, and Content pages into XML strings so they can be sent to connected devices.
private static void SampleScf()
{
// Set the gadget's GUID.
Guid gadgetId = new Guid("{0530B726-F6D5-4a66-900E-3C7673316F3B}");
// Add the gadget's registry subkey and values.
GadgetRegistration.Register(
false, // Register gadget for current user only
gadgetId, // Guid for the registry subkey
ScfSideShowGadget.ScfEndpointId, // Endpoints registry value
"Example SideShow gadget", // FriendlyName registry value
null, // StartCommand registry value
null, // Icon registry value, this gadget will use the generic gadget icon.
false, // OnlineOnly registry value
GadgetCachePolicies.KeepNewest, // CachePolicy registry value
null);
// Construct a Simple Content Format SideShow gadget for the gadget's Guid.
using (ScfSideShowGadget gadget = new ScfSideShowGadget(gadgetId))
{
// Create Simple Content Format Strings and send them to connected SideShow devices.
// Add Glance content showing date/time of last update
gadget.AddGlanceContent(
String.Format("Content updated on {0}{1:D}.", Environment.NewLine, DateTime.Now));
// Set ids.
int dialogPageId = 2;
int mainMenuId = ScfSideShowGadget.HomePageContentId;
int textPageId = 4;
int imagePageId = 5;
int contextMenuId = 6;
int backgroundImageId = 7;
// Create the main menu page.
string content = Scf.Body(
Scf.Menu(mainMenuId, "Simple Gadget Menu", ScfSelectAction.Target,
Scf.Item(dialogPageId, "See the dialog page"),
Scf.Div(),
Scf.Item(textPageId, "See the text Page")));
// Send the menu page to connected SideShow devices.
gadget.AddContent(content);
// Create the dialog page.
content = Scf.Body(
Scf.Dialog(dialogPageId, "Dialog Page Title",
Scf.Txt(ScfAlign.Center, true, Color.Violet, "A very long line of wrapping centered violet text."),
// Set the device buttons.
Scf.Btn(DeviceButton.Up, "Back to Menu", mainMenuId),
Scf.Btn(DeviceButton.Right, "Text page", textPageId),
Scf.Btn(DeviceButton.Down, "Image page", imagePageId),
Scf.Txt(ScfAlign.Right, false, Color.Yellow, "A long line of non-wrapping right aligned yellow text."),
Scf.Div(),
Scf.Txt(ScfAlign.Left, false, Color.Red, "A long line of non-wrapping left aligned red text.")));
// Send the dialog page to connected SideShow devices.
gadget.AddContent(content);
// Create the text page.
content = Scf.Body(
Scf.Content(textPageId, "This is the Text Page",
Scf.Div(),
Scf.Txt(ScfAlign.Left, true, Color.Blue, "This is some blue text")));
// Send the text page to connected SideShow devices.
gadget.AddContent(content);
// Create the image page.
content = Scf.Body(
Scf.Content(imagePageId, "Image", contextMenuId, backgroundImageId, ScfBackgroundImageFit.Center,
Scf.Txt(ScfAlign.Center, true, Color.Red, "Centered Red text"),
Scf.Br(),
Scf.Txt(ScfAlign.Right, false, Color.Green, "Right Green text")));
// Send the image page to connected SideShow devices.
gadget.AddContent(content);
// Add the image ExcelSaga.jpg to the image page.
Stream imageStream = Assembly.GetEntryAssembly().GetManifestResourceStream("CodeSampleSideShow.ExcelSaga.jpg");
gadget.AddContent(backgroundImageId, ImageContentTransforms.KeepAspectRatio,
Image.FromStream(imageStream));
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Development Platforms
Windows Vista Home Premium, Windows Vista Business, Windows Vista Enterprise, Windows Vista Ultimate
Target Platforms
Windows Vista Home Premium, Windows Vista Business, Windows Vista Enterprise, Windows Vista Ultimate
See Also
Reference
Scf Class
Scf Members
Microsoft.SideShow.SimpleContentFormat Namespace