Esempio n. 1
0
        public async Task AddTile()
        {
            // Tile Definition
            var myTile = new BandTile(TileId)
            {
                Name      = "El Bruno Tile Simple",
                TileIcon  = await ImageHelper.LoadIcon("ms-appx:///Assets/RugbyBall46.png"),
                SmallIcon = await ImageHelper.LoadIcon("ms-appx:///Assets/RugbyBall24.png")
            };

            // Page UI
            var button = new TextButton
            {
                ElementId = 1,
                Rect      = new PageRect(10, 10, 200, 90)
            };
            var panel = new FilledPanel(button)
            {
                Rect = new PageRect(0, 0, 220, 150)
            };

            myTile.PageLayouts.Add(new PageLayout(panel));

            await BandHub.Instance.BandClient.TileManager.RemoveTileAsync(TileId);

            await BandHub.Instance.BandClient.TileManager.AddTileAsync(myTile);

            // Page Data
            var pageId      = new Guid("5F5FD06E-BD37-4B71-B36C-3ED9D721F200");
            var textButtonA = new TextButtonData(1, "El Button");
            var page        = new PageData(pageId, 0, textButtonA);
            await BandHub.Instance.BandClient.TileManager.SetPagesAsync(TileId, page);
        }
Esempio n. 2
0
        private async void ButtonDisplayTileClick(object sender, RoutedEventArgs e)
        {
            var myTile = new BandTile(_myTileId)
            {
                Name      = "El Bruno Tile",
                TileIcon  = await LoadIcon("ms-appx:///Assets/RugbyBall46.png"),
                SmallIcon = await LoadIcon("ms-appx:///Assets/RugbyBall24.png")
            };
            var button = new TextButton()
            {
                ElementId = 1, Rect = new PageRect(10, 10, 200, 90)
            };
            var panel = new FilledPanel(button)
            {
                Rect = new PageRect(0, 0, 220, 150)
            };

            myTile.PageLayouts.Add(new PageLayout(panel));

            await _bandClient.TileManager.RemoveTileAsync(_myTileId);

            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")));
        }
Esempio n. 3
0
        private async Task RegisterMicrosftBandApp()
        {
            if (pairedMicrosoftBands.Length < 1)
            {
                throw new InvalidOperationException("No paired Microsoft Band");
            }

            using (var bandClient = await Microsoft.Band.BandClientManager.Instance.ConnectAsync(pairedMicrosoftBands[0]))
            {
                var tile = new Microsoft.Band.Tiles.BandTile(new Guid("/*TODO*/"))
                {
                    Name      = resourceLoader.GetString(Constants.RESOURCEKEY_APPNAME),
                    TileIcon  = await LoadIcon(""),
                    SmallIcon = await LoadIcon("")
                };

                TextButton button = new TextButton
                {
                    HorizontalAlignment = HorizontalAlignment.Center,
                    ElementId           = 1, Rect = new PageRect(10, 10, 200, 90)
                };
                FilledPanel panel = new FilledPanel(button)
                {
                    Rect = new PageRect(0, 0, 220, 150)
                };
                tile.PageLayouts.Add(new PageLayout(panel));

                var tileWasAdded = await bandClient.TileManager.AddTileAsync(tile);
            }
        }
Esempio n. 4
0
        private async Task BuildLayout(BandTile myTile)
        {
            FilledPanel panel = new FilledPanel()
            {
                Rect = new PageRect(0, 0, 220, 150)
            };

            PageElement buttonElement = null;

            switch (buttonKind)
            {
            case ButtonKind.Text:
                buttonElement = new TextButton();
                break;

            case ButtonKind.Filled:
                buttonElement = new FilledButton()
                {
                    BackgroundColor = new BandColor(0, 128, 0)
                };
                break;

            case ButtonKind.Icon:
                buttonElement = new IconButton();
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/Smile.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/SmileUpsideDown.png"));
                break;

            default:
                throw new NotImplementedException();
            }

            buttonElement.ElementId = 1;
            buttonElement.Rect      = new PageRect(10, 10, 200, 90);

            panel.Elements.Add(buttonElement);

            myTile.PageLayouts.Add(new PageLayout(panel));
        }
Esempio n. 5
0
        public TileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel = new FilledPanel();
            panel.BackgroundColorSource = ElementColorSource.Custom;
            panel.BackgroundColor       = new BandColor(0, 0, 0);
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.Custom;
            textBlock.Color               = new BandColor(255, 255, 255);
            textBlock.Rect                = new PageRect(24, 57, 32, 32);
            textBlock.ElementId           = 4;
            textBlock.Margins             = new Margins(0, 0, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);

            textBlock2                     = new TextBlock();
            textBlock2.Font                = TextBlockFont.Small;
            textBlock2.Baseline            = 0;
            textBlock2.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock2.AutoWidth           = true;
            textBlock2.ColorSource         = ElementColorSource.Custom;
            textBlock2.Color               = new BandColor(255, 255, 255);
            textBlock2.Rect                = new PageRect(23, 30, 32, 32);
            textBlock2.ElementId           = 3;
            textBlock2.Margins             = new Margins(0, 0, 0, 0);
            textBlock2.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock2.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock2);

            icon                     = new Icon();
            icon.ColorSource         = ElementColorSource.BandHighlight;
            icon.Rect                = new PageRect(193, 55, 64, 64);
            icon.ElementId           = 2;
            icon.Margins             = new Margins(0, 0, 0, 0);
            icon.HorizontalAlignment = HorizontalAlignment.Left;
            icon.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(icon);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[3];
            pageElementDataArray[0] = textBlockData;
            pageElementDataArray[1] = textBlock2Data;
            pageElementDataArray[2] = iconData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
        public ActionScreen()
        {
            //LoadIconMethod = LoadIcon;
            //AdjustUriMethod = (uri) => uri;

            panel = new FilledPanel();
            panel.BackgroundColorSource = ElementColorSource.Custom;
            panel.BackgroundColor       = new BandColor(0, 0, 0);
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            button = new TextButton();
            button.PressedColor        = new BandColor(32, 32, 32);
            button.Rect                = new PageRect(160, 32, 90, 32);
            button.ElementId           = 5;
            button.Margins             = new Margins(0, 0, 0, 0);
            button.HorizontalAlignment = HorizontalAlignment.Center;
            button.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(button);

            wrappedTextBlock                     = new WrappedTextBlock();
            wrappedTextBlock.Font                = WrappedTextBlockFont.Small;
            wrappedTextBlock.AutoHeight          = false;
            wrappedTextBlock.ColorSource         = ElementColorSource.Custom;
            wrappedTextBlock.Color               = new BandColor(255, 255, 255);
            wrappedTextBlock.Rect                = new PageRect(8, 61, 260, 200);
            wrappedTextBlock.ElementId           = 4;
            wrappedTextBlock.Margins             = new Margins(0, 0, 0, 0);
            wrappedTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
            wrappedTextBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(wrappedTextBlock);

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.Custom;
            textBlock.Color               = new BandColor(255, 255, 255);
            textBlock.Rect                = new PageRect(7, 27, 32, 32);
            textBlock.ElementId           = 3;
            textBlock.Margins             = new Margins(0, 0, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);

            textBlock2                     = new TextBlock();
            textBlock2.Font                = TextBlockFont.Small;
            textBlock2.Baseline            = 0;
            textBlock2.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock2.AutoWidth           = true;
            textBlock2.ColorSource         = ElementColorSource.Custom;
            textBlock2.Color               = new BandColor(64, 199, 243);
            textBlock2.Rect                = new PageRect(7, -1, 32, 32);
            textBlock2.ElementId           = 2;
            textBlock2.Margins             = new Margins(0, 0, 0, 0);
            textBlock2.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock2.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock2);
            pageLayout = new PageLayout(panel);

            pageLayoutData = new PageData()
            {
                PageId          = ActionScreen.GUID,
                PageLayoutIndex = 3,
                Data            = { buttonData, wrappedTextBlockData, textBlockData, textBlock2Data }
            };
        }
        private async Task CreateJukeboxTileAsync()
        {
            // create the small and tile icons from writable bitmaps.
            // Small icons are 24x24 pixels.
            var writeableSmallBmp = BitmapFactory.New(24, 24);

            using (writeableSmallBmp.GetBitmapContext())
            {
                // Load an image from the calling Assembly's resources via the relative path
                writeableSmallBmp = await BitmapFactory.New(1, 1).FromContent(new Uri("ms-appx:///Assets/Sensor24x24.png"));
            }
            var smallIcon = writeableSmallBmp.ToBandIcon();

            // Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels for Microsoft
            // Band 2.
            var writeableBmp = BitmapFactory.New(46, 46);

            using (writeableBmp.GetBitmapContext())
            {
                // Load an image from the calling Assembly's resources via the relative path
                writeableBmp = await BitmapFactory.New(1, 1).FromContent(new Uri("ms-appx:///Assets/Sensor46x46.png"));
            }
            var tileIcon = writeableBmp.ToBandIcon();

            // create a new Guid for the tile
            var tileGuid = Guid.NewGuid();

            // create a new tile with a new Guid
            var tile = new BandTile(tileGuid)
            {
                IsBadgingEnabled = true,
                Name             = "Sensor Manager",
                SmallIcon        = smallIcon,
                TileIcon         = tileIcon
            };

            // create a filled rectangle to provide the background for a button
            var panel = new FilledPanel
            {
                Rect = new PageRect(0, 0, 245, 102)
            };

            // add buttons to our layout
            panel.Elements.Add(new TextButton
            {
                ElementId    = (short)TilePageElementId.Jukebox_PlayRandom,
                Rect         = new PageRect(20, 0, 70, 102),
                PressedColor = Colors.Blue.ToBandColor()
            });

            panel.Elements.Add(new TextButton
            {
                ElementId    = (short)TilePageElementId.Jukebox_Pause,
                Rect         = new PageRect(120, 0, 100, 45),
                PressedColor = Colors.Blue.ToBandColor()
            });

            panel.Elements.Add(new TextButton
            {
                ElementId    = (short)TilePageElementId.Jukebox_Stop,
                Rect         = new PageRect(120, 55, 100, 45),
                PressedColor = Colors.Blue.ToBandColor()
            });

            // create the page layout
            var layout = new PageLayout(panel);

            // add the tile to the Band
            tile.PageLayouts.Add(layout);
            if (await bandClient.TileManager.AddTileAsync(tile))
            {
                // create the content to assign to the page
                var pageContent = new PageData(Guid.NewGuid(),
                                               0, // index of our (only) layout
                                               new TextButtonData((short)TilePageElementId.Jukebox_PlayRandom, "Play"),
                                               new TextButtonData((short)TilePageElementId.Jukebox_Pause, "Pause"),
                                               new TextButtonData((short)TilePageElementId.Jukebox_Stop, "Stop"));

                await bandClient.TileManager.SetPagesAsync(tileGuid, pageContent);
            }
        }
Esempio n. 8
0
        private async Task CreateBandTitle()
        {
            var Tiles = await BandClient.TileManager.GetTilesAsync();

            if (Tiles.Count(u => u.Id == BandManagement.tileGuid) > 0)
            {
                return;
                //await BandClient.TileManager.RemoveTileAsync(BandManagement.tileGuid);
            }
            var Theme = await BandClient.PersonalizationManager.GetThemeAsync();

            var IconStream      = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("PowerfulTrainer.Images.BandIcon.png");
            var SmallIconStream = typeof(MainPage).GetTypeInfo().Assembly.GetManifestResourceStream("PowerfulTrainer.Images.BandSmallIcon.png");
            var Icon            = await BandImage.FromStreamAsync(IconStream);

            var SmallIcon = await BandImage.FromStreamAsync(SmallIconStream);

            BandTile tile = new BandTile(BandManagement.tileGuid)
            {
                Name      = "Powerful Trainer",
                Icon      = Icon,
                SmallIcon = SmallIcon,
                IsScreenTimeoutDisabled = true
            };
            FilledPanel panel = new FilledPanel
            {
                Rect = new PageRect(0, 0, 270, 120),
            };

            panel.Elements.Add(new TextButton
            {
                ElementId = 1,
                Rect      = new PageRect(188, 70, 80, 50),
            });

            panel.Elements.Add(new WrappedTextBlock
            {
                ElementId  = 2,
                Rect       = new PageRect(5, 2, 270, 50),
                AutoHeight = true,
                Color      = Theme.Highlight
            });

            panel.Elements.Add(new TextBlock
            {
                ElementId = 3,
                Rect      = new PageRect(2, 90, 270, 50),
                AutoWidth = true
            });


            PageLayout layout = new PageLayout(panel);

            tile.PageLayouts.Add(layout);

            try
            {
                await BandClient.TileManager.AddTileAsync(tile);
            }
            catch { }
        }
        internal async void Initialize()
        {
            var bandManager = BandClientManager.Instance;
            var pairedBands = await bandManager.GetBandsAsync();

            try
            {
                if (pairedBands.Length < 1)
                {
                    info.Text = "Could not connect";
                    return;
                }

                bandClient = await bandManager.ConnectAsync(pairedBands[0]);

                info.Text = "Connected to Band";
                lastMove  = DateTime.Now;

                // Create a Tile with a TextButton on it.
                BandTile myTile = new BandTile(myTileId)
                {
                    Name      = "My Teletouch",
                    TileIcon  = await LoadIcon("ms-appx:///Assets/BandTileIconLarge.png"),
                    SmallIcon = await LoadIcon("ms-appx:///Assets/BandTileIconSmall.png")
                };
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/left.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/center.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/right.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch1.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch2.png"));

                // get the current theme from the Band
                BandTheme theme = await bandClient.PersonalizationManager.GetThemeAsync();

                BandColor colorButton        = theme.Base;
                BandColor colorButtonPressed = new BandColor(0xFF, 0xFF, 0xFF);
                PageRect  rect1 = new PageRect(5, 0, 60, 110);
                PageRect  rect2 = new PageRect(70, 0, 60, 110);
                PageRect  rect3 = new PageRect(135, 0, 60, 110);
                PageRect  rect4 = new PageRect(200, 0, 40, 35);
                PageRect  rect5 = new PageRect(200, 37, 40, 35);
                PageRect  rect6 = new PageRect(200, 75, 40, 35);

                FilledButton buttonLeft = new FilledButton()
                {
                    ElementId = 1, Rect = rect1, BackgroundColor = colorButton
                };
                FilledButton buttonCenter = new FilledButton()
                {
                    ElementId = 2, Rect = rect2, BackgroundColor = colorButton
                };
                FilledButton buttonRight = new FilledButton()
                {
                    ElementId = 3, Rect = rect3, BackgroundColor = colorButton
                };
                FilledButton buttonSwitch = new FilledButton()
                {
                    ElementId = 4, Rect = rect4, BackgroundColor = colorButton
                };
                FilledButton buttonLock = new FilledButton()
                {
                    ElementId = 5, Rect = rect5, BackgroundColor = colorButton
                };
                FilledButton buttonOnOff = new FilledButton()
                {
                    ElementId = 6, Rect = rect6, BackgroundColor = colorButton
                };
                Icon iconLeft = new Icon()
                {
                    ElementId = 7, Rect = rect1, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconCenter = new Icon()
                {
                    ElementId = 8, Rect = rect2, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconRight = new Icon()
                {
                    ElementId = 9, Rect = rect3, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconSwitch = new Icon()
                {
                    ElementId = 10, Rect = rect4, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconLock = new Icon()
                {
                    ElementId = 11, Rect = rect5, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconOnOff = new Icon()
                {
                    ElementId = 12, Rect = rect6, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };

                FilledPanel panel = new FilledPanel(iconLeft, iconCenter, iconRight, iconSwitch, iconLock, iconOnOff,
                                                    buttonLeft, buttonCenter, buttonRight, buttonSwitch, buttonLock, buttonOnOff)
                {
                    Rect = new PageRect(0, 0, 240, 110),
                    HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center
                };
                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(pageId, 0,
                                                                                  new FilledButtonData(1, colorButtonPressed),
                                                                                  new FilledButtonData(2, colorButtonPressed),
                                                                                  new FilledButtonData(3, colorButtonPressed),
                                                                                  new FilledButtonData(4, colorButtonPressed),
                                                                                  new FilledButtonData(5, colorButtonPressed),
                                                                                  new FilledButtonData(6, colorButtonPressed),
                                                                                  new IconData(7, 2),
                                                                                  new IconData(8, 3),
                                                                                  new IconData(9, 4),
                                                                                  new IconData(10, 5),
                                                                                  new IconData(11, 6),
                                                                                  new IconData(12, 7)));

                // Subscribe to events
                bandClient.TileManager.TileOpened                 += EventHandler_TileOpened;
                bandClient.TileManager.TileClosed                 += EventHandler_TileClosed;
                bandClient.TileManager.TileButtonPressed          += EventHandler_TileButtonPressed;
                bandClient.SensorManager.Gyroscope.ReadingChanged += Gyroscope_ReadingChanged;

                // Start listening for events
                await bandClient.TileManager.StartReadingsAsync();
            }
            catch (BandException bandException)
            {
                Debug.WriteLine(bandException.Message);
                info.Text = "Could not connect";
            }
        }
Esempio n. 10
0
        private async void CreateTileWithButton_Click(object sender, EventArgs e)
        {
            // add the layout to the tile
            if (BandHelper.Instance.BandClient == null)
            {
                await BandHelper.Instance.Connect();
            }

            var tile = await BandHelper.CreateTile("Step 7 Tile");

            // create a filled rectangle to provide the background for a button
            var panel = new FilledPanel
            {
                Rect = new PageRect(0, 0, 245, 102),
                BackgroundColorSource = ElementColorSource.BandBase
            };

            // add a button to our layout
            panel.Elements.Add(
                new TextButton
            {
                ElementId    = (short)TilePageElementId.Button_PushMe,
                Rect         = new PageRect(60, 25, 100, 50),
                PressedColor = new Microsoft.Band.Portable.BandColor(0xFF, 0x00, 0x00),
            });

            // create the page layout
            var layout = new PageLayout(panel);

            // add the layout to the tile, and add the tile to the Band
            try
            {
                tile.PageLayouts.Add(layout);
                if (await BandHelper.Instance.BandClient.TileManager.AddTileAsync(tile))
                {
                    // layout and tile added successfully
                }
                else
                {
                    // tile failed to be added, handle error
                }
            }
            catch (Exception ex)
            {
                // handle an error adding the layout
            }

            var pageGuid = Guid.NewGuid();

            // create the content to assign to the page
            var textButtonData = new TextButtonData
            {
                ElementId = (int)TilePageElementId.Button_PushMe,
                Text      = "Push Me!"
            };

            var pageContent = new PageData
            {
                PageId          = pageGuid,
                PageLayoutIndex = 0,
                Data            =
                {
                    textButtonData
                }
            };


            // set the page content to the Band
            try
            {
                await BandHelper.Instance.BandClient.TileManager
                .SetTilePageDataAsync(tile.Id, pageContent);
            }
            catch (Exception ex)
            {
                // handle a Band connection exception
            }
        }
Esempio n. 11
0
        /// <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();
            }
        }