コード例 #1
0
        internal static void UpdatePageData(IBandClient bandClient)
        {
            if (bandClient != null)
            {
                try
                {
                    GroupTile groupTile = new GroupTile();

                    groupTile.Data.ById <TextBlockData>(2).Text = "Background Service";
                    var data = groupTile.Data.All;

                    bandClient.TileManager.SetPagesAsync(WinkTile.tileGuid, new PageData(WinkTile.page1Guid, 0, data)).Wait();
                }
                catch (Exception ex)
                {
                    //Exception a = ex;
                    System.Diagnostics.Debug.WriteLine("CODECRIB - " + ex.ToString());
                    //LogEvent("ERROR - Unable to update page data");
                }
            }
        }
コード例 #2
0
        private static async Task <bool> InstallTile(bool isBackground)
        {
            bool installed = false;

            try
            {
                // Get the list of Microsoft Bands paired to the phone.
                IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync(isBackground);

                if (pairedBands.Length >= 1)
                {
                    // Connect to Microsoft Band.
                    using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
                    {
                        // Create a Tile with a TextButton and WrappedTextBlock on it.
                        BandTile winkTile = new BandTile(WinkTile.tileGuid)
                        {
                            Name      = "Wink",
                            TileIcon  = await LoadIcon("ms-appx:///Assets/BandTileLarge.png"),
                            SmallIcon = await LoadIcon("ms-appx:///Assets/BandTileSmall.png")
                        };

                        //TextButton button = new TextButton() { ElementId = WinkTile.button1ElementId, Rect = new PageRect(10, 5, 200, 30) };
                        //WrappedTextBlock textblock = new WrappedTextBlock() { ElementId = WinkTile.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) };
                        //winkTile.PageLayouts.Add(new PageLayout(panel));

                        GroupTile groupTile = new GroupTile();
                        winkTile.PageLayouts.Add(groupTile.Layout);
                        groupTile.LoadIconsAsync(winkTile);

                        // TODO: remove test code that checks text update feature actually works
                        groupTile.Data.ById <TextBlockData>(2).Text = "Testink";

                        // 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(WinkTile.tileGuid);

                        // Create the Tile on the Band.
                        await bandClient.TileManager.AddTileAsync(winkTile);

                        //PageData pageData = new PageData
                        //(
                        //    WinkTile.page1Guid,
                        //    0,
                        //    new TextButtonData(WinkTile.button1ElementId, "Lights Status"),
                        //    new WrappedTextBlockData(WinkTile.textElementId, "...")
                        //);
                        //await bandClient.TileManager.SetPagesAsync(WinkTile.tileGuid, pageData);

                        await bandClient.TileManager.SetPagesAsync(WinkTile.tileGuid, new PageData(WinkTile.page1Guid, 0, groupTile.Data.All));

                        // Subscribe to background tile events
                        await bandClient.SubscribeToBackgroundTileEventsAsync(WinkTile.tileGuid);

                        installed = true;
                    }
                }
            }
            catch
            {
                installed = false;
            }

            return(installed);
        }