ScfImageFit Enumeration
Indicates how to fit an image within the device's display.
Namespace: Microsoft.SideShow.SimpleContentFormat
Assembly: Microsoft.SideShow (in microsoft.sideshow.dll)
Usage
Syntax
'Declaration
Public Enumeration ScfImageFit
public enum ScfImageFit
public enum class ScfImageFit
public enum ScfImageFit
public enum ScfImageFit
Members
Member name | Description |
---|---|
Auto | Lets the device determine the best size for the associated image, thereby allowing the device to fit all content (text and images) on a single screen by adjusting the size of the associated image. |
Native | Uses the native resolution of the associated image, cropping the width as necessary (horizontal scrolling is not supported). |
Screen | Proportionately scales the associated image to fit the width and height of the screen without requiring scroll bars. |
Width | Proportionately scales the associated image to fit the available width of the screen. |
Example
The following example code shows how to use 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));
}
}
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