今度は Microsoft Band の着せ替え機能で壁紙を設定してみます
ソースコードの一式は下記にあります!
細かい実装などはこちらを参照ください
※ 順次改修していく予定なので、この記事の内容が現時点のソースより古い可能性があります
BandImage の変換クラスがあればあまり修正しなくて済みます
まずは NativePersonalizationManager を改修
/// <summary> /// iOS 用着せ替え管理クラス /// </summary> public class NativeBandPersonalizationManager : IBandPersonalizationImageManager { ~ 中略 ~ /// <summary> /// 壁紙の設定 /// </summary> /// <param name="stream">壁紙画像の入力ストリーム</param> /// <returns>Task</returns> public async Task SetMeTileImageSourceAsync(StreamImageSource source) { await Native.Personalization.BandPersonalizationManagerExtensions.SetMeTileImageTaskAsync( this.manager, await NativeBandImageConvert.ToNative(source)); } ~ 中略 ~ }
またも Android や Windows Phone もほぼ同じです
次に ViewModel
/// <summary> /// 着せ替え設定 ViewModel /// </summary> public class PersonalizeViewModel : BindableBase { ~ 中略 ~ /// <summary> /// 設定適用 /// </summary> /// <returns>Task</returns> private async Task Apply() { this.IsBusy = true; var theme = new BandTheme() { Base = StringToColor(this.BaseColor.Color), HighContrast = StringToColor(this.HighContrastColor.Color), Highlight = StringToColor(this.HighlightColor.Color), Lowlight = StringToColor(this.LowlightColor.Color), Muted = StringToColor(this.MutedColor.Color), SecondaryText = StringToColor(this.SecondaryTextColor.Color), }; await this.manager.SetThemeAsync(theme); var source = this.meTileImageSource as StreamImageSource; if (source != null) { await this.manager.SetMeTileImageSourceAsync(source); } this.IsBusy = false; } }
これだけ!・・・さっそく試してみます
オレンジテーマカラー&猫足跡の壁紙で Apply ボタン押下
Syncing... のメッセージが表示され少し時間が経ったあと、ちゃんと足跡つき壁紙にできました!