sp2-2.indd

Similar documents
HOW DO I WebBrowser コントロールで HTML5 を 使用するには ここでは以下の手順で説明します Video 要素を使用する Silverlight と JavaScript の間でやり取りする Canvas 要素を使用する Video 要素を使用する 1. Visual Stu

Android から Windows Phone へ 10 の基本タスク 英語版公開日 : 2011 年 10 月 5 日 ( 水 ) 10:09:24 AM Windows Phone Interoperability サイトは さまざまなスマートフォンプラットフォーム向けにアプリケーションを開発

目次 はじめに... 3 システムの必要条件... 3 サンプルアプリケーションの作成... 3 手順 手順 手順 手順 手順 手順 終わりに... 23

新しいイテレーション型開発

Windows Phone アプリケーション開発 写真加工アプリケーションの作成 日本マイクロソフト株式会社 デベロッパー & プラットフォーム統括本部監修

Windows Phone アプリケーション開発 DailyCalendar の作成 日本マイクロソフト株式会社 デベロッパー & プラットフォーム統括本部作成

DEMO1 まずはやってみよう アクティビティをダブルクリック 作成 - プロジェクト C# => Workflow CodeActivity をぽとぺ シーケンシャルと ステートマシン それぞれのコ ンソールアプリ あとライブラリがある びっくりマークは足りていないあかし プロパティをみると判別で

TOEIC

Abstract Kinect for Windows RGB Kinect for Windows v Kinect for Windows v2

DockControl for WPF/Silverlight

untitled

1: Android 2 Android 2.1 Android 4 Activity Android Service ContentProvider BroadcastReceiver Activity ( ): Android 1 Android Service ( ): ContentProv

Carousel for WPF/Silverlight

Chart3D for WPF/Silverlight

WPF アプリケーションの 多言語切替

MVP for VB が語る C# 入門

LogisticaTRUCKServer-Ⅱ距離計算サーバ/Active-Xコントロール/クライアント 概略   

Visual Studio Do-It-Yourself 第 9 回ユーザーコントロール 第 6 回のリソースから第 8 回のテンプレートで さまざまな方法でコントロールをカスタマズできるこ とを学びました 今回のテーマであるユーザーコントロールは 既存の一つのコントロールをカスタマ ズするのではな

XAML Do-It-Yourself 第 3 回ベントとトリガー XML Do-It-Yourself 第 3 回目は ベント処理とトリガーについて学習します Windows フォームゕプリケーションでは たとえば ボタンが押された というベントに対応する処理 ( ベントハンドラー ) を記述する

OutlookBar for WPF/Silverlight

Visual Studio ( )

C#の基本

sp2-2.indd

WD130P104P109_KK_WindowsPhone.indd

A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3,

ArcGIS Runtime SDK for Windows Phone スタートアップ ガイド (v10.1.x)

ASP.NET 2.0 Provider Model 概要

Windows 10 IoT Core MVA 2015 August Windows 10 IoT Core ハンズオントレーニング Building and running Github MS IoT Samples on Windows 10 IoT Core 3 章 UWP アプリの開発 L

WPFの初歩の初歩

Windows Phone端末開発の取組み

SharpShooter Reports.WPF 基本的な使い方 Last modified on: November 15, 2012 本ドキュメント内のスクリーンショットは英語表記ですが SharpShooter Reports JP( 日本語版 ) では日本語で表示されます

Windows Phone アプリケーション開発 設定タイルアプリケーションの作成 日本マイクロソフト株式会社 デベロッパー & プラットフォーム統括本部監修

C# ++ MASA C# ( ) XNA 1.1 C# ( ) VisualStuio XNA 4.0 VisualStuio XNA 3.1 * * *3 2.1 VisualStuio Windows ( TextGam

署名ツール検証報告書

「Android Studioではじめる 簡単Androidアプリ開発」正誤表

PLEASE READ (hidden slide)

Windows Web Windows Windows WinSock

TileView for WPF/Silverlight

目次 初めに... 3 実習用 PC... 3 USB ケーブル... 4 Visual Studio 2015 のインストール... 4.NET Micro Framework SDK のインストール... 6 Azure SDK のインストール... 9 補足 NET Micro F

untitled

LogisticaTRUCKServer-Ⅱ距離計算サーバ/Active-Xコントロール/クライアント 概略   

…E…B…U†[…h‡ðŠp‡¢‡½‚ΟbfiI…v…“…O…›…•‡Ì’¶’¬‡Ì™ñ‹Ä

GPS GPS Android GPS GPS Android 1 Android GPS Android Android GPS Android Android Android iphone Android SD GPS Android Android Android GPS SensorMana


ORiN CAO USB (3) CAO CAO USB ORiN CAO USB 1 2 (4) CAO 3 CAO USB 4 PC OS 1 CPU:Pentium IV 2. 8GHz :512MByte Windows XP SP2 Professional ORiN2 SDK USB D

WPF アプリケーションの 多言語切替

Windows Phone Mix 11

PowerPoint プレゼンテーション

untitled

Microsoft PowerPoint - Windows Presentation Foundation (WPF) 3.5 の新機能

(OnePoint) ( URL Web Copyright 2005 Microsoft Corporation. All rights reserved. Microsoft Windows Visual Basic Visual Studio Microsoft Corporation

Visual Studio 2005 Windows Mobile の 開 発 環 境 統 合 開 発 環 境 Visual Studio 2005 デスクトップと 共 通 化 された 開 発 環 境 デスクトップ 開 発 のノウハウがそのまま 利 用 可 能 高 い 開 発 生 産 性 Windo

NetCOBOL for .NET 応用編

BarCode for UWP

MISAO with WPF

付加情報をもったファイル共有システム

Visual Studio with Cordova クロスプラットフォーム開発の全貌

Excel for UWP

VB 資料 電脳梁山泊烏賊塾 音声認識 System.Speech の利用 System.Speech に依るディクテーション ( 音声を文字列化 ).NetFramework3.0 以上 (Visual Studio 2010 以降 ) では 標準で System.Speech が用意されて居るの

TM-P20 ソフトウェアユーザーズマニュアル

Visual Studio2008 C# で JAN13 バーコードイメージを作成 xbase 言語をご利用の現場でバーコードの出力が必要なことが多々あります xbase 言語製品によっては 標準でバーコード描画機能が付加されているものもあるようで す C# では バーコードフォントを利用したりバー

PowerPoint プレゼンテーション


未来を先取りした最新テクノロジー マイクロソフトの技術でロボティクス

Level1_ key

平成 29 年度卒業研究 初心者のためのゲームプログラミング用 教材の開発 函館工業高等専門学校生産システム工学科情報コース 5 年 25 番細見政央指導教員東海林智也

Prog2_12th

D:\Documents\Visual Studio 2015\Projects\MyHomePage 用サンプル \ExcelAndWord\ExcelAndWord\MainForm.cs 1 /* */ Excel や Word とやりとりする ~9,20 仕様 Excel

平成 30 年度 プログラミング研修講座 岩手県立総合教育センター

Visual Studio Do-It-Yourself シリーズ 第 1 回 Windows ゕプリケーション開発の概要 -1-

DS_BIG-IP LTM VE_jp.indd

PowerPoint プレゼンテーション

Windows PC/ BCP () PC (BYOD: Bring Your Own Device) Windows 8 2 Windows 8 Windows 8 Windows Windows 8 Windows 8 Windows 8 PC/ 2

Oracle JDeveloper 10g ADF Creation Date: Jul 07, 2004 Last Update: Jul 08, 2004 Version 1.0

Prog2_5th

00vb10-CONT-deitel.indd

超勉強会2012 MeeGoの変遷

@makoto_anjo (Computer Science) Google Desktop(Hall of Fame)

JAJP.qxd

Oracle Policy Automation 10.0システム要件

Visual Studio 2010 Ready Day ブレークアウトセッション概要

WPF Bindingの威力

PowerPoint プレゼンテーション

Prog2_10th

グラフィックス 目次

PowerPoint プレゼンテーション

untitled

ウィンドウ操作 応用

CANape Vector Japan Co., Ltd.

Windows 10 2 WaaS IT Windows 10 WaaS Windows as a Service Windows 10 WaaS IT IT IT IT 2

Max Library Size Smoke 10 Network Panel Display Default Web Browser Smoke Web Mac open Cleaner Export Destination Path Autodesk Cleaner XL Microsoft W

PC Link Tool PC Link Tool PC Link Tool PC Link Tool

XAML の勉強上要! WPF アプリケーションは作れます

Ver.2.00

PowerPoint プレゼンテーション

paper.pdf

SQL Server 2005 Line up SQL Server Mobile History Windows モバイル Embedded OS 対応 SQL Server との統合 2

XAML Do-It-Yourself シリーズ 第 1 回 XAML 概要 -1-


Prog2_2nd

Transcription:

Windows Phone によるセンサプログラミング 基応専般 太田 寛 日本マイクロソフト ( 株 ) Windows Phone とセンサ Windows Mobile 5.x Windows Mobile 6.x Windows Phone Windows Mobile OS 2010 Windows Phone 7.0 Windows Phone 7.1 2011 9 Windows Mobile Windows Phone Windows Phone 7.1 Windows Phone Windows Phone Windows Phone SDK 7.1 SDK API Windows Phone PC Windows 7 Android OS Windows Phone OS OS Windows Phone 2011 10 IS12T au 35 21 Windows Phone Windows Phone 1 表 -1 29

A-GPS GPS Accelerometer Compass Gyro 表 -1 搭載センサ一覧 Windows Phone アプリケーション C#/Visual Basic Sensors Camera Windows Phone フレームワーク Device Launchers Bing Deactivate/ t Integration & Choosers MapControl Activate FMRadio Phone Application Framework Phone Application Page Push Notification WebBrowser Control Silverlight Presentation and Media Isolated Controls Drawing Media Storage XNA Framework Input Media Content Markup Shapes Navigation Game Services Graphics Audio アプリケーションオブジェクト.NET Framework 共通基本クラスライブラリ Location Resources Globalization Net Text IO Diagnostics Configuration Security Threading Reflection Collections Component Model Runtime Service Model Linq 太字で示した, Sensors, Location は, 本稿で取り上げるライブラリを示す 図 -1 Windows Phone アプリケーションアーキテクチャ Windows Phone Windows Phone Windows Phone Windows Phone 図 -1 Windows Phone C# Visual Basic Java JVM.NET Framework Windows Phone Windows Phone Silverlight XNA Framework 30

3 Windows Phone によるセンサプログラミング Silverlight XNA Framework Windows Phone 7.1 Silverlight XNA Framework 2 Windows Phone Silverlight XNA Framework 2 Windows Phone OS Windows Phone Windows Phone Windows Phone SDK 7.1 SDK 3 SDK SDK PC Visual Studio 2010 Express for Windows Phone Windows Phone Emulator PC Emulator Expression Blend SDK for Windows Phone Application Deployment Windows Phone Developer Registration Emulator PC Windows Phone OS Windows Phone App Hub Marketplace Windows Phone 31

Accelerometer 3 Gyroscope 3 0 360 Compass 0 360 3 3 3 Motion 3 3 3 3 GeoCoordinateWatcher 表 -2 センサ関連クラスと計測可能なデータ 3 Windows Phone SDK 7.1 表 -2-2 -1 1 1 Accelerometer Gyroscope Compass -1 Accelerometer Gyro Compass Motion Accelerometer Gyro Compass 理 -2 3 図 -2 GeoCoordinateWatcher GPS 情報 Wi-Fi Web GPS 情報 -2 図 -2 センサ計測値の座標 Accelerometer Motion 4 Microsoft. 32

3 Windows Phone によるセンサプログラミング IsSupported State CurrentValue IsDataValid TimeBetweenUpdates CurrentValueChanged Start Stop CurrentValueChanged 表 -3 センサクラスのメンバ Devices.Sensors GeoCoordinateWatcher System.Device.Location 2 Windows Phone 4 センサプログラミングの基本 Accelerometer Gyroscope Compass Motion 表 -3-3 IsSupported Accelerometer 3 IsSupported true State Ready CurrentValue XXX XXXReading IsDataValid CurrentValue 理 false IsDataValid 33

TimeBetweenUpdates Windows Phone Start Stop CurrentValue Start Stop Start Stop Dispose C# Visual Basic OS 処理 Dispose 処理 Java Listener addeventlistener C# Visual Basic CurrentValueChanged CurrentValueChanged SensorReadingEven targs<xxxreading> XXXReading XXX CurrentValue センサチュートリアル C# Silverlight Windows Phone 34

3 Windows Phone によるセンサプログラミング 図 -3 Windows Phone アプリケーション開発ファイル一式 Accelerometer Visual Studio Visual Studio Visual Studio Visual C# Silverlight for Windows Phone Windows Phone OK Windows Phone OS Windows Phone OS 7.1 図 -3-3 Visual Studio MainPage.xaml Silverlight XAML XML XAML 図 -4 Visual Studio Button 2 TextBlock 1 図 -5 XAML XAML -4 Button Name Content Button buttonstart Start Button buttonend End -4 XAML 35

図 -4 MainPage.xaml とエディタ 図 -5 必要な UI コントロールの配置 XAML Start Button MainPage.xaml.cs C# buttonstart_click MainPage.xaml End Button buttonstop_click C# 処理 MainPage.xaml Button Click= Button XAML MainPage.xaml.cs buttonstart_click textblock1.text = Start ; 36

3 Windows Phone によるセンサプログラミング 図 -6 センサプログラミングに必要なコンポーネントの参照設定 buttonstop_click textblock1.text = Stop ; F5 Emulator XAML Start Stop Silverlight UI Microsoft.Devices.Sensors 図 -6.NET Microsoft.Devices.Sensors OK XNA Framework Microsoft.Xna.Framework MainPage.xaml.cs namespace // Part using Microsoft.Devices.Sensors; using Microsoft.Xna.Framework; // Part public partial class MainPage : PhoneApplicationPage private Accelerometer sensor; // Part // public MainPage() InitializeComponent(); // Part sensor = new Accelerometer(); sensor.currentvaluechanged += 37

new EventHandler<SensorReadingEventArgs<AccelerometerReading>>( sensor_currentvaluechanged); // Part void sensor_currentvaluechanged(object sender, SensorReadingEventArgs<AccelerometerReading> e) // Part TextBlock Deployment.Current.Dispatcher.BeginInvoke(() => Vector3 accel = e.sensorreading.acceleration; textblock1.text = String.Format("X=0:0.000,Y=1:0.000,Z=2:0.000", accel.x, accel.y, accel.z); ); // Part private void buttonstart_click(object sender, RoutedEventArgs e) sensor.start(); private void buttonstop_click(object sender, RoutedEventArgs e) sensor.stop(); private void PhoneApplicationPage_Unloaded(object sender, RoutedEventArgs e) sensor.dispose(); MainPage.xaml.cs MainPage Part MainPage Accelerometer Part Visual Studio 理 Visual Studio MainPage() sensor Part Visual Studio XAML TextBlock Part SensorReading Timestamp Acceleration X Y Z Acceleration 38

3 Windows Phone によるセンサプログラミング 図 -7 デバッグターゲットの選択と実行開始 1 Silverlight UI Windows UI UI UI TextBlock 処理 Deployment.Current.Dispatcher.BeginInvoke(() => ); UI 処理 buttonstart_click buttonstop_click MainPage.xaml XAML 1 Unloaded PhoneApplicationPage_ Unloaded Dispose() Dispose 図 -7 Windows Phone Emulator F5 Windows Phone Emulator Emulator Start Phone Emulator >> 図 -8 Accelerometer Accelerometer Gyroscope Compass Motion CurrentValue e.sensorreading Emulator Gyroscope Compass Motion 39

図 -8 Windows Phone Emulator 環境 3 6 Sensor Checker Marketplace GeoCoordinateWatcher Compass Accelerometer Windows Phone BingMap GeoCoordinateWatcher Compass Visual Studio Silverlight for Windows Phone Windows Phone 4 Microsoft.Devices.Sensors Microsoft.Xna.Framework System.Device GeoCoordinateWatcher 40

3 Windows Phone によるセンサプログラミング Microsoft.Phone.Controls.Maps MainPage.xaml xmlns: xmlns:map Xmlns:map= Microsoft.Phone.Controls.Maps xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:map="clrnamespace:microsoft.phone.controls.maps;assembly=microsoft.phone.controls.maps" mc:ignorable="d" d:designwidth="480" d:designheight="768" xmlns:map 2 1 ContentPanel - Grid Canvas map:map Compass RotateTransform <!--ContentPanel - --> <Grid x:name="contentpanel" Grid.Row="1" Margin="12,0,12,0"> <Canvas> <map:map x:name="mymap" ZoomLevel="15" Width="400" Height="400" Canvas.Left="28" Canvas.Top="50" CredentialsProvider="CredentialKey"> <map:map.rendertransform> <RotateTransform x:name="maprotation" CenterX="200" CenterY="200" Angle="0"/> </map:map.rendertransform> </map:map> </Canvas> </Grid> BingMap CredentialKey http://www.bingmapsportal.com/ MainPage.xaml.cs 41

using System.Device.Location; using Microsoft.Devices.Sensors; using Microsoft.Xna.Framework; using Microsoft.Phone.Controls.Maps; public partial class MainPage : PhoneApplicationPage private Compass compass; private GeoCoordinateWatcher gcwatcher; // public MainPage() InitializeComponent(); if (Compass.IsSupported) compass = new Compass(); compass.currentvaluechanged += new EventHandler<SensorReadingEventArgs<CompassReading>>( compass_currentvaluechanged); compass.start(); gcwatcher = new GeoCoordinateWatcher(); gcwatcher.positionchanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>( gcwatcher_positionchanged); gcwatcher.start(); // Part void gcwatcher_positionchanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) Deployment.Current.Dispatcher.BeginInvoke(() => mymap.center = e.position.location; ); // Part // Part void compass_currentvaluechanged( object sender, SensorReadingEventArgs<CompassReading> e) Deployment.Current.Dispatcher.BeginInvoke(() => maprotation.angle = 360 - e.sensorreading.trueheading; ); // Part private void PhoneApplicationPage_Unloaded(object sender, RoutedEventArgs e) if (compass!= null) compass.stop(); compass.dispose(); gcwatcher.stop(); gcwatcher.dispose(); 42

3 Windows Phone によるセンサプログラミング 図 -9 Windows Phone Emulator 環境 Accelerometer mymap maprotation MainPage.xaml map:map RotationTransform x:name XAML C# GeoCoordinateWatcher 情報 Position.Location mymap Center Part Compass SensorReading. TrueHeading maprotation Angle Part Map RotationTransform 2 Silverlight XNA Framework 3D Windows Phone SDK 7.1 Unloaded F5 図 -9 BingMap Emulator Windows Phone SDK 7.1 43

Map http://www.bing.com UI UI Emulator Compass USB PC PC Windows Phone Zune PC PC Visual Studio Windows Phone Device F5 図 -10 Compass Emulator Compass Compass 2 IS02T 25ms if (Compass.IsSupported) compass = new Compass(); compass.currentvaluechanged += new EventHandler<SensorReadingEventArgs<CompassReading>>( compass_currentvaluechanged); compass.timebetweenupdates = TimeSpan.FromSeconds(2); compass.start(); 2 Compass_CurrentValueChanged BeginInvoke 図 -10 実端末での実行 44

3 Windows Phone によるセンサプログラミング Deployment.Current.Dispatcher.BeginInvoke(() => Duration duration = new Duration(TimeSpan.FromSeconds(1)); DoubleAnimation animation = new DoubleAnimation(); animation.duration = duration; animation.to = e.sensorreading.trueheading; Storyboard sb = new Storyboard(); sb.children.add(animation); sb.duration = duration; Storyboard.SetTarget(animation, maprotation); Storyboard.SetTargetProperty( animation, new PropertyPath(RotateTransform.AngleProperty)); sb.begin(); ); DoubleAnimation StoryBoard 2 1 Windows Phone Emulator API 6 5 Windows Phone 情報 参考文献 1 Windows Phone 7.1 Hardware Specification http://msdn.microsoft.com/en-us/library/ff637514(v=vs.92). aspx 2 Fundamental Concepts for Windows Phone http://msdn.microsoft.com/en-us/library/ff967549(v=vs.92). aspx 3 Windows Phone http://msdn.microsoft.com/ja-jp/windowsphone/ 4 Windows Phone Class Library Reference http://msdn.microsoft.com/en-us/library/ff626516(v=vs.92).aspx 5 UX UX-TV http://msdn.microsoft.com/ja-jp/hh162048 6 http://blogs.msdn.com/hirosho/ 2011 10 17 太田寛 hirosho@microsoft.com 45