Scf Class

Provides methods to help construct SideShow Simple Content Format XML strings. This class cannot be inherited.

Namespace: Microsoft.SideShow.SimpleContentFormat
Assembly: Microsoft.SideShow (in microsoft.sideshow.dll)

Usage

Syntax

'Declaration
Public NotInheritable Class Scf
public static class Scf
public ref class Scf abstract sealed
public final class Scf
public final class Scf

Example

This code example 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.

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));
    }
}

Remarks

The SideShow platform allows content IDs to be in the range of 0x00000000 through 0xFFFFFFFF (the range of an unsigned integer). However, the managed API for SideShow limits content IDs to the range 0x00000000 through 0x7FFFFFFF (the range of a signed integer). This restriction is due to the fact that the managed API has to be CLS-compliant. The Common Language Specification requires that all integer parameters be signed integers.

If your gadget uses the managed API and you need to use content IDs outside the allowed range, you can manually generate the SCF and use those IDs.

Inheritance Hierarchy

System.Object
  Microsoft.SideShow.SimpleContentFormat.Scf

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 Members
Microsoft.SideShow.SimpleContentFormat Namespace