Universal windows platformの新機能をおさえよう
-
Upload
makoto-nishimura -
Category
Technology
-
view
2.782 -
download
0
Transcript of Universal windows platformの新機能をおさえよう
![Page 1: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/1.jpg)
U W P のののののののののの
古代魚庵西村誠
Universal Windows Platform
![Page 2: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/2.jpg)
概要UWP(Win10) とストアアプリ (Win8.x)2 つのアプリプラットフォームの違いについてUWP の特徴である複数のプラットフォームに対応する方法
![Page 3: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/3.jpg)
お品書き・ストアアプリ≒ UWP
・様々なデバイスに対応する・各デバイスの拡張を知る
![Page 4: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/4.jpg)
ストアアプリ≒ UWP
![Page 5: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/5.jpg)
ストアアプリ・ Windows 8.x で登場・新しい API WinRT(ARM 対応の OS じゃないよ )
・タッチ対応の UI
・ストアからの配布
ちょっとややこしい・・・。 API の名前の方。 ARM 対応の方の WinRT は普及しませんでしたね
Windows 7 以前の OS では動作しない
全画面で起動するなどマウス & キーボー操作だと不便な点も
![Page 6: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/6.jpg)
ストアアプリ・ PC( 主にタブレット ) と Mobile 向け・もともと Windows Phone 向けの API が進化・ Windows 10 でも動くよ・画面は XAML( 画面定義 ) +コード
Silverlight ベースから WinRT へ。 Windows Phone の API も色々歴史がありました
この頃、 Windows Phone は日本で・・・
DirectX で画面を描画する場合とコードが JS の場合は別。コードは C# 、 VB 、 C++ 、 JS
![Page 7: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/7.jpg)
ストアアプリ・ 2 プロジェクト 1 共通プロジェクト・ 2 バイナリ
PC 用と電話用のプロジェクト+ Shared プロジェクトでコードを共有。
バイナリレベルでは別物
![Page 8: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/8.jpg)
UWP・ Windows 10 から登場したプラットフォーム・ストアアプリの進化形・ Windows 10 なら動く・ XAML+ コードなのは同様
違いもあるけど、動作モデルや API はおおむね共通。おおむねというのが曲者(あるある)
または動作するアプリケーションを UWP 、 UWP アプリと呼びます
PC 、タブレット、 IoT 、スマフォなどなど。 Xbox One でも動く予定・・・予定・・・買ったのに・・・
XAML は HTML のようなマークアップ言語
![Page 9: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/9.jpg)
ののの
・ 1 プロジェクト・ 1 バイナリ・ Windows Phone 7 から始まる長い歴史が・・・・コントロールが 2 つ増えた
ストアアプリとコードを共有したい場合は +Shared プロジェクト
バイナリレベルで同じもの(もちろん CPU アーキテクチャレベルでは別)
Silverlight ベースの電話と、 WinRT なストアアプリから始まって・・・いや、昔話はするまい
SplitView と RelativePanel というレスポンシブ向けのコントロール
![Page 10: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/10.jpg)
Windows 10 なら
https://doc.co/nzBEox
![Page 11: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/11.jpg)
デスクトップ・ PC 、タブレット向けの Windows 10
・ストアアプリからの移植も容易スマフォ版は UI 部分などたまにはまりどころがある
![Page 12: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/12.jpg)
モバイル・ Windows 10 Mobile
・ Windows Phone 向け日本発売おめでとう‼
![Page 13: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/13.jpg)
IoT・ Windows 10 IoT
・ Raspberry Pi 2 などで動作・組み込み機器で Visual Studio 開発
たまに古い Raspberry Pi を買って泣く人が・・・
これは個人的に新鮮な体験
![Page 14: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/14.jpg)
未登場・ Xbox One とか Surface タブとか、 HoloLendsとか来るよね!! 将来的には Microsoft Band でも(これは、ただの願望)
![Page 15: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/15.jpg)
ストアアプリ≒ UWP・大きな違いは UWP は色々なデバイスで動く・ UWP は Windows 10 以降限定・ストアから配布などが不要なら WPF や WFも
大きな利点もこれ
ターゲットの OS に Windows 8.x を含める?
枯れているだけにノウハウや、商用コントロールなどが充実。サンドボックスが無いのも
![Page 16: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/16.jpg)
様々なデバイスに対応するここからは開発のお話し
![Page 17: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/17.jpg)
コードでデバイス判定・ AnalyticsInfo.VersionInfo.DeviceFamily
・以下の文字列が取得できる要 :using Windows.System.Profile;
Windows IoT の場合” Windows.IoT”
Windows DeskTop の場合” Windows.Desktop”
Windows Mobile の場合” Windows.Mobile”
![Page 18: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/18.jpg)
コードで機能を判定・特定の機能が利用可能か調べる・コード
Windows Phone のハードウェアボタンとか、デバイス固有の機能
using Windows.Foundation.Metadata;・・・ bool isHWButton = ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");
S
![Page 19: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/19.jpg)
コードで機能を判定・ IsTypePresent 以外にも
・いやいやもっと
IsEventPresentIsMethodPresentIsPropertyPresent
IsApiContractPresent
IsEnumNamdValuePresent
IsReadOnlyPropertyPresent
IsWriteablePropertyPresent
![Page 20: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/20.jpg)
コードで機能を判定・ストアアプリと同様の判定をする場合も・コード
例えば、 Windows Phono のカメラとかはストアアプリの頃と同じ書き方・・・
var compass = Compass.GetDefault();
if (compass != null)
{
System.Diagnostics.Debug.WriteLine(" コンパスがある場合の処理");
}
![Page 21: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/21.jpg)
コードで機能を判定・ストアアプリと同様の判定をする場合も
・ DEMO : Accelerometer
例えば、 Windows Phono のカメラとかはストアアプリの頃と同じ書き方・・・
![Page 22: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/22.jpg)
コードで分岐・ UWP と Windows Pone 、ストアアプリを判定 ・コード
Shared Project でコードを共有したい場合など #if WINDOWS_UWP
// UWP の場合 // さらに PC か電話かを判定する場合 var isMobile = VersionInfo.DeviceFamily == "Windows.Mobile";
#endif
#if WINDOWS_PHONE_APP
// Windows Phone 8.1 の場合 #endif
#if WINDOWS_APP
// Windows 8.1 の場合 #endif
![Page 23: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/23.jpg)
コードで分岐・ UWP と Windows Pone 、ストアアプリを判定
・ DEMO : ifdef
Shared Project でコードを共有したい場合など
![Page 24: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/24.jpg)
コードで分岐・文字列を忘れたらコンパイルシンボルで プロジェクトのプロパティ→ビルド。 UWP の場合
![Page 25: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/25.jpg)
コードで分岐・文字列を忘れたらコンパイルシンボルで 試しに変えてみよう
![Page 26: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/26.jpg)
画面について・策 1. デバイスにこだわらず画面幅で判定・ AdaptiveTrigger
画面の横幅でレイアウトを変更
<VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState> <VisualState.StateTriggers> <AdaptiveTrigger MinWindowWidth="720" /> </VisualState.StateTriggers> <VisualState.Setters> <Setter Target="MySplitView.DisplayMode" Value="Overlay" />
![Page 27: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/27.jpg)
画面について・策 1. デバイスにこだわらず画面幅で判定
DEMO : XamlResponsiveTechniques
画面の横幅でレイアウトを変更
![Page 28: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/28.jpg)
画面について・策 2. デバイスファミリーで分岐・ XAML をそれぞれ用意
画面の横幅でレイアウトを変更
![Page 29: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/29.jpg)
各デバイスの拡張を知るデバイス固有の拡張を利用する
![Page 30: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/30.jpg)
拡張 (Extention)・デバイスファミリー固有の機能は参照から
ソリューションエクスプローラーの「参照」を右クリックから「参照の追加」!!
![Page 31: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/31.jpg)
拡張 ()
・ ~ Extensions for the UWPなんか Windows 10 のビルド番号毎に拡張がある気がするけど、今は気にしないぜ・・・
![Page 32: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/32.jpg)
拡張 ()
・ ~ Extensions for the UWP
Windows Desktop Extensions for the UWPWindows IoT Extensions for the UWPWindows Mobile Extensions for the UWPWindows Team Extensions for the UWP
![Page 33: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/33.jpg)
拡張 ()
・追加してみる参照に追加された
![Page 34: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/34.jpg)
拡張 ()
・エラーになる?・デスクトップ拡張の機能を追加して IoT で実行
参照に追加しただけなら OK 。機能を使うとエラー。
![Page 35: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/35.jpg)
拡張 ()
・中身は?
・主な中身は SDKManifest.xml と IDL(or .h)
以下の URL にあるよ C:\Program Files (x86)\Windows Kits\10\Extension SDKs\
IDL はインターフェイス定義ファイル
![Page 36: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/36.jpg)
拡張 -
・ SDKManifest.xml から中身が推測できそう
・上の API が使えるようになる
例えば IoT の場合・・・
<ContainedApiContracts>
<ApiContract name="Windows.Devices.DevicesLowLevelContract" version="2.0.0.0"/>
<ApiContract name="Windows.System.SystemManagementContract" version="2.0.0.0"/>
</ContainedApiContracts>
拡張を追加してない場合はコードクラスが参照できずエラー
![Page 37: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/37.jpg)
拡張のののの・ DevicesLowLevelContract
Adc って何かなー( Analog-Digital Converter ・・・だそうです・・・)I2c って何かなー
![Page 38: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/38.jpg)
拡張のののの・ DevicesLowLevelContract
Adc って何かなー( Analog-Digital Converter )I2c って何かなー(たぶん、これ→)
![Page 39: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/39.jpg)
拡張ののののごめん・・・IoT 用語わからん・・・
![Page 40: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/40.jpg)
拡張ののののののの・気を取り直して Mobile
・以下が追加されますIoT はハードル高いけど追加される拡張が少ないので把握はしやすいかな
次のスライドへ・・・
![Page 41: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/41.jpg)
<ApiContract name="Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract" version="1.0.0.0"/>
<ApiContract name="Windows.ApplicationModel.Calls.Background.CallsBackgroundContract" version="1.0.0.0"/>
<ApiContract name="Windows.ApplicationModel.Calls.CallsPhoneContract" version="2.0.0.0"/>
<ApiContract name="Windows.ApplicationModel.SocialInfo.SocialInfoContract" version="1.0.0.0"/>
<ApiContract name="Windows.ApplicationModel.CommunicationBlocking.CommunicationBlockingContract" version="1.0.0.0"/>
<ApiContract name="Windows.ApplicationModel.Wallet.WalletContract" version="1.0.0.0"/>
<ApiContract name="Windows.Devices.SmartCards.SmartCardBackgroundTriggerContract" version="1.0.0.0"/>
<ApiContract name="Windows.Devices.SmartCards.SmartCardEmulatorContract" version="2.0.0.0"/>
<ApiContract name="Windows.Embedded.DeviceLockdown.DeviceLockdownContract" version="1.0.0.0"/>
<ApiContract name="Windows.Gaming.Preview.GamesEnumerationContract" version="1.0.0.0"/>
<ApiContract name="Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract" version="1.0.0.0"/>
<ApiContract name="Windows.Networking.Sockets.ControlChannelTriggerContract" version="1.0.0.0"/>
<ApiContract name="Windows.Phone.PhoneContract" version="1.0.0.0"/>
<ApiContract name="Windows.Phone.StartScreen.DualSimTileContract" version="1.0.0.0"/>
<ApiContract name="Windows.Services.Maps.GuidanceContract" version="2.0.0.0"/>
<ApiContract name="Windows.Services.Maps.LocalSearchContract" version="2.0.0.0"/>
<ApiContract name="Windows.Security.EnterpriseData.EnterpriseDataContract" version="2.0.0.0"/>
<ApiContract name="Windows.System.Profile.ProfileHardwareTokenContract" version="1.0.0.0"/>
<ApiContract name="Windows.System.Profile.ProfileRetailInfoContract" version="1.0.0.0"/>
<ApiContract name="Windows.System.UserProfile.UserProfileContract" version="1.0.0.0"/>
<ApiContract name="Windows.UI.WebUI.Core.WebUICommandBarContract" version="1.0.0.0"/>
![Page 42: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/42.jpg)
拡張ののののののの・いくつか抜粋ちょっと推測まじり・・・
Calls.Background.CallsBackgroundContract
Calls.CallsPhoneContract
アプリから電話をコールしたり、コールをトリガーするための API
Windows.ApplicationModel.SocialInfo.SocialInfoContract
たぶん SNS連携的な・・・
![Page 43: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/43.jpg)
拡張ののののののの・いくつか抜粋かなり推測まじり・・・
Wallet.WalletContract
決済処理SmartCards.SmartCardBackgroundTriggerContract
SmartCards.SmartCardEmulatorContract
カードリーダーで情報を読み取る?(海外事情?)
![Page 44: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/44.jpg)
拡張のののののののの・いくつか抜粋かなり推測まじり・・・
Scanners.ScannerDeviceContract
スキャナーMedia.Capture.AppCaptureContract
Media.Capture.CameraCaptureUIContract
Web カメラなどのメディア系
![Page 45: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/45.jpg)
拡張のののののののの・いくつか抜粋かなり推測まじり・・・
Globalization.GlobalizationJapanesePhoneticAnalyzerContract
日本語音声解析Networking.Sockets.ControlChannelTriggerContract
ソケット接続周り
![Page 46: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/46.jpg)
拡張ののののの・一個だけ
・最後なのでもう少し追いかけてみるまだモノが公に出てないから、今後増えるのかも
Windows.System.Profile.ProfileSharedModeContract
![Page 47: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/47.jpg)
拡張ののののの・オブジェクトブラウザー
SharedMobeSettings クラスがある模様
![Page 48: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/48.jpg)
拡張ののののの・オブジェクトブラウザー
・ winmd の場所
SharedMobeSettings クラスがある模様
![Page 49: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/49.jpg)
拡張ののののの・ winmd を ILSpyで確認
Bool値を返すプロパティが一つ
Provides access to the settings for shared mode. For example, devices with large screens could support communal shared apps.
大画面をサポートした共有可能なアプリかを返す?(わかるような・・・)
![Page 50: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/50.jpg)
まとめ・ UWP は色々なデバイスで動作する・ UWP はデバイスや画面幅で作り分けれる・ UWP はデバイス特有の拡張も使える
だからアプリを作ろう
だからアプリを作ろう
だからアプリを作ろう
![Page 51: Universal windows platformの新機能をおさえよう](https://reader036.fdocument.pub/reader036/viewer/2022062412/5870f84c1a28ab5f528b51bf/html5/thumbnails/51.jpg)
御静聴ありがとうございました