Scf.Img Method
Creates a Simple Content Format Img element.
Namespace: Microsoft.SideShow.SimpleContentFormat
Assembly: Microsoft.SideShow (in microsoft.sideshow.dll)
Usage
Syntax
'Declaration
Public Shared Function Img ( _
id As Integer, _
align As ScfAlign, _
imageFit As ScfImageFit, _
altText As String _
) As ScfElement
public static ScfElement Img (
int id,
ScfAlign align,
ScfImageFit imageFit,
string altText
)
public:
static ScfElement^ Img (
int id,
ScfAlign align,
ScfImageFit imageFit,
String^ altText
)
public static ScfElement Img (
int id,
ScfAlign align,
ScfImageFit imageFit,
String altText
)
public static function Img (
id : int,
align : ScfAlign,
imageFit : ScfImageFit,
altText : String
) : ScfElement
Parameters
- id
Identifies the content’s ID.
- align
Identifies how the image should be aligned.
- imageFit
Identifies how the image should fit.
- altText
Identifies the image’s alternate text.
Return Value
Returns a ScfElement object that represents an image.
Example
The following example code shows the use of the Img method to send images to connected devices. The example shows how to reference an image that is located in the gadget's assembly as well an external image stored in a local directory.
private static void SampleImg()
{
// 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 showing date/time of last update
gadget.AddGlanceContent(
String.Format("Content updated on {0}{1:D}.", Environment.NewLine, DateTime.Now));
// Set ids.
int mainMenuId = ScfSideShowGadget.HomePageContentId;
int textPageId = 4;
int imagePageId = 5;
int imageId = 7;
// Create the main menu page.
string content = Scf.Body(
Scf.Menu(mainMenuId, "Simple Gadget Menu", ScfSelectAction.Target,
Scf.Item(textPageId, "See the text page"),
Scf.Item(imagePageId, "See the image Page")));
// Send the menu page to connected SideShow devices.
gadget.AddContent(content);
// Create the text page.
content = Scf.Body(
Scf.Content(textPageId, "This is the Text Page",
Scf.Txt(ScfAlign.Left, true, Color.Green, "This is some Green text")));
// Send the text page to connected SideShow devices.
gadget.AddContent(content);
// Create the image page using the Img method.
content = Scf.Body(
Scf.Content(imagePageId, "This is the image page.",
Scf.Img(imageId, ScfAlign.Center, ScfImageFit.Auto, "Alt image text."),
Scf.Txt(ScfAlign.Center, true, Color.Black, "Image caption.")));
// Send the image page to connected SideShow devices.
gadget.AddContent(content);
// Send an image from a local directory to connnected SideShow devices.
string imageLocation = @"C:\Users\Public\SideShowGadget\HungerForce.jpg";
gadget.AddContent(imageId, ImageContentTransforms.KeepAspectRatio, new Bitmap(imageLocation));
// Send an image from the this gadget's assembly to connnected SideShow devices.
Stream imageStream = Assembly.GetEntryAssembly().GetManifestResourceStream("CodeSampleSideShow.ExcelSaga.jpg");
gadget.AddContent(imageId, 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