Scf.Item Method (Generic Nullable, Generic Nullable, Int32, Object )

Creates a Simple Content Format Item element.

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

Usage

Syntax

'Declaration
Public Shared Function Item ( _
    imageId As Nullable(Of Integer), _
    contextMenuId As Nullable(Of Integer), _
    targetId As Integer, _
    ParamArray content As Object() _
) As ScfElement
public static ScfElement Item (
    Nullable<int> imageId,
    Nullable<int> contextMenuId,
    int targetId,
    params Object[] content
)
public:
static ScfElement^ Item (
    Nullable<int> imageId, 
    Nullable<int> contextMenuId, 
    int targetId, 
    ... array<Object^>^ content
)
public static ScfElement Item (
    Nullable<int> imageId, 
    Nullable<int> contextMenuId, 
    int targetId, 
    Object[] content
)
public static function Item (
    imageId : Nullable<int>, 
    contextMenuId : Nullable<int>, 
    targetId : int, 
    ... content : Object[]
) : ScfElement

Parameters

  • imageId
    Identifies the content’s image ID.
  • contextMenuId
    Identifies the one-based ID of the page’s context menu.
  • targetId
    Identifies the ID of the content that the device should navigate to.
  • content
    An ScfElement object that makes up this Item element's content.

Return Value

Returns an ScfElement that represents a menu item..

Example

The following example code creates a Simple Content Format Menu with icons for each item.

private static void SampleItem2()
{
    // 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))
    {
        // Add Glance content.
        gadget.AddGlanceContent(
           String.Format("Some glance content"));

        // Set element ids;
        int mainMenuPageId = 1;
        int icon1Id = 2;
        int icon2Id = 3;
        int icon3Id = 4;
        int page1Id = 5;
        int page2Id = 6;
        int page3Id = 7;
        int menuItem1Id = 8;
        int menuItem2Id = 9;
        int menuItem3Id = 10;

        // Create the main menu with 3 menu items. Each menu item has an icon and links to a context menu. 
        string content =
            Scf.Body(
                Scf.Menu(mainMenuPageId, "Main Menu", ScfSelectAction.Target,
                    // The first context menu.
                    Scf.Item(menuItem1Id, icon1Id, null, page1Id, "Click for page 1."),
                    Scf.Item(menuItem2Id, icon2Id, null, page2Id, "Click for page 2."),
                    Scf.Item(menuItem3Id, icon3Id, null, page3Id, "Click for page 3.")
                    )
                );
        gadget.AddContent(content);

        // Add the 1st icon.
        string imageLocation = @"C:\Users\Public\SideShowGadget\icon1.jpg";
        gadget.AddContent(icon1Id, ImageContentTransforms.KeepAspectRatio, new Bitmap(imageLocation));

        // Add the 2nd icon.
        imageLocation = @"C:\Users\Public\SideShowGadget\icon2.jpg";
        gadget.AddContent(icon2Id, ImageContentTransforms.KeepAspectRatio, new Bitmap(imageLocation));

        // Add the 3rd icon.
        imageLocation = @"C:\Users\Public\SideShowGadget\icon3.jpg";
        gadget.AddContent(icon3Id, ImageContentTransforms.KeepAspectRatio, new Bitmap(imageLocation));

        // The first page.
        string page1 = Scf.Body(
         Scf.Content(page1Id, "Page 1 Title",
         Scf.Txt(ScfAlign.Left, true, Color.Black, "Page 1 text.")));
        gadget.AddContent(page1);
        
        // The second page.
        string page2 = Scf.Body(
            Scf.Content(page2Id, "Page 2 Title",
            Scf.Txt(ScfAlign.Left, true, Color.Black, "Page 2 text.")));
        gadget.AddContent(page2);

        // The third page.
        string page3 = Scf.Body(
            Scf.Content(page3Id, "Page 3 Title",
            Scf.Txt(ScfAlign.Left, true, Color.Black, "Page 3 text.")));
        gadget.AddContent(page3);
    }
}

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