Window Phone 8 应用程序连接扩展图片中心,图片扩展,图片查看器

时间:2023-03-09 03:26:34
Window Phone 8 应用程序连接扩展图片中心,图片扩展,图片查看器

WMAppManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
<DefaultLanguage xmlns="" code="zh-CN" />
<App xmlns="" ProductID="{eb469a5c-e2dc-4dc6-ad58-153797faed43}" Title="PhoneAppPhotoExtensions" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="PhoneAppPhotoExtensions author" Description="Sample description" Publisher="PhoneAppPhotoExtensions" PublisherID="{429d1ed4-d204-4130-a105-6ce51ec208ab}">
<IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_MEDIALIB_AUDIO" />
<Capability Name="ID_CAP_MEDIALIB_PLAYBACK" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="PhoneAppPhotoExtensionsToken" TaskName="_default">
<TemplateFlip>
<SmallImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileSmall.png</SmallImageURI>
<Count>0</Count>
<BackgroundImageURI IsRelative="true" IsResource="false">Assets\Tiles\FlipCycleTileMedium.png</BackgroundImageURI>
<Title>PhoneAppPhotoExtensions</Title>
<BackContent>
</BackContent>
<BackBackgroundImageURI>
</BackBackgroundImageURI>
<BackTitle>
</BackTitle>
<DeviceLockImageURI>
</DeviceLockImageURI>
<HasLarge>
</HasLarge>
</TemplateFlip>
</PrimaryToken>
</Tokens>
<Extensions>
<Extension ExtensionName="Photos_Extra_Hub" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
<Extension ExtensionName="Photos_Extra_Viewer" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
<Extension ExtensionName="Photos_Extra_Share" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
</Extensions>
<ScreenResolutions>
<ScreenResolution Name="ID_RESOLUTION_WVGA" />
<ScreenResolution Name="ID_RESOLUTION_WXGA" />
<ScreenResolution Name="ID_RESOLUTION_HD720P" />
</ScreenResolutions>
</App>
</Deployment>
            // Get a dictionary of query string keys and values.
IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; //<Extension ExtensionName="Photos_Extra_Viewer" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
// Ensure that there is at least one key in the query string, and check whether the "token" key is present.
if (queryStrings.ContainsKey("token"))
{ // Retrieve the picture from the media library using the token passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(queryStrings["token"]); // Create a WriteableBitmap object and add it to the Image control Source property.
BitmapImage bitmap = new BitmapImage();
bitmap.CreateOptions = BitmapCreateOptions.None;
bitmap.SetSource(picture.GetImage()); WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);
retrievePic.Source = picLibraryImage;
}
//<Extension ExtensionName="Photos_Extra_Share" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
if (queryStrings.ContainsKey("FileId"))
{
// Retrieve the picture from the media library using the FileID
// passed to the application.
MediaLibrary library = new MediaLibrary();
Picture picture = library.GetPictureFromToken(queryStrings["FileId"]); // Create a WriteableBitmap object and add it to the Image control Source property.
BitmapImage bitmap = new BitmapImage();
bitmap.CreateOptions = BitmapCreateOptions.None;
bitmap.SetSource(picture.GetImage()); WriteableBitmap picLibraryImage = new WriteableBitmap(bitmap);
retrievePic.Source = picLibraryImage;
}

http://msdn.microsoft.com/zh-cn/library/gg278408(v=vs.92).aspx#BKMK_Photos

PhoneAppPhotoExtensions2013年10月12日164259.rar