giovedì 22 marzo 2012

Windows Phone 7.5 & Microsoft.Phone.Tasks

<phone:PhoneApplicationPage
    x:Class="W75_Photo.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" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot  la griglia radice in cui viene inserito tutto il contenuto della pagina-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contiene il nome dell'applicazione e il titolo della pagina-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="CSharpLight" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="PhotoCamera" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - inserire ulteriore contenuto qui-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Button Content="Take a Photo" VerticalAlignment="Top" Click="Button_Click"></Button>
        </Grid>
    </Grid>
  </phone:PhoneApplicationPage>
Partial Public Class MainPage
    Inherits PhoneApplicationPage
    ' Costruttore
    Public Sub New()
        InitializeComponent()
    End Sub

    Private Sub Button_Click(sender As System.Object, e As System.Windows.RoutedEventArgs)
        Dim pt As New Microsoft.Phone.Tasks.CameraCaptureTask
        AddHandler pt.Completed, Sub(s As Object, e1 As Microsoft.Phone.Tasks.PhotoResult)
                                     If e1.TaskResult = Microsoft.Phone.Tasks.TaskResult.OK Then
                                         'Ecco un reader per lo stream contenente la foto :)  semplice
                                         Dim sr As New IO.StreamReader(e1.ChosenPhoto)
                                     End If
                                 End Sub
        'Avviamo il Task
        pt.Show()
    End Sub
End Class
Creare un App per Windows Phone 7.5 in 5 minuti.  Sorriso
Deploy effettuato su NOKIA LUMIA 800.
Tiz

Nessun commento: