private void TileManager_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { var elementId = (short)e.TileEvent.ElementId; var tileId = e.TileEvent.TileId; var message = Empty; if (_bandTileComplex.TileId == tileId) { switch (elementId) { case BandTileComplex.ButtonAId: message = "Click on button A"; break; case BandTileComplex.ButtonBId: message = "Click on button B"; break; default: message = "Click on other element"; break; } } BandUserActions = message; _buttonPressedCount++; StatusMessage = Format("Tile Button Pressed = {0}", _buttonPressedCount); }
private async void TileManagerOnTileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> bandTileEventArgs) { var appBandTile = _appBandTileManager.AppBandTiles.FirstOrDefault(dt => bandTileEventArgs.TileEvent.TileId == dt.Id); if (appBandTile != null) { await appBandTile.TileButtonPressedAsync(_bandClient, bandTileEventArgs); } }
/// <summary> /// Handle the event that occurs when our tile is closed /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileClosed(object sender, BandTileEventArgs <IBandTileClosedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. LogEvent(String.Format("EventHandler_TileClosed: TileId={0} Timestamp={1}", e.TileEvent.TileId, e.TileEvent.Timestamp)); UpdatePageData(); // Disconnect the Band now that the user has closed the tile. DisconnectBand(); }
/// <summary> /// Handle the event that occurs when the user opens our tile /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. LogEvent(String.Format("EventHandler_TileOpened: TileId={0} Timestamp={1}", e.TileEvent.TileId, e.TileEvent.Timestamp)); // We create a Band connection when the tile is opened and keep it connected until the tile closes. ConnectBand(); UpdatePageData(); }
private void OnTileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { // most scenarios would need this, I don't. var tileId = e.TileEvent.TileId; // We make our call. This is hard-coded for now. var line = AccessoryManager.PhoneLineDetails.FirstOrDefault(); if (line != null) { AccessoryManager.MakePhoneCall(line.LineId, Constants.PhoneNumber); } }
private async void TileManager_TileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { //alert! //Create new alert in the alerts list ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); var eventUniqueID = new DateTime().Millisecond *new Random().Next(1, 5); var result = await client.GetDataAsync(59.975349, 10.665395, eventUniqueID); await client.CloseAsync(); //Start sending live data from band to a new event list in sharepoint }
void TileManager_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { //TextButton tb = (TextButton)sender; //tb.ElementId; //this.viewModel.StatusMessage = string.Format("TileButtonPressed =" + id+" oo"+idd+"buttonPressedCount"); var a = Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { var idd = e.TileEvent.ElementId; // var id = 1; string url = null; // buttonPressedCount++; this.viewModel.StatusMessage = string.Format("TileButtonPressed =" + idd + " oo" + idd + "buttonPressedCount"); switch (idd) { case 1: url = "http://192.168.1.100:8000/automate/on"; break; case 2: url = "http://192.168.1.100:8000/automate/off"; break; case 3: url = "http://192.168.1.100:8000/automate/onf"; break; case 4: url = "http://192.168.1.100:8000/automate/dance"; break; case 5: url = "http://192.168.1.100:8000/automate/dim"; break; case 6: url = "http://192.168.1.100:8000/automate/"; break; } get(url); } ); }
private async void EventHandler_TileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { // This method is called when the user taps on our Band tile // // e.TileEvent.TileId is the tile’s Guid // e.TileEvent.Timestamp is the DateTimeOffset of the event // // handle the event await bandClient.SensorManager.Gyroscope.StartReadingsAsync(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info1.Text = "Tile Opened"; }); }
/// <summary> /// Handle the event that occurs when the user presses a button on page of the tile /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. // e.TileEvent.PageId is the Guid of our page with the button. // e.TileEvent.ElementId is the value assigned to the button // in our layout (i.e., // TilePageElementId.Button_PushMe). LogEvent(String.Format("EventHandler_TileButtonPressed: TileId={0} PageId={1} ElementId={2}", e.TileEvent.TileId, e.TileEvent.PageId, e.TileEvent.ElementId)); // We should have a Band connection from the tile open event, but in case the OS unloaded our background code // between that event and this button press event, we restore the connection here as needed. ConnectBand(); UpdatePageData(); }
private async void TileManager_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { Debug.WriteLine((TilePageElementId)e.TileEvent.ElementId); switch ((TilePageElementId)e.TileEvent.ElementId) { case TilePageElementId.Jukebox_PlayRandom: await this.PlayRandomMusicAsync(); break; case TilePageElementId.Jukebox_Pause: await this.PauseMusicAsync(); break; case TilePageElementId.Jukebox_Stop: await this.StopMusicAsync(); break; case TilePageElementId.Rover_MoveForward: await this.MoveRoverForwardAsync(); break; case TilePageElementId.Rover_MoveBackward: await this.MoveRoverBackwardAsync(); break; case TilePageElementId.Rover_RotateLeft: await this.RotateRoverLeftAsync(); break; case TilePageElementId.Rover_RotateRight: await this.RotateRoverRightAsync(); break; case TilePageElementId.Rover_Stop: await this.StopRoverAsync(); break; } }
private async void TileManager_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { switch ((TilePageElementId)e.TileEvent.ElementId) { case TilePageElementId.Jukebox_PlayRandom: await this.PlayRandomMusicAsync(); break; case TilePageElementId.Jukebox_Pause: await this.PauseMusicAsync(); break; case TilePageElementId.Jukebox_Stop: await this.StopMusicAsync(); break; } }
async void OnTileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { if (e.TileEvent.ElementId == this.designedLayout.btnBeer.ElementId) { this.storage.IncrementCounter(ItemType.Beer); } else if (e.TileEvent.ElementId == this.designedLayout.btnCoffee.ElementId) { this.storage.IncrementCounter(ItemType.Coffee); } else if (e.TileEvent.ElementId == this.designedLayout.btnTea.ElementId) { this.storage.IncrementCounter(ItemType.Tea); } else if (e.TileEvent.ElementId == this.designedLayout.btnWine.ElementId) { this.storage.IncrementCounter(ItemType.Wine); } await this.UpdatePageDataAsync(); this.UpdateUI(); }
private async void TileManager_TileOpened(object sender, BandTileEventArgs<IBandTileOpenedEvent> e) { //alert! //Create new alert in the alerts list ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); var result = await client.CreateAlertAsync(59.975349, 10.665395, eventUniqueID); await client.CloseAsync(); await bandClient.NotificationManager.ShowDialogAsync(e.TileEvent.TileId, "Help is on the way!", "It shouldn't take long..."); heartRateMonitor(); //skinTemperatureMonitor(); //GyroscopeMonitor(); //PedometerMonitor(); //GsrMonitor(); //UVMonitor(); // start the Heartrate sensor try { await bandClient.SensorManager.HeartRate.StartReadingsAsync(); } catch (BandException ex) { // handle a Band connection exception throw ex; } //try //{ // await bandClient.SensorManager.Gyroscope.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.Pedometer.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.Gsr.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.UV.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.SkinTemperature.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} }
public async override Task TileButtonPressedAsync(IBandClient bandClient, BandTileEventArgs<IBandTileButtonPressedEvent> bandTileEventArgs) { await base.TileButtonPressedAsync(bandClient, bandTileEventArgs); if (bandTileEventArgs.TileEvent.ElementId == PageElementKind.CustomMessageButton) { OnCustomMessageButtonPressed(bandTileEventArgs); } }
void OnTileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { }
/// <summary> /// Handles the tile opened event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="bandTileEventArgs">The <see cref="BandTileEventArgs{IBandTileOpenedEvent}"/> instance containing the event data.</param> protected virtual void TileManagerOnTileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> bandTileEventArgs) { }
/// <summary> /// Handle the event that occurs when our tile is closed /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileClosed(object sender, BandTileEventArgs<IBandTileClosedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. LogEvent(String.Format("EventHandler_TileClosed: TileId={0} Timestamp={1}", e.TileEvent.TileId, e.TileEvent.Timestamp)); UpdatePageData(); // Disconnect the Band now that the user has closed the tile. DisconnectBand(); }
/// <summary> /// Handle the event that occurs when the user presses a button on page of the tile /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. // e.TileEvent.PageId is the Guid of our page with the button. // e.TileEvent.ElementId is the value assigned to the button // in our layout (i.e., // TilePageElementId.Button_PushMe). LogEvent(String.Format("EventHandler_TileButtonPressed: TileId={0} PageId={1} ElementId={2}", e.TileEvent.TileId, e.TileEvent.PageId, e.TileEvent.ElementId)); // We should have a Band connection from the tile open event, but in case the OS unloaded our background code // between that event and this button press event, we restore the connection here as needed. ConnectBand(); UpdatePageData(); }
private void TileManager_TileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { StatusMessage = "Tile Opened"; }
/// <summary> /// Event that is triggered when the band tile is opened. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">The opened event arguments.</param> private async void OnTileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { await RunBackgroundTask(); }
void TileManager_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { //TextButton tb = (TextButton)sender; //tb.ElementId; //this.viewModel.StatusMessage = string.Format("TileButtonPressed =" + id+" oo"+idd+"buttonPressedCount"); var a = Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { var idd = e.TileEvent.ElementId; // var id = 1; string url = null; // buttonPressedCount++; this.viewModel.StatusMessage = string.Format("TileButtonPressed =" + idd + " oo" + idd + "buttonPressedCount"); switch (idd) { case 1: url = "http://192.168.1.100:8000/automate/on"; break; case 2: url = "http://192.168.1.100:8000/automate/off"; break; case 3: url = "http://192.168.1.100:8000/automate/onf"; break; case 4: url = "http://192.168.1.100:8000/automate/dance"; break; case 5: url = "http://192.168.1.100:8000/automate/dim"; break; case 6: url = "http://192.168.1.100:8000/automate/"; break; } get(url); } ); }
private async void TileManager_TileOpened(object sender, BandTileEventArgs<IBandTileOpenedEvent> e) { var bandClient = await GetBandClient(); if (bandClient != null) { if (e.TileEvent.TileId == BandUiDefinitions.TileId && _lastTemperatureData != null) { var buc = new BandUiController(bandClient); await buc.SetUiValues( _lastTemperatureData.Timestamp.ToLocalTime().ToString("HH:mm:ss"), _lastTemperatureData.Timestamp.ToLocalTime().ToString("dd-MM-yyyy"), $"{_lastTemperatureData.Temperature}°C", GetFanStatusText()); await bandClient.NotificationManager.VibrateAsync(VibrationType.NotificationOneTone); } } }
private async void TileManager_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { var te = e.TileEvent; if (te.TileId == BandUiDefinitions.TileId && te.PageId == BandUiDefinitions.Page1Id && te.ElementId == BandUiDefinitions.ButtonToggleFanId) { if (!_isProcessing) { _lastToggleUse = DateTime.UtcNow; _isProcessing = true; var cmd = new FanSwitchCommand(_lastFanStatus, true); Debug.WriteLine($"Sending fan command {cmd.Status}"); await UpdateFirstPageStatus(); await _fanStatusPoster.PostData(cmd); } } }
async void EventHandler_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { // This method is called when the user presses the // button in our tile’s layout. // // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. // e.TileEvent.PageId is the Guid of our page with the button. // e.TileEvent.ElementId is the value assigned to the button Guid pageId = e.TileEvent.PageId; StorageFolder folder = ApplicationData.Current.LocalFolder; if (Helpers.containsKeyDictionary(pageId, folder)) { string switchName = Helpers.getValueByKeyDictionary(pageId, folder); string value; if (e.TileEvent.ElementId == 3) { value = "on"; } else { value = "off"; } Helpers.apiCall("set/" + Uri.EscapeUriString(switchName) + "/" + value); string apiCallResult = Helpers.apiCall("switches"); //IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync(); //bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]); TileUIUpdater t = new TileUIUpdater(bandClient, myTileId); t.updatePages(JArray.Parse(apiCallResult)); } #pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed }
/// <summary> /// Handle the event that occurs when the user opens our tile /// </summary> /// <param name="sender"></param> /// <param name="e">Data describing the event details</param> private void EventHandler_TileOpened(object sender, BandTileEventArgs<IBandTileOpenedEvent> e) { // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. LogEvent(String.Format("EventHandler_TileOpened: TileId={0} Timestamp={1}", e.TileEvent.TileId, e.TileEvent.Timestamp)); // We create a Band connection when the tile is opened and keep it connected until the tile closes. ConnectBand(); UpdatePageData(); }
private async void OnTileClosed(object sender, BandTileEventArgs<IBandTileClosedEvent> e) { try { Logger.Info("Handling TileClosed event."); //Make sure the client is created //The background task might be stopped after the OnTileOpened event if (this._backgroundTileClient == null) this._backgroundTileClient = await this.GetClientAsync(true); await this.ChangeTileDataToLoadingAsync(this._backgroundTileClient); this._backgroundTileClient.Dispose(); } catch (Exception exception) { Logger.Error(exception); if (this._backgroundTileClient != null) { var title = CTime2CoreResources.Get("BandService.ApplicationName"); var body = CTime2CoreResources.Get("BandService.ErrorOccurred"); await this._backgroundTileClient.NotificationManager.ShowDialogAsync(BandConstants.TileId, title, body); } } finally { Logger.Info("Handled TileClosed event."); this._backgroundTileEventTaskSource.SetResult(null); } }
void EventHandler_TileOpened(object sender, BandTileEventArgs<IBandTileOpenedEvent> e) { // This method is called when the user taps our Band tile. // // e.TileEvent.TileId is the tile’s Guid. // e.TileEvent.Timestamp is the DateTimeOffset of the event. // // handle the event //SendDialog(); }
private void TileManager_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { Debug.WriteLine(e.TileEvent.TileId + " ----- " + e.TileEvent.ElementId); switch ((int) e.TileEvent.ElementId) { case 2: if (App.AudioPlayer.IsMyBackgroundTaskRunning) { if (MediaPlayerState.Playing == App.AudioPlayer.CurrentPlayer.CurrentState) { App.AudioPlayer.CurrentPlayer.Pause(); } else if (MediaPlayerState.Paused == App.AudioPlayer.CurrentPlayer.CurrentState) { App.AudioPlayer.CurrentPlayer.Play(); } else if (MediaPlayerState.Closed == App.AudioPlayer.CurrentPlayer.CurrentState) { App.AudioPlayer.StartBackgroundAudioTask(); } } else { App.AudioPlayer.StartBackgroundAudioTask(); } break; case 3: MessageService.SendMessageToBackground(new SkipPreviousMessage()); break; case 4: MessageService.SendMessageToBackground(new SkipNextMessage()); break; default: break; } }
private async void TileManager_TileOpened(object sender, BandTileEventArgs <IBandTileOpenedEvent> e) { //alert! //Create new alert in the alerts list ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); var result = await client.CreateAlertAsync(59.975349, 10.665395, eventUniqueID); await client.CloseAsync(); await bandClient.NotificationManager.ShowDialogAsync(e.TileEvent.TileId, "Help is on the way!", "It shouldn't take long..."); heartRateMonitor(); //skinTemperatureMonitor(); //GyroscopeMonitor(); //PedometerMonitor(); //GsrMonitor(); //UVMonitor(); // start the Heartrate sensor try { await bandClient.SensorManager.HeartRate.StartReadingsAsync(); } catch (BandException ex) { // handle a Band connection exception throw ex; } //try //{ // await bandClient.SensorManager.Gyroscope.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.Pedometer.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.Gsr.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.UV.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} //try //{ // await bandClient.SensorManager.SkinTemperature.StartReadingsAsync(); //} //catch (BandException ex) //{ // // handle a Band connection exception // throw ex; //} }
/// <summary> /// Handles the tile button pressed event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="bandTileEventArgs">The <see cref="BandTileEventArgs{IBandTileButtonPressedEvent}"/> instance containing the event data.</param> protected virtual void TileManagerOnTileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> bandTileEventArgs) { }
private async void OnTileOpened(object sender, BandTileEventArgs<IBandTileOpenedEvent> bandTileEventArgs) { try { Logger.Info("Handling TileOpened event."); this._backgroundTileClient = await this.GetClientAsync(true); await this.ChangeTileDataToReadyAsync(this._backgroundTileClient); await this._backgroundTileClient.NotificationManager.VibrateAsync(VibrationType.NotificationOneTone); } catch (Exception exception) { Logger.Error(exception); if (this._backgroundTileClient != null) { var title = CTime2CoreResources.Get("BandService.ApplicationName"); var body = CTime2CoreResources.Get("BandService.ErrorOccurred"); await this._backgroundTileClient.NotificationManager.ShowDialogAsync(BandConstants.TileId, title, body); } } finally { Logger.Info("Handled TileOpened event."); this._backgroundTileEventTaskSource.SetResult(null); } }
public virtual async Task TileButtonPressedAsync(IBandClient bandClient, BandTileEventArgs<IBandTileButtonPressedEvent> args) { await bandClient.NotificationManager.VibrateAsync(VibrationType.NotificationOneTone); }
private async void OnTileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { try { Logger.Info("Handling TileButtonPressed event."); //Make sure the client is created //The background task might be stopped after the OnTileOpened event if (this._backgroundTileClient == null) this._backgroundTileClient = await this.GetClientAsync(true); if (e.TileEvent.TileId == BandConstants.TileId) { if (e.TileEvent.ElementId == new StampPageLayout().StampTextButton.ElementId) { await this._backgroundTileClient.NotificationManager.VibrateAsync(VibrationType.NotificationOneTone); bool checkedIn = this._applicationStateService.GetCurrentUser() != null ? await this._cTimeService.IsCurrentlyCheckedIn(this._applicationStateService.GetCurrentUser().Id) : false; var stampHelper = new CTimeStampHelper(this._applicationStateService, this._cTimeService); await stampHelper.Stamp(this, checkedIn ? TimeState.Left : TimeState.Entered); await this.ChangeTileDataToReadyAsync(this._backgroundTileClient); } else if (e.TileEvent.ElementId == new TestConnectionPageLayout().TestTextButton.ElementId) { await this._backgroundTileClient.NotificationManager.VibrateAsync(VibrationType.NotificationTwoTone); } } } catch (Exception exception) { Logger.Error(exception); if (this._backgroundTileClient != null) { var title = CTime2CoreResources.Get("BandService.ApplicationName"); var body = CTime2CoreResources.Get("BandService.ErrorOccurred"); await this._backgroundTileClient.NotificationManager.ShowDialogAsync(BandConstants.TileId, title, body); } } finally { Logger.Info("Handled TileButtonPressed event."); this._backgroundTileEventTaskSource.SetResult(null); } }
private void TileManager_TileClosed(object sender, BandTileEventArgs <IBandTileClosedEvent> e) { StatusMessage = $"Tile {e.TileEvent.TileId} closed at {e.TileEvent.Timestamp}"; }
private void TileManager_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { StatusMessage = $"Button {e.TileEvent.ElementId} on page {e.TileEvent.PageId} pressed at {e.TileEvent.Timestamp}"; }
private void OnCustomMessageButtonPressed(BandTileEventArgs<IBandTileButtonPressedEvent> bandTileEventArgs) { // this is a good place to integrate logging like event tracking with Application Insights // https://azure.microsoft.com/en-us/documentation/articles/app-insights-api-custom-events-metrics/#track-event if (CustomMessageButtonPressed != null) { var eventArgs = new EventArgs(); CustomMessageButtonPressed(this, eventArgs); } }
private async void EventHandler_TileButtonPressed(object sender, BandTileEventArgs <IBandTileButtonPressedEvent> e) { // This method is called when the user presses the // button in our tile’s layout // // e.TileEvent.TileId is the tile’s Guid // e.TileEvent.Timestamp is the DateTimeOffset of the event // e.TileEvent.PageId is the Guid of our page with the button // e.TileEvent.ElementId is the value assigned to the button // in our layout, i.e. // TilePageElementId.Button_PushMe // // handle the event if (e.TileEvent.PageId == pageId) { switch (e.TileEvent.ElementId) { case 1: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "Left pressed"; isButton1Down = !isButton1Down; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } if (!isKeepDown) { isButton1Down = false; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } } }); break; case 2: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "Center pressed"; isButton2Down = !isButton2Down; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } if (!isKeepDown) { isButton2Down = false; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } } }); break; case 3: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "Right pressed"; isButton3Down = !isButton3Down; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } if (!isKeepDown) { isButton3Down = false; if (isMouse) { (App.Current as App).MainController.SendMouseData(offsetXY, isButton1Down, isButton2Down, isButton3Down, true); } else { (App.Current as App).MainController.SendJoystickData(offsetXY, isButton1Down, isButton2Down, isButton3Down, false, false, true); } } }); break; case 4: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "Switch pressed"; isMouse = !isMouse; this.ButtonMouse.Background = this.isMouse ? brushSelected : brushNotSelected; this.ButtonJoystick.Background = !this.isMouse ? brushSelected : brushNotSelected; }); break; case 5: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "Lock pressed"; toggleSwitchLock.IsOn = !toggleSwitchLock.IsOn; isKeepDown = toggleSwitchLock.IsOn; }); break; case 6: await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { info2.Text = "On/Off pressed"; toggleSwitchAutoOnOff.IsOn = !toggleSwitchAutoOnOff.IsOn; isAutoOnOff = toggleSwitchAutoOnOff.IsOn; }); break; default: break; } } }
private async void TileManager_TileButtonPressed(object sender, BandTileEventArgs<IBandTileButtonPressedEvent> e) { switch ((TilePageElementId)e.TileEvent.ElementId) { case TilePageElementId.Jukebox_PlayRandom: await this.PlayRandomMusicAsync(); break; case TilePageElementId.Jukebox_Pause: await this.PauseMusicAsync(); break; case TilePageElementId.Jukebox_Stop: await this.StopMusicAsync(); break; case TilePageElementId.Rover_MoveForward: await this.MoveRoverForwardAsync(); break; case TilePageElementId.Rover_MoveBackward: await this.MoveRoverBackwardAsync(); break; case TilePageElementId.Rover_RotateLeft: await this.RotateRoverLeftAsync(); break; case TilePageElementId.Rover_RotateRight: await this.RotateRoverRightAsync(); break; case TilePageElementId.Rover_Stop: await this.StopRoverAsync(); break; } }