ScfSideShowGadget.AddContent Method (Int32, ImageContentTransforms, Image)
Sends a Simple Content Format image from the gadget to the connected Windows SideShow-compatible devices.
Namespace: Microsoft.SideShow.SimpleContentFormat
Assembly: Microsoft.SideShow (in microsoft.sideshow.dll)
Usage
Syntax
'Declaration
Public Sub AddContent ( _
contentId As Integer, _
imageConversionFlags As ImageContentTransforms, _
image As Image _
)
public void AddContent (
int contentId,
ImageContentTransforms imageConversionFlags,
Image image
)
public:
void AddContent (
int contentId,
ImageContentTransforms imageConversionFlags,
Image^ image
)
public void AddContent (
int contentId,
ImageContentTransforms imageConversionFlags,
Image image
)
public function AddContent (
contentId : int,
imageConversionFlags : ImageContentTransforms,
image : Image
)
Parameters
- contentId
An Int32 that identifies the constant's ID.
- imageConversionFlags
Identifies the image conversions that should be done by the gadget before sending the image to the device.
- image
Identifies the image to be sent from the gadget to the device.
Example
The following example code shows the use of the Img method to send images to connected Windows SideShow-compatible devices. The example shows how to reference images that are 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
ScfSideShowGadget Class
ScfSideShowGadget Members
Microsoft.SideShow.SimpleContentFormat Namespace