Scf.Content Method (Int32, String, ScfElement )

Creates a Simple Content Format Content element.

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

Usage

Syntax

'Declaration
Public Shared Function Content ( _
    id As Integer, _
    pageTitle As String, _
    ParamArray content As ScfElement() _
) As ScfElement
public static ScfElement Content (
    int id,
    string pageTitle,
    params ScfElement[] content
)
public:
static ScfElement^ Content (
    int id, 
    String^ pageTitle, 
    ... array<ScfElement^>^ content
)
public static ScfElement Content (
    int id, 
    String pageTitle, 
    ScfElement[] content
)
public static function Content (
    id : int, 
    pageTitle : String, 
    ... content : ScfElement[]
) : ScfElement

Parameters

  • id
    Identifies the content's ID.
  • pageTitle
    Identifies the title of the content's page.
  • content
    An array of ScfElement objects that make up this content element's content.

Return Value

An ScfElement object that represents the specified content.

Example

This example code shows 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));
    }
}

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