private void CreateRatePoll() { TextBlock nameTextBlock = new TextBlock() { Color = Colors.Blue.ToBandColor(), ElementId = 1, Rect = new PageRect(0, 0, 200, 30) }; WrappedTextBlock questionBlock = new WrappedTextBlock() { ElementId = 2, Rect = new PageRect(0, 0, 200, 70) }; TextButton button1 = new TextButton() { ElementId = 3, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) }; TextButton button2 = new TextButton() { ElementId = 4, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) }; TextButton button3 = new TextButton() { ElementId = 5, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) }; TextButton button4 = new TextButton() { ElementId = 6, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) }; TextButton button5 = new TextButton() { ElementId = 7, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) }; FlowPanel panel1 = new FlowPanel(nameTextBlock, questionBlock) { Orientation = FlowPanelOrientation.Vertical, Rect = new PageRect(0, 0, 200, 102) }; FlowPanel panel2 = new FlowPanel(button1, button2, button3, button4, button5) { Orientation = FlowPanelOrientation.Horizontal, Rect = new PageRect(0, 0, 200, 102) }; ScrollFlowPanel panelRate = new ScrollFlowPanel(panel1, panel2) { Orientation = FlowPanelOrientation.Horizontal, Rect = new PageRect(0, 0, 200, 102), ScrollBarColorSource = ElementColorSource.BandBase }; PageLayout pageLayout = new PageLayout(panelRate); PageLayouts.Add(pageLayout); }
private static PageLayout CreateMessageWithButtonLayout() { var customMessageWrappedTextBlock = new WrappedTextBlock() { ElementId = PageElementKind.CustomMessageText2, Rect = new PageRect(0, 0, 258, 102), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; var customMessageButton = new TextButton() { ElementId = PageElementKind.CustomMessageButton, Margins = new Margins(25, 10, 25, 10), Rect = new PageRect(0, 0, 170, 45), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var customMessageWithAckButtonPanel = new ScrollFlowPanel(customMessageWrappedTextBlock, customMessageButton) { Orientation = FlowPanelOrientation.Vertical, Rect = new PageRect(0, 0, 258, 102), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, }; var customMessageWithAckButtonLayout = new PageLayout(customMessageWithAckButtonPanel); return customMessageWithAckButtonLayout; }
/// <summary> /// Called when the "Install Tile" button is pressed in the UI. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void InstallTileButton_Click(object sender, RoutedEventArgs e) { App.Current.StatusMessage = "Installing...\n"; try { // Get the list of Microsoft Bands paired to the phone. IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync(); if (pairedBands.Length < 1) { App.Current.StatusMessage = "This sample app requires a Microsoft Band paired to your device. Also make sure that you have the latest firmware installed on your Band, as provided by the latest Microsoft Health app."; return; } // Connect to Microsoft Band. using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0])) { // Create a Tile with a TextButton and WrappedTextBlock on it. BandTile myTile = new BandTile(TileConstants.TileGuid) { Name = "My Tile", TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"), SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png") }; TextButton button = new TextButton() { ElementId = TileConstants.Button1ElementId, Rect = new PageRect(10, 5, 200, 30) }; WrappedTextBlock textblock = new WrappedTextBlock() { ElementId = TileConstants.TextElementId, Rect = new PageRect(10, 40, 200, 88) }; PageElement[] elements = new PageElement[] { button, textblock }; FilledPanel panel = new FilledPanel(elements) { Rect = new PageRect(0, 0, 220, 128) }; myTile.PageLayouts.Add(new PageLayout(panel)); // Remove the Tile from the Band, if present. An application won't need to do this everytime it runs. // But in case you modify this sample code and run it again, let's make sure to start fresh. await bandClient.TileManager.RemoveTileAsync(TileConstants.TileGuid); // Create the Tile on the Band. await bandClient.TileManager.AddTileAsync(myTile); PageElementData[] pagedata = new PageElementData[] { new TextButtonData(TileConstants.Button1ElementId, TileConstants.ButtonLabel), new WrappedTextBlockData(TileConstants.TextElementId, "...") }; await bandClient.TileManager.SetPagesAsync(TileConstants.TileGuid, new PageData(TileConstants.Page1Guid, 0, pagedata)); // Subscribe to background tile events await bandClient.SubscribeToBackgroundTileEventsAsync(TileConstants.TileGuid); App.Current.StatusMessage = "Installed Tile"; } } catch (Exception ex) { App.Current.StatusMessage = ex.ToString(); } }
private async void OnAddButtonTileClick(object sender, EventArgs e) { try { BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); FilledButton button = new FilledButton(0, 5, 210, 45); button.BackgroundColor = Color.Red; button.Margins = new Margins(0, 5, 0, 0); button.ElementId = 12; TextButton button2 = new TextButton(0, 0, 210, 45); button2.PressedColor = Color.Blue; button2.Margins = new Margins(0, 5, 0, 0); button2.ElementId = 21; FlowPanel flowPanel = new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.Vertical); flowPanel.AddElements(button); flowPanel.AddElements(button2); PageLayout pageLayout = new PageLayout(flowPanel); BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } builder.SetPageLayouts(pageLayout); BandTile tile = builder.Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } PageData pageData = new PageData(Java.Util.UUID.RandomUUID(), 0); pageData.Update(new FilledButtonData(12, Color.Yellow)); pageData.Update(new TextButtonData(21, "Text Button")); await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData); Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show(); // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } }
async partial void AddButtonPageClick (UIButton sender) { if (client != null && client.IsConnected) { Output ("Creating tile..."); // remove an old tile try { var tiles = await client.TileManager.GetTilesTaskAsync (); if (tiles.Any (x => x.TileId.AsString () == tileId.AsString ())) { // a tile exists, so remove it await client.TileManager.RemoveTileTaskAsync (tileId); Output ("Removed tile!"); } } catch (BandException ex) { Output ("Error: " + ex.Message); } // create the tile NSError operationError; var tileName = "iOS Sample"; var tileIcon = BandIcon.FromUIImage (UIImage.FromBundle ("tile.png"), out operationError); var smallIcon = BandIcon.FromUIImage (UIImage.FromBundle ("badge.png"), out operationError); var tile = BandTile.Create (tileId, tileName, tileIcon, smallIcon, out operationError); tile.BadgingEnabled = true; // create the button page var textBlock = new TextBlock (PageRect.Create (0, 0, 200, 40), TextBlockFont.Small); textBlock.ElementId = 10; textBlock.Baseline = 25; textBlock.HorizontalAlignment = HorizontalAlignment.Center; textBlock.BaselineAlignment = TextBlockBaselineAlignment.Relative; textBlock.AutoWidth = false; textBlock.Color = BandColor.FromUIColor (UIColor.Red, out operationError); textBlock.Margins = Margins.Create (5, 2, 5, 2); var button = new TextButton (PageRect.Create (0, 0, 200, 40)); button.ElementId = 11; button.HorizontalAlignment = HorizontalAlignment.Center; button.PressedColor = BandColor.FromUIColor (UIColor.Purple, out operationError); button.Margins = Margins.Create (5, 2, 5, 2); var flowPanel = new FlowPanel (PageRect.Create (15, 0, 260, 105)); flowPanel.AddElement (textBlock); flowPanel.AddElement (button); var pageLayout = new PageLayout (); pageLayout.Root = flowPanel; tile.PageLayouts.Add (pageLayout); // add the tile to the band try { Output ("Adding tile..."); await client.TileManager.AddTileTaskAsync (tile); } catch (BandException ex) { Output ("Error: " + ex.Message); } // set the page data try { Output ("Creating page data..."); var pageValues = new PageElementData [] { TextBlockData.Create (textBlock.ElementId, "TextButton sample", out operationError), TextButtonData.Create (button.ElementId, "Press Me", out operationError) }; var page = PageData.Create (barcodePageId, 0, pageValues); await client.TileManager.SetPagesTaskAsync (new[]{ page }, tileId); Output ("Completed custom page!"); } catch (BandException ex) { Output ("Error: " + ex.Message); } } else { Output ("Band is not connected. Please wait...."); } }
private async void Button_Click(object sender, RoutedEventArgs e) { this.viewModel.StatusMessage = "Running ..."; try { // Get the list of Microsoft Bands paired to the phone. IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync(); if (pairedBands.Length < 1) { this.viewModel.StatusMessage = "This sample app requires a Microsoft Band paired to your device. Also make sure that you have the latest firmware installed on your Band, as provided by the latest Microsoft Health app."; return; } // Connect to Microsoft Band. using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0])) { // Create a Tile with a TextButton on it. Guid myTileId = new Guid("12408A60-13EB-46C2-9D24-F14BF6A033C6"); BandTile myTile = new BandTile(myTileId) { Name = "My Tile", TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"), SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png") }; TextButton button = new TextButton() { ElementId = 1, Rect = new PageRect(10, 10, 200, 90) }; FilledPanel panel = new FilledPanel(button) { Rect = new PageRect(0, 0, 220, 150) }; myTile.PageLayouts.Add(new PageLayout(panel)); // Remove the Tile from the Band, if present. An application won't need to do this everytime it runs. // But in case you modify this sample code and run it again, let's make sure to start fresh. await bandClient.TileManager.RemoveTileAsync(myTileId); // Create the Tile on the Band. await bandClient.TileManager.AddTileAsync(myTile); await bandClient.TileManager.SetPagesAsync(myTileId, new PageData(new Guid("5F5FD06E-BD37-4B71-B36C-3ED9D721F200"), 0, new TextButtonData(1, "Click here"))); // Subscribe to Tile events. int buttonPressedCount = 0; TaskCompletionSource<bool> closePressed = new TaskCompletionSource<bool>(); bandClient.TileManager.TileButtonPressed += (s, args) => { var a = Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { buttonPressedCount++; this.viewModel.StatusMessage = string.Format("TileButtonPressed = {0}", buttonPressedCount); } ); }; bandClient.TileManager.TileClosed += (s, args) => { closePressed.TrySetResult(true); }; await bandClient.TileManager.StartReadingsAsync(); // Receive events until the Tile is closed. this.viewModel.StatusMessage = "Check the Tile on your Band (it's the last Tile). Waiting for events ..."; await closePressed.Task; // Stop listening for Tile events. await bandClient.TileManager.StopReadingsAsync(); this.viewModel.StatusMessage = "Done."; } } catch (Exception ex) { this.viewModel.StatusMessage = ex.ToString(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { this.viewModel.StatusMessage = "Running ..."; try { // Get the list of Microsoft Bands paired to the phone. IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync(); if (pairedBands.Length < 1) { this.viewModel.StatusMessage = "This sample app requires a Microsoft Band paired to your device. Also make sure that you have the latest firmware installed on your Band, as provided by the latest Microsoft Health app."; return; } // Connect to Microsoft Band. using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0])) { // Create a Tile with a TextButton on it. IEnumerable<BandTile> tileslist = await bandClient.TileManager.GetTilesAsync(); foreach (var t in tileslist) { if (t.Name == "Fan Control") { a = t.Name; } } if (a != "Fan Control") { Guid myTileId = new Guid("12408A60-13EB-46C2-9D24-F14BF6A033C6"); Guid pageId = Guid.NewGuid(); BandTile myTile = new BandTile(myTileId) { Name = "Fan Control", TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"), SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png") }; TextButton button = new TextButton() { ElementId = 1, Rect = new PageRect(0, 0, 50, 120) }; TextButton button1 = new TextButton() { ElementId = 2, Rect = new PageRect(50, 0, 50, 120) }; TextButton button2 = new TextButton() { ElementId = 3, Rect = new PageRect(100, 0, 50, 120) }; TextButton button3 = new TextButton() { ElementId = 4, Rect = new PageRect(150,0, 50, 120) }; TextButton button4= new TextButton() { ElementId = 5, Rect = new PageRect(200, 0, 50, 120) }; TextButton button5 = new TextButton() { ElementId = 6, Rect = new PageRect(250, 0, 50, 120) }; ScrollFlowPanel panel = new ScrollFlowPanel(button, button1, button2, button3, button4, button5) { Orientation = FlowPanelOrientation.Horizontal, Rect = new PageRect(0, 0, 320, 120), }; myTile.PageLayouts.Add(new PageLayout(panel)); //FilledPanel panel1 = new FilledPanel(button1) { Rect = new PageRect(0, 0, 220, 150) }; //myTile.PageLayouts.Add(new PageLayout(panel1)); // Remove the Tile from the Band, if present. An application won't need to do this everytime it runs. // But in case you modify this sample code and run it again, let's make sure to start fresh. await bandClient.TileManager.RemoveTileAsync(myTileId); // Create the Tile on the Band. await bandClient.TileManager.AddTileAsync(myTile); await bandClient.TileManager.SetPagesAsync(myTileId, new PageData(new Guid("5F5FD06E-BD37-4B71-B36C-3ED9D721F200"), 0, new TextButtonData(1, "1"), new TextButtonData(2, "2"), new TextButtonData(3, "3"), new TextButtonData(4, "4"), new TextButtonData(5, "5"), new TextButtonData(6, "6"))); //await bandClient.TileManager.SetPagesAsync(myTileId, new PageData(new Guid("5F5FD06E-BD37-4B71-B36C-3ED9D721F200"), 1, new TextButtonData(2, "Click here2"))); // Subscribe to Tile events. int buttonPressedCount = 0; } bandClient.TileManager.TileButtonPressed += TileManager_TileButtonPressed; TaskCompletionSource<bool> closePressed = new TaskCompletionSource<bool>(); bandClient.TileManager.TileClosed += (s, args) => { closePressed.TrySetResult(true); }; await bandClient.TileManager.StartReadingsAsync(); // Receive events until the Tile is closed. this.viewModel.StatusMessage = "Check the Tile on your Band (it's the last Tile). Waiting for events ..."; await closePressed.Task; // Stop listening for Tile events. // await bandClient.TileManager.StopReadingsAsync(); //this.viewModel.StatusMessage = "Done."; } } catch (Exception ex) { this.viewModel.StatusMessage = ex.ToString(); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.fragment_tiles, container, false); mListTiles = rootView.FindViewById<ListView>(Resource.Id.listTiles); RelativeLayout header = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_tiles_header, null); mTextRemainingCapacity = header.FindViewById<TextView>(Resource.Id.textAvailableCapacity); mButtonAddButtonTile = header.FindViewById<Button>(Resource.Id.buttonAddButtonTile); mButtonAddButtonTile.Click += async delegate { try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); FilledButton button = new FilledButton(0, 5, 210, 45); button.BackgroundColor = Color.Red; button.Margins = new Margins(0, 5, 0 ,0); button.ElementId = 12; TextButton button2 = new TextButton(0, 0, 210, 45); button2.PressedColor = Color.Blue; button2.Margins = new Margins(0, 5, 0 ,0); button2.ElementId = 21; FlowPanel flowPanel = new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.Vertical); flowPanel.AddElements(button); flowPanel.AddElements(button2); PageLayout pageLayout = new PageLayout(flowPanel); BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } builder.SetPageLayouts(pageLayout); BandTile tile = builder.Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } PageData pageData = new PageData(Java.Util.UUID.RandomUUID(), 0); pageData.Update(new FilledButtonData(12, Color.Yellow)); pageData.Update(new TextButtonData(21, "Text Button")); await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData); Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show(); // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Add tile", e); } }; mButtonAddBarcodeTile = header.FindViewById<Button>(Resource.Id.buttonAddBarcodeTile); mButtonAddBarcodeTile.Click += async delegate { try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); // create layout 1 Barcode barcode1 = new Barcode(new PageRect(0, 0, 221, 70), BarcodeType.Code39); barcode1.Margins = new Margins(3, 0, 0, 0); barcode1.ElementId = 11; TextBlock textBlock1 = new TextBlock(new PageRect(0, 0, 230, 30), TextBlockFont.Small, 0); textBlock1.Color = Color.Red; textBlock1.ElementId = 21; FlowPanel flowPanel1 = new FlowPanel(new PageRect(15, 0, 245, 105), FlowPanelOrientation.Vertical); flowPanel1.AddElements(barcode1); flowPanel1.AddElements(textBlock1); PageLayout pageLayout1 = new PageLayout(flowPanel1); // create layout 2 Barcode barcode2 = new Barcode(0, 0, 221, 70, BarcodeType.Pdf417); barcode2.Margins = new Margins(3, 0, 0, 0); barcode2.ElementId = 11; TextBlock textBlock2 = new TextBlock(0, 0, 230, 30, TextBlockFont.Small, 0); textBlock2.Color = Color.Red; textBlock2.ElementId = 21; FlowPanel flowPanel2 = new FlowPanel(15, 0, 245, 105, FlowPanelOrientation.Vertical); flowPanel2.AddElements(barcode2); flowPanel2.AddElements(textBlock2); PageLayout pageLayout2 = new PageLayout(flowPanel2); // create the tile BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } builder.SetPageLayouts(pageLayout1, pageLayout2); BandTile tile = builder.Build(); // add tile try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } PageData pageData1 = new PageData(Java.Util.UUID.RandomUUID(), 0); pageData1.Update(new BarcodeData(11, "MK12345509", BarcodeType.Code39)); pageData1.Update(new TextButtonData(21, "MK12345509")); PageData pageData2 = new PageData(Java.Util.UUID.RandomUUID(), 1); pageData2.Update(new BarcodeData(11, "901234567890123456", BarcodeType.Pdf417)); pageData2.Update(new TextButtonData(21, "901234567890123456")); await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData1, pageData2); Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show(); // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Add tile", e); } }; mButtonAddTile = header.FindViewById<Button>(Resource.Id.buttonAddTile); mButtonAddTile.Click += async delegate { try { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final android.graphics.BitmapFactory.Options options = new android.graphics.BitmapFactory.Options(); BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)); BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)); BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon); if (mCheckboxBadging.Checked) { builder.SetTileSmallIcon(badgeIcon); } if (mCheckboxCustomTheme.Checked) { builder.SetTheme(mThemeView.Theme); } BandTile tile = builder.Build(); try { var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile); if (result) { Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show(); } else { Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show(); } } catch (Exception ex) { Util.ShowExceptionAlert(Activity, "Add tile", ex); } // Refresh our tile list and count await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Add tile", e); } }; mButtonRemoveTile = header.FindViewById<Button>(Resource.Id.buttonRemoveTile); mButtonRemoveTile.Click += async delegate { try { await Model.Instance.Client.TileManager.RemoveTileTaskAsync(mSelectedTile.TileId); mSelectedTile = null; Toast.MakeText(Activity, "Tile removed", ToastLength.Short).Show(); await RefreshData(); RefreshControls(); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Remove tile", e); } }; mCheckboxBadging = header.FindViewById<CheckBox>(Resource.Id.cbBadging); mThemeView = header.FindViewById<BandThemeView>(Resource.Id.viewCustomTheme); mCheckboxCustomTheme = header.FindViewById<CheckBox>(Resource.Id.cbCustomTheme); mCheckboxCustomTheme.CheckedChange += (sender, e) => { mThemeView.Visibility = e.IsChecked ? ViewStates.Visible : ViewStates.Gone; }; mEditTileName = header.FindViewById<EditText>(Resource.Id.editTileName); mEditTileName.TextChanged += (sender, e) => RefreshControls(); RelativeLayout footer = (RelativeLayout)inflater.Inflate(Resource.Layout.fragment_tiles_footer, null); mEditTitle = footer.FindViewById<EditText>(Resource.Id.editTitle); mEditBody = footer.FindViewById<EditText>(Resource.Id.editBody); mCheckboxWithDialog = footer.FindViewById<CheckBox>(Resource.Id.cbWithDialog); mButtonSendMessage = footer.FindViewById<Button>(Resource.Id.buttonSendMessage); mButtonSendMessage.Click += async delegate { try { await Model.Instance.Client.NotificationManager.SendMessageTaskAsync( mSelectedTile.TileId, mEditTitle.Text, mEditBody.Text, DateTime.Now, mCheckboxWithDialog.Checked); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Send message", e); } }; mButtonSendDialog = footer.FindViewById<Button>(Resource.Id.buttonSendDialog); mButtonSendDialog.Click += async delegate { try { await Model.Instance.Client.NotificationManager.ShowDialogTaskAsync(mSelectedTile.TileId, mEditTitle.Text, mEditBody.Text); } catch (Exception e) { Util.ShowExceptionAlert(Activity, "Show dialog", e); } }; mListTiles.AddHeaderView(header); mListTiles.AddFooterView(footer); mTileListAdapter = new TileListAdapter(this); mListTiles.Adapter = mTileListAdapter; mListTiles.ItemClick += (sender, e) => { var position = e.Position - 1; // ignore the header if (position >= 0 && position < mTileListAdapter.Count) { mSelectedTile = (BandTile) mTileListAdapter.GetItem(position); RefreshControls(); } }; return rootView; }