1.       Manifest File:
| 
Properties/WMAppManifest.xml | 
| 
<?xml version="1.0" encoding="utf-8"?> 
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0"> 
  <DefaultLanguage xmlns="" code="en-US" /> 
  <App xmlns="" ProductID="{86602b8c-3386-4d53-9061-4010038430fd}" Title="CameraApp" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="camera author" Description="Sample description" Publisher="camera" PublisherID="{52fa765c-ce63-4113-a70c-46ecadbcd9b2}"> 
    <IconPath IsRelative="true" IsResource="false">Assets\ApplicationIcon.png</IconPath> 
    <Capabilities> 
      <Capability Name="ID_CAP_MEDIALIB_PLAYBACK" /> 
      <Capability Name="ID_CAP_SENSORS" /> 
      <Capability Name="ID_CAP_ISV_CAMERA" /> 
    </Capabilities> 
    <Tasks> 
      <DefaultTask Name="_default" NavigationPage="MainPage.xaml" /> 
    </Tasks> 
    <Tokens> 
      <PrimaryToken TokenID="cameraToken" 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>camera</Title> 
          <BackContent> 
          </BackContent> 
          <BackBackgroundImageURI> 
          </BackBackgroundImageURI> 
          <BackTitle> 
          </BackTitle> 
          <DeviceLockImageURI> 
          </DeviceLockImageURI> 
          <HasLarge> 
          </HasLarge> 
        </TemplateFlip> 
      </PrimaryToken> 
    </Tokens> 
    <ScreenResolutions> 
      <ScreenResolution Name="ID_RESOLUTION_WVGA" /> 
      <ScreenResolution Name="ID_RESOLUTION_WXGA" /> 
      <ScreenResolution Name="ID_RESOLUTION_HD720P" /> 
    </ScreenResolutions> 
  </App> 
</Deployment> | 
2.       User Interface (UI) file:
| 
MainPage.xaml | 
| 
<phone:PhoneApplicationPage 
    x:Class="camera.MainPage" 
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" 
    mc:Ignorable="d" 
    FontFamily="{StaticResource PhoneFontFamilyNormal}" 
    FontSize="{StaticResource PhoneFontSizeNormal}" 
    Foreground="{StaticResource PhoneForegroundBrush}" 
SupportedOrientations="Portrait" Orientation="Portrait" 
shell:SystemTray.IsVisible="True"> 
    <!--LayoutRoot is the root grid where all page content is placed--> 
    <Grid x:Name="LayoutRoot" Background="Transparent"> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="Auto"/> 
            <RowDefinition Height="*"/> 
        </Grid.RowDefinitions> 
        <!--TitlePanel contains the name of the application and page title--> 
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> 
            <TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/> 
            <TextBlock  Text="Camera App" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> 
        </StackPanel> 
        <!--ContentPanel - place additional content here--> 
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
            <Button Content="Camera Capture" Height="72" HorizontalAlignment="Left" Margin="49,412,0,0" Name="capture" VerticalAlignment="Top" Width="334" Click="cameraCapture_Click" /> 
            <Image Height="269" HorizontalAlignment="Left" Margin="25,19,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="406" /> 
        </Grid> 
    </Grid> 
</phone:PhoneApplicationPage> | 
3.       Code file:
| 
Source Code | 
| 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Net; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Navigation; 
using Microsoft.Phone.Controls; 
using Microsoft.Phone.Shell; 
using camera.Resources; 
using Microsoft.Phone.Tasks; 
using System.Windows.Media.Imaging; 
namespace camera 
{ 
    public partial class MainPage : PhoneApplicationPage 
    { 
        // Constructor 
 public MainPage() 
    {           InitializeComponent();         } 
private void cameraCapture_Click(object sender, RoutedEventArgs e) 
        { 
CameraCaptureTask cameraCaptureTask; 
// initializes the task object, and identifies the method to run after the user completes the task. 
cameraCaptureTask = new CameraCaptureTask(); 
cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed); 
            cameraCaptureTask.Show(); 
        } 
void cameraCaptureTask_Completed(object sender, PhotoResult e) 
        { 
if (e.TaskResult == TaskResult.OK) 
  { 
BitmapImage bmp = new BitmapImage();                bmp.SetSource(e.ChosenPhoto); 
image1.Source = bmp; 
            } 
        } 
    } 
} | 
 
ليست هناك تعليقات:
إرسال تعليق