Scf.Item Method (Generic Nullable, Generic Nullable, Boolean, Boolean, 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 ( _
    itemId As Nullable(Of Integer), _
    imageId As Nullable(Of Integer), _
    isEnabled As Boolean, _
    isDefault As Boolean, _
    contextMenuId As Nullable(Of Integer), _
    targetId As Integer, _
    ParamArray content As Object() _
) As ScfElement
public static ScfElement Item (
    Nullable<int> itemId,
    Nullable<int> imageId,
    bool isEnabled,
    bool isDefault,
    Nullable<int> contextMenuId,
    int targetId,
    params Object[] content
)
public:
static ScfElement^ Item (
    Nullable<int> itemId, 
    Nullable<int> imageId, 
    bool isEnabled, 
    bool isDefault, 
    Nullable<int> contextMenuId, 
    int targetId, 
    ... array<Object^>^ content
)
public static ScfElement Item (
    Nullable<int> itemId, 
    Nullable<int> imageId, 
    boolean isEnabled, 
    boolean isDefault, 
    Nullable<int> contextMenuId, 
    int targetId, 
    Object[] content
)
public static function Item (
    itemId : Nullable<int>, 
    imageId : Nullable<int>, 
    isEnabled : boolean, 
    isDefault : boolean, 
    contextMenuId : Nullable<int>, 
    targetId : int, 
    ... content : Object[]
) : ScfElement

Parameters

  • itemId
    Identifies the item’s ID.
  • imageId
    Identifies the content’s image ID.
  • isEnabled
    Indicates whether the item is enabled or not.
  • isDefault
    Indicates whether the item should be selected by default.
  • 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 that contains an item element that is selected by default as well as an item element that is disabled. A disabled item will do nothing if the user selects it.

private static void SampleItem4()
{
    // 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;

        string content =
            Scf.Body(
                Scf.Menu(mainMenuPageId, "Main Menu", ScfSelectAction.Target,
                    // This is the default item.
                    Scf.Item(null, icon1Id, true, true, null, page1Id, "Displays page 1."),
                    Scf.Item(null, icon2Id, true, false, null, page2Id, "Displays page 2."),
                    // This item is disabled.
                    Scf.Item(null, icon3Id, false, false, null, page3Id, "Displays 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, "Dialog 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, "Dialog 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, "Dialog Page 3 Title",
            Scf.Txt(ScfAlign.Left, true, Color.Black, "Page 3 text.")));
        gadget.AddContent(page3);
    }
}

Remarks

If isEnabled is false, then nothing will happen if the user selects the item.

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