public static Task <string> GetFirmwareVersionTaskAsync(this BandClient client) { var tcs = new TaskCompletionSource <string> (); client.GetFirmwareVersionAsync(tcs.AttachCompletionHandler()); return(tcs.Task); }
public NotificationsPage(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { InitializeComponent(); ViewModel = new NotificationsViewModel(info, bandClient, tile); }
async partial void ConnectToBandClick (UIButton sender) { if (client == null) { // get the client client = manager.AttachedClients.FirstOrDefault (); if (client == null) { Output ("Failed! No Bands attached."); } else { // attach event handlers client.ButtonPressed += (_, e) => { Output (string.Format ("Button {0} Pressed: {1}", e.TileButtonEvent.ElementId, e.TileButtonEvent.TileName)); }; client.TileOpened += (_, e) => { Output (string.Format ("Tile Opened: {0}", e.TileEvent.TileName)); }; client.TileClosed += (_, e) => { Output (string.Format ("Tile Closed: {0}", e.TileEvent.TileName)); }; try { Output ("Please wait. Connecting to Band..."); await manager.ConnectTaskAsync (client); } catch (BandException ex) { Output ("Failed to connect to Band:"); Output (ex.Message); } } } else { Output ("Please wait. Disconnecting from Band..."); await manager.DisconnectTaskAsync (client); client = null; } }
protected override void StopListening() { // disconnect the contact event for non-contact probes. this probe has already been marked as non-running, so // there's no risk of a race condition in which the contact state changes to worn and the change event attempts // to restart this probe after it has been stopped (we check Running during the change event). if (!(this is MicrosoftBandContactProbe)) { MicrosoftBandContactProbe contactProbe = Protocol.Probes.Single(probe => probe is MicrosoftBandContactProbe) as MicrosoftBandContactProbe; contactProbe.ContactStateChanged -= ContactStateChanged; } StopReadings(); // only cancel the static health test if none of the band probes should be running. if (BandProbesThatShouldBeRunning.Count == 0) { CancelHealthTest(); } // disconnect the client if no band probes are actually running. if (BandProbesThatAreRunning.Count == 0 && (BandClient?.IsConnected ?? false)) { try { SensusServiceHelper.Get().Logger.Log("All Band probes have stopped. Disconnecting client.", LoggingLevel.Normal, GetType()); BandClient.DisconnectAsync().Wait(); BandClient = null; } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Failed to disconnect client: " + ex.Message, LoggingLevel.Normal, GetType()); } } }
public SensorsPage(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { InitializeComponent(); ViewModel = new SensorsViewModel(BandInfo, BandClient); }
protected override void StopListening() { StopReadings(); // only cancel the static health test if none of the band probes should be running. if (BandProbesThatShouldBeRunning.Count == 0) { CancelHealthTest(); } // disconnect the client if no band probes are actually running. if (BandProbesThatAreRunning.Count == 0 && (BandClient?.IsConnected ?? false)) { try { SensusServiceHelper.Get().Logger.Log("All Band probes have stopped. Disconnecting client.", LoggingLevel.Normal, GetType()); BandClient.DisconnectAsync().Wait(); BandClient = null; } catch (Exception ex) { SensusServiceHelper.Get().Logger.Log("Failed to disconnect client: " + ex.Message, LoggingLevel.Normal, GetType()); } } }
public async Task <String> ConnectToBand(BandDeviceInfo b) { band = b; bandClient = await bandClientManager.ConnectAsync(band); return(String.Format("connected to {0} !", band.Name)); }
public async Task <OAuth2AccessToken> RefreshTokenAsync(BandClient client) { string postUrl = BandOauthPostUrl; var content = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("grant_type", "refresh_token"), new KeyValuePair <string, string>("refresh_token", client.AccessToken.RefreshToken), }); HttpClient httpClient; if (client.HttpClient == null) { httpClient = new HttpClient(); } else { httpClient = client.HttpClient; } var clientIdConcatSecret = OAuth2Helper.Base64Encode(client.AppCredentials.ClientId + ":" + client.AppCredentials.ClientSecret); httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", clientIdConcatSecret); HttpResponseMessage response = await httpClient.PostAsync(postUrl, content); string responseString = await response.Content.ReadAsStringAsync(); return(OAuth2Helper.ParseAccessTokenResponse(responseString)); }
async partial void ConnectToBandClick(UIButton sender) { if (client == null) { // get the client client = manager.AttachedClients.FirstOrDefault(); if (client == null) { Output("Failed! No Bands attached."); } else { try { Output("Please wait. Connecting to Band..."); await manager.ConnectTaskAsync(client); Output("Band connected."); } catch (BandException ex) { Output("Failed to connect to Band:"); Output(ex.Message); } } } else { Output("Please wait. Disconnecting from Band..."); await manager.DisconnectTaskAsync(client); Output("Band disconnected."); } }
public PersonalizationPage(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { InitializeComponent(); personalizationViewModel = new PersonalizationViewModel(info, bandClient); ViewModel = personalizationViewModel; }
public SensorsViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { sensorManager = bandClient.SensorManager; Sensors = new ObservableCollection <BaseViewModel>(); Init(); }
public override async Task Destroy() { await base.Destroy(); await BandClient.TileManager.StopEventListenersAsync(); await BandClient.DisconnectAsync(); }
public async Task <int> StartBandMonitor() { _waveGesture.WaveDetected += (sender, e) => { var eh = MoveNextGesture; if (eh != null) { eh(sender, e); } }; _waveGesture.ReverseWaveDetected += (sender, e) => { var eh = MovePrevGesture; if (eh != null) { eh(sender, e); } }; // Get the list of Microsoft Bands paired to the phone. var pairedBands = await BandClientManager.Instance.GetPairedBandsAsync(); if (pairedBands.Count() < 1) { await _parentPage.DisplayAlert("No Bands", "Unable to find a Band to connect to.", "Ok"); return(0); } // Connect to Microsoft Band. _bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands.First()); Debug.WriteLine("Band found"); var sensors = _bandClient.SensorManager; //sensors.Gyroscope.ReportingInterval = sensors.Gyroscope.SupportedReportingIntervals.Min(); sensors.Accelerometer.ReadingChanged += (s, args) => { _waveGesture.AddAccelerometerReading(args.SensorReading); //EventHubsInterface.SendAccelerometerReading(args.SensorReading); }; sensors.Gyroscope.ReadingChanged += (sender, e) => { _waveGesture.AddGyroscopeReading(e.SensorReading); }; //SensorStatusTextBlock.Text = "Initialized!"; //Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Green); await sensors.Accelerometer.StartReadingsAsync(Microsoft.Band.Portable.Sensors.BandSensorSampleRate.Ms16); //await sensors.Gyroscope.StartReadingsAsync (Microsoft.Band.Portable.Sensors.BandSensorSampleRate.Ms16); Debug.WriteLine("Sensor reads requested"); return(0); }
public VibrationsViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { notifiactionManager = bandClient.NotificationManager; VibrateCommand = new Command(async () => { await notifiactionManager.VibrateAsync((VibrationType)vibrationIndex); }); }
public VibrationsViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { notifiactionManager = bandClient.NotificationManager; VibrateCommand = new Command(async() => { await notifiactionManager.VibrateAsync((VibrationType)vibrationIndex); }); }
public static Task ConnectTaskAsync(this BandClientManager manager, BandClient client) { var tcs = new TaskCompletionSource <object> (); EventHandler <ClientManagerConnectedEventArgs> onConnected = null; EventHandler <ClientManagerDisconnectedEventArgs> onDisconnect = null; EventHandler <ClientManagerFailedToConnectEventArgs> onFailed = null; // setup the completed event onConnected = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we are finished tcs.SetResult(null); } }; manager.Connected += onConnected; // setup the canceled event onDisconnect = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we were canceled tcs.SetCanceled(); } }; manager.Disconnected += onDisconnect; // setup the failed event onFailed = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we failed tcs.SetException(new BandException(args.Error)); } }; manager.ConnectionFailed += onFailed; // run async manager.ConnectAsync(client); return(tcs.Task); }
public AddTilePage(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { InitializeComponent(); addTileViewModel = new AddTileViewModel(info, bandClient, tile); Init(); ViewModel = addTileViewModel; }
public VibrationsPage(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { InitializeComponent(); ViewModel = new VibrationsViewModel(info, bandClient); foreach (var type in VibrationsViewModel.GetVibrationTypes()) { vibrationTypesPicker.Items.Add(type); } }
public static Task ConnectTaskAsync (this BandClientManager manager, BandClient client) { var tcs = new TaskCompletionSource<object> (); EventHandler<ClientManagerConnectedEventArgs> onConnected = null; EventHandler<ClientManagerDisconnectedEventArgs> onDisconnect = null; EventHandler<ClientManagerFailedToConnectEventArgs> onFailed = null; // setup the completed event onConnected = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we are finished tcs.SetResult (null); } }; manager.Connected += onConnected; // setup the canceled event onDisconnect = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we were canceled tcs.SetCanceled(); } }; manager.Disconnected += onDisconnect; // setup the failed event onFailed = (sender, args) => { if (args.Client == client) { manager.Connected -= onConnected; manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we failed tcs.SetException (new BandException(args.Error)); } }; manager.ConnectionFailed += onFailed; // run async manager.ConnectAsync (client); return tcs.Task; }
async public override void ReceivedRemoteNotification(UIApplication application, NSDictionary userInfo) { if (null != userInfo && userInfo.ContainsKey(new NSString("aps"))) { NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary; string alert = string.Empty; if (aps.ContainsKey(new NSString("alert"))) { var nsString = aps[new NSString("alert")] as NSString; if (nsString != null) { alert = nsString.ToString(); } } if (!string.IsNullOrEmpty(alert)) { //Show a pop-up if the application is open UIAlertView avAlert = new UIAlertView("CRM Item", alert, null, "OK", null); avAlert.Show(); BandClient client = MainViewController.GetClient(); //Connect to Band if not already connected if (client == null) { try { BandClientManager manager = MainViewController.GetManager(); client = manager.AttachedClients.FirstOrDefault(); if (client == null) { return; } client = MainViewController.GetClient(); } catch (BandException) { } } if (client == null) { return; } //Send to Band await client.NotificationManager.SendMessageTaskAsync(MainViewController.GetTileId(), "CRM Item", alert, DateTime.Now, true); } } }
public async Task <ActionResult> Callback(string code) { var authenticator = new OAuth2Helper(_appCredentials, ConfigurationManager.AppSettings["BaseUrl"] + "/band/callback"); OAuth2AccessToken accessToken = await authenticator.ExchangeAuthCodeForAccessTokenAsync(code); if (!string.IsNullOrEmpty(accessToken.Token)) { _bandClient = GetBandClient(accessToken); } return(RedirectToAction("Profile")); }
public StartTimeService(DiscordSocketClient client, BandClient band, DatabaseService database, ClashClient clash) { _client = client; _band = band; _database = database; _clash = clash; _tokenSource = new CancellationTokenSource(); _client.ReactionAdded += async(cache, channel, reaction) => { if (cache.Id != _lastMessage?.Id || reaction.UserId == _client.CurrentUser.Id) { return; } var user = await _client.GetOrFetchUserAsync(reaction.UserId); switch (reaction.Emote.Name) { case "✅": await channel.SendMessageAsync(string.Empty, embed : new EmbedBuilder { Description = $"{user.Mention} can start war", Color = Color.Green } .Build()); break; case "❌": await channel.SendMessageAsync(string.Empty, embed : new EmbedBuilder { Description = $"{user.Mention} cannot start war", Color = Color.Red } .Build()); break; case "⚠": await channel.SendMessageAsync(string.Empty, embed : new EmbedBuilder { Description = $"{user.Mention} can maybe start war", Color = Color.Orange } .Build()); break; } }; }
internal BandSensorManager(BandClient client, NativeBandSensorManager sensorManager) { this.Native = sensorManager; this.client = client; this.accelerometer = new Lazy <BandAccelerometerSensor>(() => new BandAccelerometerSensor(this)); this.contact = new Lazy <BandContactSensor>(() => new BandContactSensor(this)); this.distance = new Lazy <BandDistanceSensor>(() => new BandDistanceSensor(this)); this.gyroscope = new Lazy <BandGyroscopeSensor>(() => new BandGyroscopeSensor(this)); this.heartRate = new Lazy <BandHeartRateSensor>(() => new BandHeartRateSensor(this)); this.pedometer = new Lazy <BandPedometerSensor>(() => new BandPedometerSensor(this)); this.skinTemperature = new Lazy <BandSkinTemperatureSensor>(() => new BandSkinTemperatureSensor(this)); this.ultravioletLight = new Lazy <BandUltravioletLightSensor>(() => new BandUltravioletLightSensor(this)); }
/// <summary> /// HttpClient and hence FitbitClient are designed to be long-lived for the duration of the session. This method ensures only one client is created for the duration of the session. /// More info at: http://stackoverflow.com/questions/22560971/what-is-the-overhead-of-creating-a-new-httpclient-per-call-in-a-webapi-client /// </summary> /// <returns></returns> private BandClient GetBandClient(OAuth2AccessToken accessToken = null) { if (Session["BandClient"] == null) { if (accessToken != null) { BandClient client = new BandClient(_appCredentials, accessToken); Session["BandClient"] = client; return(client); } //throw new Exception("First time requesting a BandClient from the session you must pass the AccessToken."); return(null); } return((BandClient)Session["BandClient"]); }
internal BandSensorManager(BandClient client, NativeBandSensorManager sensorManager) { this.Native = sensorManager; this.client = client; this.accelerometer = new Lazy<BandAccelerometerSensor>(() => new BandAccelerometerSensor(this)); this.calories = new Lazy<BandCaloriesSensor>(() => new BandCaloriesSensor(this)); this.contact = new Lazy<BandContactSensor>(() => new BandContactSensor(this)); this.distance = new Lazy<BandDistanceSensor>(() => new BandDistanceSensor(this)); this.gyroscope = new Lazy<BandGyroscopeSensor>(() => new BandGyroscopeSensor(this)); this.heartRate = new Lazy<BandHeartRateSensor>(() => new BandHeartRateSensor(this)); this.pedometer = new Lazy<BandPedometerSensor>(() => new BandPedometerSensor(this)); this.skinTemperature = new Lazy<BandSkinTemperatureSensor>(() => new BandSkinTemperatureSensor(this)); this.ultravioletLight = new Lazy<BandUltravioletLightSensor>(() => new BandUltravioletLightSensor(this)); }
private async Task setupBand() { band = clientViewModel.BandClient; var newTiles = (await band.TileManager.GetTilesAsync()); foreach (var item in newTiles) { if (item.Name == "New Tile") { tile = item; } } //Debug.WriteLine("loading tiles"); //tile = newTiles.Where(n => newTiles.All(o => o.Name == "New Tile")).First(); //Debug.WriteLine("found tile"); }
public override async Task Prepare() { if (BandClient == null) { BandClient = await BandClientManager.Instance.ConnectAsync(BandInfo); } await base.Prepare(); FirmwareVersion = await BandClient.GetFirmwareVersionAsync(); OnPropertyChanged("FirmwareVersion"); HardwareVersion = await BandClient.GetHardwareVersionAsync(); OnPropertyChanged("HardwareVersion"); }
public static Task DisconnectTaskAsync(this BandClientManager manager, BandClient client) { // short circuit becuase if we are already disconnected // then the delegate won't get fired if (!client.IsConnected) { return(Task.FromResult <object> (null)); } var tcs = new TaskCompletionSource <object> (); EventHandler <ClientManagerDisconnectedEventArgs> onDisconnect = null; EventHandler <ClientManagerFailedToConnectEventArgs> onFailed = null; // setup the disconnected event onDisconnect = (sender, args) => { if (args.Client == client) { manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we were disconnected (success) tcs.SetResult(null); } }; manager.Disconnected += onDisconnect; // setup the failed event onFailed = (sender, args) => { if (args.Client == client) { manager.Disconnected -= onDisconnect; manager.ConnectionFailed -= onFailed; // we failed tcs.SetException(new BandException(args.Error)); } }; manager.ConnectionFailed += onFailed; // run async manager.DisconnectAsync(client); return(tcs.Task); }
public AddTileViewModel(BandDeviceInfo info, BandClient bandClient, BandTile tile) : this(info, bandClient) { TileId = tile.Id.ToString("D"); TileName = tile.Name; TileIcon = tile.Icon; AllowBadging = tile.SmallIcon != null; TileBadge = tile.SmallIcon; if (tile.Theme != default(BandTheme)) { UseCustomTheme = true; TileTheme = tile.Theme; } else { TileTheme = App.DefaultTheme; } }
public TilesPage(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { InitializeComponent(); var addTile = new ToolbarItem { Text = "Add", Icon = OnPlatform( iOS: (FileImageSource)FileImageSource.FromFile("Icons/Add.png"), Android: (FileImageSource)FileImageSource.FromFile("Add.png"), Windows: (FileImageSource)FileImageSource.FromFile("Assets/Icons/Add.png")) }; addTile.Clicked += AddTileButtonClicked; ToolbarItems.Add(addTile); ViewModel = new TilesViewModel(info, bandClient); }
public AddTileViewModel(BandDeviceInfo info, BandClient bandClient, BandTile tile) : this(info, bandClient) { TileId = tile.Id.ToString("D"); TileName = tile.Name; TileIcon = tile.Icon; TileBadge = tile.SmallIcon; DisableScreenTimeout = tile.IsScreenTimeoutDisabled; if (tile.Theme != BandTheme.Empty) { UseCustomTheme = true; TileTheme = tile.Theme; } else { TileTheme = App.DefaultTheme; } }
public NotificationsViewModel(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { notifiactionManager = bandClient.NotificationManager; this.tile = tile; SendMessageCommand = new Command(async () => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now); }); SendMessageWithDialogCommand = new Command(async () => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now, true); }); ShowDialogCommand = new Command(async () => { await notifiactionManager.ShowDialogAsync(tile.Id, Title, Body); }); }
public static async Task Init() { var BandClientManager = Microsoft.Band.Portable.BandClientManager.Instance; var pairedBands = await BandClientManager.GetPairedBandsAsync(); try { BandClient = await BandClientManager.ConnectAsync(pairedBands.First()); { await RequestConsent(); GetSensorValue(); } } catch (Exception ex) { } }
public NotificationsViewModel(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { notifiactionManager = bandClient.NotificationManager; this.tile = tile; SendMessageCommand = new Command(async() => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now); }); SendMessageWithDialogCommand = new Command(async() => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now, true); }); ShowDialogCommand = new Command(async() => { await notifiactionManager.ShowDialogAsync(tile.Id, Title, Body); }); }
public async Task <bool> ConnectToBand(BandDeviceInfo b, User user) { band = b; try { this.user = user; bandClient = await bandClientManager.ConnectAsync(band); } catch (Exception ex) { String.Format("Exception: " + ex); return(false); } if (bandClient != null) { return(true); } return(false); }
public PersonalizationViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { personalizationManager = bandClient.PersonalizationManager; GetBandThemeCommand = new Command(async () => { BandTheme = await personalizationManager.GetThemeAsync(); }); DefaultBandThemeCommand = new Command(() => { BandTheme = App.DefaultTheme; }); SetBandThemeCommand = new Command(async () => { await personalizationManager.SetThemeAsync(BandTheme); }); GetMeTileImageCommand = new Command(async () => { MeTileImage = await personalizationManager.GetMeTileImageAsync(); }); DefaultMeTileImageCommand = new Command(async () => { MeTileImage = await App.LoadImageResourceAsync("Resources/metile.png"); }); SelectMeTileImageCommand = new Command(async () => { var photo = await CrossMedia.Current.PickPhotoAsync(); if (photo != null) { MeTileImage = await BandImage.FromStreamAsync(photo.GetStream()); } }, () => CrossMedia.Current.IsPickPhotoSupported); SetMeTileImageCommand = new Command(async () => { await personalizationManager.SetMeTileImageAsync(MeTileImage); }); Init(); }
internal BandTileManager(BandClient client, NativeBandTileManager tileManager) { this.Native = tileManager; this.client = client; #if __ANDROID__ this.tileReceiver = new BandTileBroadcastReceiver( e => OnTileOpened(new BandTileOpenedEventArgs(e)), e => OnTileClosed(new BandTileClosedEventArgs(e)), e => OnTileButtonPressed(new BandTileButtonPressedEventArgs(e))); #elif __IOS__ this.tileDelegate = new BandTileDelegate( e => OnTileOpened(new BandTileOpenedEventArgs(e)), e => OnTileClosed(new BandTileClosedEventArgs(e)), e => OnTileButtonPressed(new BandTileButtonPressedEventArgs(e))); #elif WINDOWS_PHONE_APP this.Native.TileButtonPressed += OnNativeTileButtonPressed; this.Native.TileOpened += OnNativeTileOpened; this.Native.TileClosed += OnNativeTileClosed; #endif }
async partial void ConnectToBandClick (UIButton sender) { if (client == null) { // get the client client = manager.AttachedClients.FirstOrDefault (); if (client == null) { Output ("Failed! No Bands attached."); } else { try { Output ("Please wait. Connecting to Band..."); await manager.ConnectTaskAsync (client); Output ("Band connected."); } catch (BandException ex) { Output ("Failed to connect to Band:"); Output (ex.Message); } } } else { Output ("Please wait. Disconnecting from Band..."); await manager.DisconnectTaskAsync (client); Output ("Band disconnected."); } }
public async void StartConnecting() { if (client != null) { return; } // get the client client = manager.AttachedClients.FirstOrDefault (); if (client == null) { Console.WriteLine ("Failed! No Bands attached."); } else { try { SetConnectionState(ConnectionState.Connecting); Console.WriteLine ("Please wait. Connecting to Band..."); await manager.ConnectTaskAsync (client); } catch (BandException ex) { Console.WriteLine ("Failed to connect to Band:"); Console.WriteLine (ex.Message); } } }
internal BandPersonalizationManager(BandClient client, NativeBandPersonalizationManager personalizationManager) { this.Native = personalizationManager; this.client = client; }
public TilesViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { tileManager = bandClient.TileManager; Tiles = new ObservableCollection<TileViewModel>(); }
public BaseClientContentPage(BandDeviceInfo info, BandClient bandClient) { BandInfo = info; BandClient = bandClient; }
internal BandNotificationManager(BandClient client, NativeBandNotificationManager notificationManager) { this.Native = notificationManager; this.client = client; }
public BaseClientViewModel(BandDeviceInfo info, BandClient bandClient) { BandClient = bandClient; BandInfo = info; }
public AddTileViewModel(BandDeviceInfo info, BandClient bandClient) : base(info, bandClient) { tileManager = bandClient.TileManager; tileTheme = App.DefaultTheme; tileId = Guid.NewGuid(); tileName = "New Tile"; GenerateTileIdCommand = new Command(() => { TileId = Guid.NewGuid().ToString("D"); }); DefaultTileIconCommand = new Command(async () => { TileIcon = await App.LoadImageResourceAsync("Resources/tile.png"); }); SelectTileIconCommand = new Command(async () => { var photo = await CrossMedia.Current.PickPhotoAsync(); if (photo != null) { TileIcon = await BandImage.FromStreamAsync(photo.GetStream()); } }, () => CrossMedia.Current.IsPickPhotoSupported); DefaultTileBadgeCommand = new Command(async () => { TileBadge = await App.LoadImageResourceAsync("Resources/badge.png"); }); SelectTileBadgeCommand = new Command(async () => { var photo = await CrossMedia.Current.PickPhotoAsync(); if (photo != null) { TileBadge = await BandImage.FromStreamAsync(photo.GetStream()); } }, () => CrossMedia.Current.IsPickPhotoSupported); DefaultThemeCommand = new Command(() => { TileTheme = App.DefaultTheme; }); AddTileCommand = new Command(async () => { var tile = new BandTile(tileId) { Icon = TileIcon, Name = TileName, SmallIcon = TileBadge, IsScreenTimeoutDisabled = DisableScreenTimeout }; if (UseCustomTheme) { tile.Theme = TileTheme; } tile.PageImages.AddRange(new[] { await App.LoadImageResourceAsync("Resources/star.png") }); var layouts = CreatePageLayouts(); tile.PageLayouts.AddRange(layouts); await tileManager.AddTileAsync(tile); var datas = CreatePageDatas(); await tileManager.SetTilePageDataAsync(tile.Id, datas); }); RemoveTileCommand = new Command(async () => { await tileManager.RemoveTileAsync(tileId); }); }