12. Windows Phone 8 API
WP 8.0 Games
Direct X/Direct 3D & C++
WP 8.0 WP 8.0
XAML & VB/C# & Direct 3D XAML & C++
WP 8.0 WP 8.0
XAML & VB/C# XAML & C++
WP 7.1
XNA & VB/C#
WP7.1= Windows Phone OS 7.1 = Windows Phone 7.1/7.8
WP 7.1
XAML & VB/C#
.NET API for Windows
Win32 &
Windows Phone
COM
Phone Runtime
(native)
(managed) (managed/native)
13. .NET API for Windows
Win32 &
Windows Phone
COM
Phone Runtime
• .NET API for Windows Phone
• WP7.1にあるすべてのtypeとAPIを含む
• System名前空間とMicrosoft.Phone名前空間
• WP8.0追加API
•Microsoft.Phone.Wallet
•Microsoft.Phone.Tasks.ShareMediaTask
•Microsoft.Phone.Tasks.MapsTask
•Microsoft.Phone.Storage.ExternalStorage
•Microsoft.Phone.Networking.Voip
など
14. .NET API for Windows
Win32 &
Windows Phone
COM
Phone Runtime
• Windows Phone Runtime (WinPRT)
• WinRTのサブセット + Phone関連の追加
Win RT • Phone関連の追加
(約11,000メンバ) •音声合成と音声認識
•カスタム連絡先ストア
•ロックスクリーン
サブセット 追加 など
(約2,800) (約600)
15. .NET APIとWinPRTで同等APIが存在
.NET API Windows Phone Runtime API
System.IO.IsolatedStorage Windows.Storate
System.Net.Sockets Windows.Networking.Sockets
System.Threading.ThreadPool Windows.System.Threading.ThreadPool
Microsoft.Devices.Sensors Windows.Devices.Sensors
• WP7.1とWP8.0をターゲットにする
なら.NET API
• WP8とW8でコード共有するなら
WinPRT
46. カメラビューの表示
Dim res As Windows.Foundation.Size = SupportedResolutions(0)
Me.Live = Await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, res)
RaiseEvent Initialized(Nothing, Nothing)
Imports Windows.Phone.Media.Capture
Public ReadOnly Property Live As PhotoCaptureDevice
Get
Return Me.VmLiveModel.Live
End Get
End Property
<Rectangle Grid.Row="0" Stroke="Black" Margin="0,100,0,100">
<Rectangle.Fill>
<VideoBrush x:Name="ViewfinderBrush"/>
</Rectangle.Fill>
</Rectangle>
Me.ViewfinderBrush.SetSource(Me.ViewModel.Live)
47. コンパス機能の追加
Private WithEvents CompassWatcher As Compass
Me.CompassWatcher = Compass.GetDefault
Private Sub ReadingChanged(sender As Compass,
e As CompassReadingChangedEventArgs) _
Handles CompassWatcher.ReadingChanged
Me.MagneticHeading = e.Reading.HeadingMagneticNorth
End Sub
Imports Windows.Devices.Sensors
Public ReadOnly Property MagneticHeading As Double
Get
Return Me.VmCompassModel.MagneticHeading
End Get
End Property
48. コンパス機能の追加
<Grid x:Name="Compass_Grid" RenderTransformOrigin="0.5,0.5">
<es:RegularPolygon
Stroke="{StaticResource PhoneAccentBrush}" StrokeThickness="3"
InnerRadius="1" PointCount="3" Stretch="Fill"
UseLayoutRounding="False" Width="160" Height="160"
Margin="127.015,240,127.015,392.478"/>
<Ellipse Width="320" Height="320"
Stroke="{StaticResource PhoneAccentBrush}" StrokeThickness="3" />
</Grid>
Private Sub Compass_PropertyChanged(sender As Object,
e As PropertyChangedEventArgs) _
Handles ViewModel.PropertyChanged
Dispatcher.BeginInvoke(
Sub()
Dim g As New TransformGroup
g.Children.Add(New RotateTransform With {
.Angle = Me.ViewModel.MagneticHeading})
Me.Compass_Grid.RenderTransform = g
End Sub)
End Sub
50. 傾きを反映
Private WithEvents MotionWatcher As Inclinometer
Me.MotionWatcher = Inclinometer.GetDefault
Private Sub ReadingChanged(sender As Inclinometer,
e As InclinometerReadingChangedEventArgs) _
Handles MotionWatcher.ReadingChanged
Me.Pitch = e.Reading.PitchDegrees
Me.Yaw = e.Reading.YawDegrees
Me.Roll = e.Reading.RollDegrees
End Sub
Public ReadOnly Property Pitch As Single
Get
Return Me.VmMotionModel.Pitch
End Get
End Property
Public ReadOnly Property Yaw As Single
Get
Return Me.VmMotionModel.Yaw
End Get
End Property
;
;
51. 傾きを反映
<Grid x:Name="D3D_Grid" Grid.Row="0" RenderTransformOrigin="0.5,0.5">
<Grid x:Name="Compass_Grid" RenderTransformOrigin="0.5,0.5">
:
</Grid>
</Grid>
Private Sub Compass_PropertyChanged(sender As Object,
e As PropertyChangedEventArgs) _
Handles ViewModel.PropertyChanged
Dispatcher.BeginInvoke(
Sub()
Dim g As New TransformGroup
g.Children.Add(New RotateTransform With {
.Angle = Me.ViewModel.MagneticHeading})
Me.Compass_Grid.RenderTransform = g
Me.D3D_Grid.Projection = New PlaneProjection With {
.RotationX = Me.ViewModel.Pitch,
.RotationY = Me.ViewModel.Roll}
End Sub)
End Sub