8.0 相機和照片: 鏡頭的可擴充性, 圖片的可擴充性, 圖片的自動上傳擴充
介紹
與眾不同 windows phone 8.0 之 相機和照片
鏡頭的可擴充性
圖片的可擴充性
圖片的自動上傳擴充
樣本
1、示範如何將本 app 註冊為鏡頭擴充
CameraAndPhoto/LensExtensibility.xaml
<phone:PhoneApplicationPage x:Class="Demo.CameraAndPhoto.LensExtensibility" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" mc:Ignorable="d" shell:SystemTray.IsVisible="True"> <Grid Background="Transparent"> <StackPanel Orientation="Vertical"> <TextBlock x:Name="lblMsg" Text="啟動相機後,可以通過“濾鏡”啟動本 app" /> <Button x:Name="btnPhotoCapture" Content="用此 app 照相" Click="btnPhotoCapture_Click" /> <Button x:Name="btnAudioVideoCapture" Content="用此 app 錄影" Click="btnAudioVideoCapture_Click" /> </StackPanel> </Grid> </phone:PhoneApplicationPage>
CameraAndPhoto/LensExtensibility.xaml.cs
/* * 示範如何將本 app 註冊為鏡頭擴充 * * 1、需要在 manifest 中增加配置 <Extension TaskID="_default" ExtensionName="Camera_Capture_App" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5631}" /> * 2、在 Assets 根資料夾內添加 3 個檔案,作為鏡頭選取器的表徵圖 * Lens.Screen-WVGA.png - 800*480 15:9 * Lens.Screen-WXGA.png - 1280*768 15:9 * Lens.Screen-720p.png - 1280*720 16:9 * * * 註: * 相關的 UriMapper 參見 MyUriMapper.cs * * * 什麼是鏡頭擴充? * 就是開啟相機後,單擊“濾鏡”按鈕,會出現一排 app 列表,這裡的每一個 app 就是一個鏡頭擴充程式 */ using System.Collections.Generic; using System.Windows.Navigation; using Microsoft.Phone.Controls; using System; namespace Demo.CameraAndPhoto { public partial class LensExtensibility : PhoneApplicationPage { public LensExtensibility() { InitializeComponent(); } protected override void OnNavigatedTo(NavigationEventArgs e) { IDictionary<string, string> queryStrings = this.NavigationContext.QueryString; if (queryStrings.ContainsKey("fromLens")) { lblMsg.Text = "您是通過相機的“濾鏡”啟動本 app 的"; } base.OnNavigatedTo(e); } private void btnPhotoCapture_Click(object sender, System.Windows.RoutedEventArgs e) { NavigationService.Navigate(new Uri("/CameraAndPhoto/PhotoCaptureDeviceDemo.xaml", UriKind.Relative)); } private void btnAudioVideoCapture_Click(object sender, System.Windows.RoutedEventArgs e) { NavigationService.Navigate(new Uri("/CameraAndPhoto/AudioVideoCaptureDeviceDemo.xaml", UriKind.Relative)); } } }