Пример #1
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);
            }
        }
    public async Task<bool> BuildTile()
    {
      if (_bandClient != null)
      {
        var cap = await _bandClient.TileManager.GetRemainingTileCapacityAsync();
        if (cap > 0)
        {
          var tile = new BandTile(BandUiDefinitions.TileId)
          {
            Name = "Temperature reader",
            TileIcon = await LoadIcon("ms-appx:///Assets/TileIconLarge.png"),
            SmallIcon = await LoadIcon("ms-appx:///Assets/TileIconSmall.png"),
          };

          foreach (var page in BuildTileUi())
          {
            tile.PageLayouts.Add(page);
          }
          await _bandClient.TileManager.AddTileAsync(tile);
          await _bandClient.TileManager.RemovePagesAsync(BandUiDefinitions.TileId);
          await _bandClient.TileManager.SetPagesAsync(BandUiDefinitions.TileId, BuildIntialTileData());
          return true;
        }
      }
      return false;
    }
Пример #3
0
        public async Task<bool> AddTileAsync(BandTile tile)
        {
            bool result = false;
            result = await Native.AddTileAsync(tile);

            return result;
        } 
        public static Task RemoveTileTaskAsync(this IBandTileManager manager, BandTile tile)
        {
            var tcs = new TaskCompletionSource <object> ();

            manager.RemoveTileAsync(tile, tcs.AttachCompletionHandler());
            return(tcs.Task);
        }
Пример #5
0
        public async Task<bool> RegisterTile() {
            var pairedBands = await BandClientManager.Instance.GetBandsAsync();

            using (var bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0])) {
                var tiles = await bandClient.TileManager.GetTilesAsync();

                var tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();

                var tileIconBitmap = new WriteableBitmap(46, 46);
                
                var tileIcon = tileIconBitmap.ToBandIcon();

                var tileGuid = Guid.NewGuid();

                var tile = new BandTile(tileGuid) { 
                    IsBadgingEnabled = true,   
                    Name = "jcMSBWN",     
                    TileIcon = tileIcon
                };

                await bandClient.TileManager.AddTileAsync(tile);
                
                _setting.WriteSetting(SETTINGS.TILE_ID, tile.TileId);
            }

            return true;
        }
Пример #6
0
        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.
                    // WARNING! This tile guid is only an example. Please do not copy it to your test application;
                    // always create a unique guid for each application.
                    // If one application installs its tile, a second application using the same guid will fail to install
                    // its tile due to a guid conflict. In the event of such a failure, the text of the exception will not
                    // report that the tile with the same guid already exists on the band.
                    // There might be other unexpected behavior.
                    Guid myTileId = new Guid("06CF1D20-81F5-4200-AA8B-C694BAFDA0A8");
                    BandTile myTile = new BandTile(myTileId)
                    {
                        Name = "My Tile",
                        TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };

                    // 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);
                    
                    // Check if there is space for your tile on the band before adding it.
                    if (await bandClient.TileManager.GetRemainingTileCapacityAsync() > 0)
                    {
                        // Create the Tile on the Band.
                        await bandClient.TileManager.AddTileAsync(myTile);

                        // Send a notification.
                        await bandClient.NotificationManager.SendMessageAsync(myTileId, "Microsoft Band", "Hello World !", DateTimeOffset.Now, MessageFlags.ShowDialog);

                        this.viewModel.StatusMessage = "Done. Check the Tile on your Band (it's the last Tile).";
                    }
                    else
                    {
                        this.viewModel.StatusMessage = "No space on the band for your tile, remove a tile and try again.";
                    }
                }
            }
            catch (Exception ex)
            {
                this.viewModel.StatusMessage = ex.ToString();
            }
        }
Пример #7
0
        public async Task<bool> AddTileAsync(BandTile tile, CancellationToken token)
        {
            if (tile == null)
            {
                throw new ArgumentNullException("tile");
            }
            if (string.IsNullOrWhiteSpace(tile.Name))
            {
                throw new ArgumentException(BandResource.BandTileEmptyName, "tile");
            }
            if (tile.SmallIcon == null)
            {
                throw new ArgumentException(BandResource.BandTileNoSmallIcon, "tile");
            }
            if (tile.TileIcon == null)
            {
                throw new ArgumentException(BandResource.BandTileNoTileIcon, "tile");
            }
            if (tile.AdditionalIcons.Count + 2 > _constants.BandTypeConstants.MaxIconsPerTile)
            {
                throw new ArgumentException(BandResource.BandTileTooManyIcons, "tile");
            }
            if (tile.PageLayouts.Count > 5)
            {
                throw new ArgumentException(BandResource.BandTileTooManyTemplates, "tile");
            }
            foreach (PageLayout layout in tile.PageLayouts)
            {
                if (layout == null)
                {
                    throw new InvalidOperationException(BandResource.BandTileNullTemplateEncountered);
                }
                // TODO: add this back...
                //if (layout.GetSerializedByteCountAndValidate() > 768)
                //{
                //    throw new ArgumentException(BandResource.BandTilePageTemplateBlobTooBig);
                //}
            }

            await Task.Delay(500);

            // We will only run against one app so don't need much complexity here (would be nice at some 
            // point to be able the client to be able to test against a pre-configured setup of app tiles
            // on the band though)

            // request consent from user (TODO: make this a configurable property).
            // generate application ID which identifies the application package
            //var package = System.Windows.ApplicationModel.Package.current;
            var appId = _appIdProvider.GetAppId(); // TODO: Fix this - all this to be configured

            // store that against the tile...
            var tr = new TileRepresentation(tile.ToTileData(_tiles.GetCount(), appId), null);

            _tiles.AddTile(tr);

            return true;
        }
        protected virtual async Task<BandTile> CreateBandTilelAsync()
        {
            var bandTile = new BandTile(Id)
            {
                Name = Name,
                TileIcon = await TileIconUri.GetBandIconAsync(),
                SmallIcon = await SmallIconUri.GetBandIconAsync(),
            };

            return bandTile;
        }
Пример #9
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();
            }
        }
Пример #10
0
        public async void TileManager_SetNewTile()
        {
            var bandClient = await TestUtils.GetBandClientAsync();

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

            // Create the small and tile icons from writable bitmaps. 
            // Small icons are 24x24 pixels. 
            WriteableBitmap smallIconBitmap = new WriteableBitmap(24, 24);
            BandIcon smallIcon = smallIconBitmap.ToBandIcon();

            // Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels  
            // for Microsoft Band 2. 
            WriteableBitmap tileIconBitmap = new WriteableBitmap(46, 46);
            BandIcon tileIcon = tileIconBitmap.ToBandIcon();   
            
            // create a new tile 
            BandTile tile = new BandTile(tileGuid)
            {
                // set the name     
                Name = "MyTile",
                
                // set the icons     
                SmallIcon = smallIcon,
                TileIcon = tileIcon
            }; 

            // get the current set of tiles 
            try
            {
                // add the tile to the Band     
                if (await bandClient.TileManager.AddTileAsync(tile))
                {
                    // tile was successfully added          
                    // can proceed to set tile content with SetPagesAsync     
                }
                else
                {
                    // tile failed to be added, handle error     
                }
            }
            catch (BandException ex)
            {     
                // handle a Band connection exception } 

            }
        }
Пример #11
0
        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.
                    Guid myTileId = new Guid("D0BAB7A8-FFDC-43C3-B995-87AFB2A43387");
                    BandTile myTile = new BandTile(myTileId)
                    {
                        Name = "My Tile",
                        TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };

                    // 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);

                    // Send a notification.
                    await bandClient.NotificationManager.SendMessageAsync(myTileId, "Microsoft Band", "Hello World !", DateTimeOffset.Now, MessageFlags.ShowDialog);

                    this.viewModel.StatusMessage = "Done. Check the Tile on your Band (it's the last Tile).";
                }
            }
            catch (Exception ex)
            {
                this.viewModel.StatusMessage = ex.ToString();
            }
        }
        public async Task CreateAndPushTileAsync(string name)
        {
            if (BandClient == null)
            {
                await FindBands();
            }
            try
            {
                var designed = new BandTileLayout();
                BandTile myTile = new BandTile(BandTileId)
                {
                    Name = name,
                    SmallIcon = await LoadIcon("ms-appx:///Band/bandsmallicon.png"),
                    TileIcon = await LoadIcon("ms-appx:///Band/bandicon.png")
                };
                myTile.PageLayouts.Add(designed.Layout);

                _bandTileId = BandTileId;
                if (BandClient != null && BandClient.TileManager.TileInstalledAndOwned(ref _bandTileId, CancellationToken.None))
                {
                }
                else
                {
                    var tilecapacity = await BandClient?.TileManager.GetRemainingTileCapacityAsync();
                    if (tilecapacity == 0)
                    {
                        ErrorLogProxy.NotifyError("No space on Band for tile");
                        return;
                    }
                    await BandClient.TileManager.RemoveTileAsync(myTile.TileId);
                    await BandClient.TileManager.AddTileAsync(myTile);
                }
                await BandClient.TileManager.SetPagesAsync(myTile.TileId, new PageData(BandPageId, 0, designed.Data.All));
                BandClient.TileManager.TileButtonPressed += TileManager_TileButtonPressed;
                await BandClient.TileManager.StartReadingsAsync();
                MainPage.Current.MainPageViewModel.BandIconVisibility = Visibility.Visible;
                MainPage.Current.MainPageViewModel.BandIconOpacity = (float)1.0;
            }
            catch (Exception ex)
            {
                ErrorLogProxy.LogError(ex.Message);
                ErrorLogProxy.NotifyErrorInDebug(ex.Message);
            }
        }
Пример #13
0
        private async Task<bool> CreateTile(IBandClient bandClient)
        {
            try
            {
                int tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();

                if (tileCapacity > 0)
                {
                    BandTile tile = new BandTile(myTileId)
                    {
                        Name = "Ahorcado",
                        TileIcon = await LoadIcon(String.Format("{0}Logo46x46{1}", path, ext)),
                        SmallIcon = await LoadIcon(String.Format("{0}Logo24x24{1}", path, ext))
                    };

                    foreach (string code in codes)
                        tile.AdditionalIcons.Add(await LoadIcon(String.Format("{0}{1}{2}", path, code, ext)));

                    if (await bandClient.TileManager.AddTileAsync(tile))
                    {
                        CreateLayout(tile);
                        await bandClient.NotificationManager.SendMessageAsync(myTileId, "Ahorcado", "Tile was just created!",
                            DateTimeOffset.Now, MessageFlags.None);

                        return true;
                    }
                    else
                    {
                        await ShowDialogAsync("Error", "Tile not created");
                        return false;
                    }
                }
                else
                {
                    await ShowDialogAsync("Error", "No space on Band for tile");
                    return false;
                }
            }
            catch (BandException ex)
            {
                ShowDialogAsync("Error", "Error creating tile. Exception found: " + ex.Message);
                return false;
            }
        }
Пример #14
0
 public async Task<bool> RemoveTileAsync(BandTile tile)
 {
     return await RemoveTileAsync(tile, CancellationToken.None);
 }
Пример #15
0
 public void RemoveTile(BandTile tile)
 {
     var bandTile = _tiles.Where(t => t.Data.AppID == tile.TileId).FirstOrDefault();
     _tiles.Remove(bandTile);
 }
Пример #16
0
 public static async Task <bool> RemoveTileTaskAsync(this IBandTileManager manager, BandTile tile)
 {
     return((bool)await manager.RemoveTileAsync(tile).AsTask());
 }
Пример #17
0
 public static async Task <bool> AddTileTaskAsync(this IBandTileManager manager, Activity activity, BandTile tile)
 {
     return((bool)await manager.AddTileAsync(activity, tile).AsTask());
 }
Пример #18
0
		private async Task RefreshData()
		{
			if (Model.Instance.Connected)
			{
				try
				{
					var capacity = await Model.Instance.Client.TileManager.GetRemainingTileCapacityTaskAsync();
					mRemainingCapacity = capacity;
				}
				catch (Exception e)
				{
					mRemainingCapacity = -1;
					Util.ShowExceptionAlert(this, "Check capacity", e);
				}

				try
				{
					tiles = (await Model.Instance.Client.TileManager.GetTilesTaskAsync()).ToList();
//					mTileListAdapter.TileList = tiles.ToList();
				}
				catch (Exception e)
				{
					mTiles = null;
					mSelectedTile = null;
					Util.ShowExceptionAlert(this, "Get tiles", e);
				}
			}
			else
			{
				mRemainingCapacity = -1;
				mTiles = null;
			}
		}
 private async void OnRemoveTileClick(object sender, EventArgs e)
 {
     try
     {
         await Model.Instance.Client.TileManager.RemoveTileTaskAsync(mSelectedTile.TileId);
         mSelectedTile = null;
         Toast.MakeText(Activity, "Tile removed", ToastLength.Short).Show();
         await RefreshData();
         RefreshControls();
     }
     catch (Exception ex)
     {
         Util.ShowExceptionAlert(Activity, "Remove tile", ex);
     }
 }
        public async Task SyncToBand()
        {
            // Get the list of Microsoft Bands paired to the phone/tablet/PC.
            pairedBands = await BandClientManager.Instance.GetBandsAsync();

            if (pairedBands.Count() == 0)
            {
                BandStatusTxt = "You are not paired to a Microsoft Band";
                return;
            }

            BandStatusTxt = "Connecting to Microsoft Band...";
            try
            {
                // Connect to Microsoft Band.
                using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
                {
                    BandStatusTxt = "Connected...preparing to update";
                    Guid TileGuid = App.APP_SETTINGS.BandID;

                    BandTile RewardsTile = new BandTile(TileGuid)
                    {
                        Name = "Rewards Wallet",
                        SmallIcon = await LoadIcon("ms-appx:///Assets/BandTileIcon_sm.png"),
                        TileIcon = await LoadIcon("ms-appx:///Assets/BandTileIcon.png")
                    };


                    // CODE_39 Page
                    TextBlock myCardTextBlock = new TextBlock()
                    {
                        ColorSource = ElementColorSource.BandHighlight,
                        ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                        Rect = new PageRect(0, 0, 250, 30),
                        Margins = new Margins(15, 0, 15, 15)
                    };
                    Barcode barcode = new Barcode(BarcodeType.Code39)
                    {
                        ElementId = 2, // the Id of the Barcode element; we'll use it later to set its barcode value to be rendered
                        Rect = new PageRect(0, 0, 250, 100)
                    };
                    FlowPanel panel = new FlowPanel(myCardTextBlock, barcode)
                    {
                        Orientation = FlowPanelOrientation.Vertical,
                        Rect = new PageRect(0, 0, 250, 145)
                    };

                    PageLayout layout_CODE_39 = new PageLayout(panel);

                    // PDF_417 Page
                    TextBlock myCardTextBlock2 = new TextBlock()
                    {
                        ColorSource = ElementColorSource.BandHighlight,
                        ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                        Rect = new PageRect(0, 0, 250, 30),
                        Margins = new Margins(15, 0, 15, 15)
                    };
                    Barcode barcode2 = new Barcode(BarcodeType.Pdf417)
                    {
                        ElementId = 2, // the Id of the Barcode element; we'll use it later to set its barcode value to be rendered
                        Rect = new PageRect(0, 0, 250, 100)
                    };
                    FlowPanel panel2 = new FlowPanel(myCardTextBlock2, barcode2)
                    {
                        Orientation = FlowPanelOrientation.Vertical,
                        Rect = new PageRect(0, 0, 250, 145)
                    };

                    PageLayout layout_PDF_417 = new PageLayout(panel2);

                    try
                    {
                        // add the layout to the tile
                        RewardsTile.PageLayouts.Add(layout_CODE_39);
                        RewardsTile.PageLayouts.Add(layout_PDF_417);
                    }
                    catch (BandException ex)
                    {
                        // handle an error adding the layout
                    }

                    try
                    {
                        // Add tile only if it doesn't already exist
                        IEnumerable<BandTile> currTiles = await bandClient.TileManager.GetTilesAsync();
                        if (currTiles.Where(t => t.TileId == TileGuid).Count() == 0)
                        {
                            BandStatusTxt = "Updating Rewards Wallet Tile...";
                            await bandClient.TileManager.RemoveTileAsync(RewardsTile);
                            // add the tile to the Band
                            if (await bandClient.TileManager.AddTileAsync(RewardsTile))
                            {
                                // tile was successfully added
                                // can proceed to set tile content with SetPagesAsync
                            }
                            else
                            {
                                // tile failed to be added, handle error
                                BandStatusTxt = "Error adding Rewards Wallet Tile to the Band";
                            }
                        }
                    }
                    catch (BandException ex)
                    {
                        // handle a Band connection exception
                        BandStatusTxt = "Error adding Rewards Wallet Tile to the Band";
                        return;
                    }

                    await bandClient.TileManager.RemovePagesAsync(TileGuid);

                    int PagesAdded = 0;
                    for (var idx = 0; idx < App.APP_SETTINGS.RewardCards.Count && PagesAdded < 8; idx++)
                    {
                        BarcodeType pageBarcodeType = BarcodeType.Code39;

                        if (CanBeRenderedOnBand(App.APP_SETTINGS.RewardCards[idx]))
                        {                            
                            Guid messagesPageGuid = Guid.NewGuid();
                            string cardNumber = App.APP_SETTINGS.RewardCards[idx].Number;

                            // we're going from native UPC encoding to UPC39...some cases require the dropping of a check digit
                            switch(App.APP_SETTINGS.RewardCards[idx].Format)
                            {
                                case ZXing.BarcodeFormat.EAN_13:
                                case ZXing.BarcodeFormat.EAN_8:
                                case ZXing.BarcodeFormat.UPC_EAN_EXTENSION:
                                case ZXing.BarcodeFormat.UPC_A:
                                    pageBarcodeType = BarcodeType.Code39;
                                    cardNumber = App.APP_SETTINGS.RewardCards[idx].Number.Substring(0, App.APP_SETTINGS.RewardCards[idx].Number.Length - 1);
                                    break;
                                case ZXing.BarcodeFormat.PDF_417:
                                    pageBarcodeType = BarcodeType.Pdf417;
                                    cardNumber = App.APP_SETTINGS.RewardCards[idx].Number; ;
                                    break;
                                case ZXing.BarcodeFormat.CODE_128:
                                    pageBarcodeType = BarcodeType.Code39;
                                    cardNumber = App.APP_SETTINGS.RewardCards[idx].Number; ;
                                    break;
                            }

                            PageData pageContent;
                            if (pageBarcodeType == BarcodeType.Code39)
                            {
                                pageContent = new PageData(
                                    messagesPageGuid,
                                    0,
                                    new TextBlockData(1, App.APP_SETTINGS.RewardCards[idx].Name.Trim()),
                                    new BarcodeData(pageBarcodeType, barcode.ElementId.Value, cardNumber)
                                    );
                            }
                            else
                            {
                                pageContent = new PageData(
                                    messagesPageGuid,
                                    1,
                                    new TextBlockData(1, App.APP_SETTINGS.RewardCards[idx].Name.Trim()),
                                    new BarcodeData(pageBarcodeType, barcode.ElementId.Value, cardNumber)
                                    );
                            }

                            try
                            {
                                // set the page content on the Band
                                if (await bandClient.TileManager.SetPagesAsync(TileGuid, pageContent))
                                {
                                    // page content successfully set on Band
                                    BandStatusTxt = "Updating " + App.APP_SETTINGS.RewardCards[idx].Name.Trim() + " card";
                                    PagesAdded++;
                                }
                                else
                                {
                                    // unable to set content to the Band
                                    BandStatusTxt = "Failed to add " + App.APP_SETTINGS.RewardCards[idx].Name.Trim() + " card to the Band";
                                }
                            }
                            catch (BandException ex)
                            {
                                // handle a Band connection exception
                                BandStatusTxt = "Failed to add cards to the Band";
                            }
                        }
                    }
                    BandStatusTxt = "Sync to Band Complete!";
                    DispatcherTimer timer = new DispatcherTimer();
                    timer.Tick += (object sender, object e) => {
                        timer.Stop();
                        BandStatusTxt = string.Empty;
                    };
                    timer.Interval = new TimeSpan(0, 0, 3);
                    timer.Start();
                }
            }
            catch(Exception e)
            {
                BandStatusTxt = "Failed to connect to the Microsoft Band";
                
            }
        }
Пример #21
0
 private async Task<BandTile> CreateTile()
 {
     // create a new Guid for the tile 
     Guid tileGuid = new Guid("D781F673-6D05-4D69-BCFF-EA7E706C3418");
     // create a new tile with a new Guid 
     BandTile tile = new BandTile(tileGuid)
     {
         // enable badging (the count of unread messages)     
         IsBadgingEnabled = true,
         // set the name     
         Name = "HelloBand",
         // set the icons     
         SmallIcon = await LoadIcon("ms-appx:///Assets/Bat-Man24.png"),
         TileIcon = await LoadIcon("ms-appx:///Assets/Bat-Man46.png")
     };
     return tile;
 }
Пример #22
0
        private async void bandRegistration_Click(object sender, RoutedEventArgs e)
        {
            var pairedBands = await BandClientManager.Instance.GetBandsAsync();
            using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
            {
                // Create a Tile.
                Guid myTileId = new Guid("9DE3027F-287B-43AB-B0AA-84D80116FC7E");
                BandTile myTile = new BandTile(myTileId)
                {
                    Name = "KAIT",
                    TileIcon = await LoadIcon("ms-appx:///Assets/BandTileIconLarge.png"),
                    SmallIcon = await LoadIcon("ms-appx:///Assets/BandTileIconSmall.png")
                };
                await bandClient.TileManager.AddTileAsync(myTile);

                // Send a notification.
                await bandClient.NotificationManager.SendMessageAsync(myTileId, "KAIT", "Connected To Phone", DateTimeOffset.Now, MessageFlags.ShowDialog);
                ApplicationData.Current.LocalSettings.Values["Paired"] = true;
                bandRegistration.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            }
        }
Пример #23
0
        /// <summary>
        /// Ensure if the tile should exist it does, if it shouldn't it won't.
        /// </summary>
        public async Task<bool> EnsureBandTileState()
        {
            IBandInfo pairedBand = await GetPairedBand();
            if(pairedBand == null)
            {
                // We don't have a band.
                return false;
            }
          
            bool wasSuccess = true;
            try
            {
                // Try to connect to the band.
                using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBand))
                {
                    // Get the current set of tiles
                    IEnumerable<BandTile> tiles = await bandClient.TileManager.GetTilesAsync();

                    // See if our tile exists
                    BandTile baconitTile = null;
                    foreach(BandTile tile in tiles)
                    {
                        if(tile.TileId.Equals(c_bandTileGuid))
                        {
                            baconitTile = tile;
                        }
                    }

                    if(baconitTile == null)
                    {
                        // The tile doesn't exist
                        if(ShowInboxOnBand)
                        {
                            // We need a tile, try to make one.
                            int tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();
                            if (tileCapacity == 0)
                            {
                                m_baconMan.MessageMan.ShowMessageSimple("Can't add tile to Band", "Baconit can't add a tile to your Microsoft Band because you reached the maximum number of tile. To add the Baconit tile remove one of the other tiles on your band.");
                                wasSuccess = false;
                            }
                            else
                            {
                                // Create the icons
                                BandIcon smallIcon = null;
                                BandIcon tileIcon = null;

                                // This icon should be 24x24 pixels
                                WriteableBitmap smallIconBitmap = await BitmapFactory.New(1, 1).FromContent(new Uri("ms-appx:///Assets/AppAssets/BandIcons/BandImage24.png", UriKind.Absolute));
                                smallIcon = smallIconBitmap.ToBandIcon();
                                // This icon should be 46x46 pixels
                                WriteableBitmap tileIconBitmap = await BitmapFactory.New(1, 1).FromContent(new Uri("ms-appx:///Assets/AppAssets/BandIcons/BandImage46.png", UriKind.Absolute));
                                tileIcon = tileIconBitmap.ToBandIcon();
     
                                // Create a new tile
                                BandTile tile = new BandTile(c_bandTileGuid)
                                {
                                    IsBadgingEnabled = true,
                                    Name = "Baconit",
                                    SmallIcon = smallIcon,
                                    TileIcon = tileIcon
                                };

                                if (!await bandClient.TileManager.AddTileAsync(tile))
                                {
                                    m_baconMan.MessageMan.DebugDia("failed to create tile");
                                    m_baconMan.TelemetryMan.ReportUnexpectedEvent(this, "FailedToCreateTileOnBand");
                                    wasSuccess = false;
                                }
                            }
                        }   
                    }
                    else
                    {
                        // The tile exists
                        if (!ShowInboxOnBand)
                        {
                            // We need to remove it
                            if (!await bandClient.TileManager.RemoveTileAsync(baconitTile))
                            {
                                m_baconMan.MessageMan.DebugDia("failed to remove tile");
                                m_baconMan.TelemetryMan.ReportUnexpectedEvent(this, "FailedToRemoveTileOnBand");
                                wasSuccess = false;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                m_baconMan.MessageMan.DebugDia("band connect failed", e);
                wasSuccess = false;
            }
            return wasSuccess;
        }
Пример #24
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            this.viewModel.StatusMessage = "Running ...";

            try
            {
                // Get the list of Microsoft Bands paired to the phone/tablet/PC.
                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]))
                {
                    // We'll create a Tile that looks like this:
                    // +--------------------+
                    // | MY CARD            | 
                    // | |||||||||||||||||  | 
                    // | 123456789          |
                    // +--------------------+
                    
                    // First, we'll prepare the layout for the Tile page described above.
                    TextBlock myCardTextBlock = new TextBlock()
                    {
                        Color = Colors.Blue.ToBandColor(),
                        ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                        Rect = new PageRect(0, 0, 200, 25)
                    };
                    Barcode barcode = new Barcode(BarcodeType.Code39)
                    {
                        ElementId = 2, // the Id of the Barcode element; we'll use it later to set its barcode value to be rendered
                        Rect = new PageRect(0, 0, 250, 50)
                    };
                    TextBlock digitsTextBlock = new TextBlock()
                    {
                        ElementId = 3, // the Id of the TextBlock element; we'll use it later to set its text to "123456789"
                        Rect = new PageRect(0, 0, 200, 25)
                    };
                    FlowPanel panel = new FlowPanel(myCardTextBlock, barcode, digitsTextBlock)
                    {
                        Orientation = FlowPanelOrientation.Vertical,
                        Rect = new PageRect(0, 0, 250, 100)
                    };
                    
                    // Now we'll create the Tile.
                    Guid myTileId = new Guid("D781F673-6D05-4D69-BCFF-EA7E706C3418");
                    BandTile myTile = new BandTile(myTileId)
                    {
                        Name = "My Tile",
                        TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };
                    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(myTile.TileId);

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

                    // And create the page with the specified texts and values.
                    PageData page = new PageData(
                        Guid.NewGuid(), // the Id for the page
                        0, // the index of the layout to be used; we have only one layout in this sample app, but up to 5 layouts can be registered for a Tile
                        new TextBlockData(myCardTextBlock.ElementId.Value, "MY CARD"),
                        new BarcodeData(barcode.BarcodeType, barcode.ElementId.Value, "123456789"),
                        new TextBlockData(digitsTextBlock.ElementId.Value, "123456789"));

                    await bandClient.TileManager.SetPagesAsync(myTile.TileId, page);

                    this.viewModel.StatusMessage = "Done. Check the Tile on your Band (it's the last Tile).";
                }
            }
            catch (Exception ex)
            {
                this.viewModel.StatusMessage = ex.ToString();
            }
        }
Пример #25
0
        public async Task<bool> RemoveTileAsync(BandTile tile, CancellationToken token)
        {
            await Task.Run(() =>
            {
                _tiles.RemoveTile(tile);
            }, token);

            return true;
        }
Пример #26
0
        async private void Click_AddTile(object sender, RoutedEventArgs e)
        {
            AppBarButton_Pin.IsEnabled = false;
            try
            {
                // determine the number of available tile slots on the Band
                int tileCapacity = await bandClient.TileManager.GetRemainingTileCapacityAsync();
                if (tileCapacity < 1)
                {
                    return;
                }
            }
            catch (BandException ex)
            {
                // handle a Band connection exception }
            }
            
            // Create the small and tile icons from writable bitmaps.
            // Small icons are 24x24 pixels.
            BandIcon smallIcon;
            StorageFile imageFile_small = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Band_SmallIcon.png"));
            using (IRandomAccessStream fileStream = await imageFile_small.OpenAsync(FileAccessMode.Read))
            {
                WriteableBitmap bitmap = new WriteableBitmap(24, 24);
                await bitmap.SetSourceAsync(fileStream);
                smallIcon = bitmap.ToBandIcon();
            }

            // Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels
            // for Microsoft Band 2.
            BandIcon tileIcon;
            StorageFile imageFile_large = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Band_LargeIcon.png"));
            using (IRandomAccessStream fileStream = await imageFile_large.OpenAsync(FileAccessMode.Read))
            {
                WriteableBitmap bitmap = new WriteableBitmap(48, 48);
                await bitmap.SetSourceAsync(fileStream);
                tileIcon = bitmap.ToBandIcon();
            }

            // create a new Guid for the tile
            Guid newGuid = Guid.NewGuid();
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values["BOLGuid"] = tileGuid = newGuid;
            // create a new tile with a new Guid
            tile = new BandTile(tileGuid)
            {
                // enable badging (the count of unread messages)
                IsBadgingEnabled = true,
                // set the name
                Name = "Band of Love",
                // set the icons
                SmallIcon = smallIcon,
                TileIcon = tileIcon
            };

            // Create a scrollable vertical panel that will hold 2 text messages.
            ScrollFlowPanel panel = new ScrollFlowPanel
            {
                Rect = new PageRect(0, 0, 245, 102),
                Orientation = FlowPanelOrientation.Vertical,
                ScrollBarColorSource = ElementColorSource.BandBase
            };

            // add the text block to contain the first message
            panel.Elements.Add(
                new WrappedTextBlock
                {
                    ElementId = (short)TileMessagesLayoutElementId.Message1,
                    Rect = new PageRect(0, 0, 245, 102),
                    // left, top, right, bottom margins
                    Margins = new Margins(15, 0, 15, 0),
                    Color = new BandColor(0xFF, 0xFF, 0xFF),
                    Font = WrappedTextBlockFont.Small
                }
            );

            // add the text block to contain the second message
            panel.Elements.Add(
                new WrappedTextBlock
                {
                    ElementId = (short)TileMessagesLayoutElementId.Message2,
                    Rect = new PageRect(0, 0, 245, 102),
                    // left, top, right, bottom margins
                    Margins = new Margins(15, 0, 15, 0),
                    Color = new BandColor(0xFF, 0xFF, 0xFF),
                    Font = WrappedTextBlockFont.Small
                }
            );
            // create the page layout
            PageLayout layout = new PageLayout(panel);

            try
            {     // add the layout to the tile
                tile.PageLayouts.Add(layout);
            }
            catch (BandException ex)
            {
                // handle an error adding the layout
            }

            try
            {
                // add the tile to the Band
                if (await bandClient.TileManager.AddTileAsync(tile))
                {
                    // tile was successfully added
                    AppBarButton_Pin.Visibility = Visibility.Collapsed;
                    AppBarButton_UnPin.Visibility = Visibility.Visible;
                    AppBarButton_UnPin.IsEnabled = true;

                    // can proceed to set tile content with SetPagesAsync
                }
                else
                {
                    // tile failed to be added, handle error
                }
            }
            catch (BandException ex)
            {
                // handle a Band connection exception }
            }

            // create a new Guid for the messages page
            Guid messagesPageGuid = Guid.NewGuid();
            // create the object that contains the page content to be set
            PageData pageContent = new PageData(
                messagesPageGuid,
                // specify which layout to use for this page
                (int)TileLayoutIndex.MessagesLayout,
                new WrappedTextBlockData(
                    (Int16)TileMessagesLayoutElementId.Message1,
                    "This is the text of the first message"
                ),
                new WrappedTextBlockData(
                    (Int16)TileMessagesLayoutElementId.Message2,
                    "This is the text of the second message"
                )
            );
            try
            {
                // set the page content on the Band
                if (await bandClient.TileManager.SetPagesAsync(tileGuid, pageContent))
                {
                    // page content successfully set on Band
                }
                else
                {
                    // unable to set content to the Band
                }
            }
            catch (BandException ex)
            {
                // handle a Band connection exception
            }
        }
Пример #27
0
 public Task<bool> AddTileAsync(BandTile tile)
 {
     throw new NotImplementedException();
 }
        private async void BandTileCreator()
        {
            try
            {
                var bandClientManager = BandClientManager.Instance;
                var pairedBands = await bandClientManager.GetBandsAsync();
                if (pairedBands.Length == 0)
                {
                    var msg = new MessageDialog("No bands connected! \nPlease connect a band and try again");
                    await msg.ShowAsync();
                    await Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));
                    return;
                }

                var bandInfo = pairedBands.FirstOrDefault();
                var bandClient = await bandClientManager.ConnectAsync(bandInfo);

                var tileManager = bandClient.TileManager;
                // get the current set of tiles
                var tiles = await tileManager.GetTilesAsync();
                // get the number of tiles we can add
                var capacity = await tileManager.GetRemainingTileCapacityAsync();
                // create a new tile
                var tile = new BandTile(Guid.NewGuid())
                {
                   Name = "BeFriendBeta"
                };
                // add the tile
                await tileManager.AddTileAsync(tile);
               
                tileManager.TileButtonPressed += (sender, e) => {
                    var frame = Window.Current.Content as Frame;
                    if (frame != null)
                    {
                        frame.Navigate(typeof(Sospage));
                    }
                };
                
                
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }


        }
		public static Task RemoveTileTaskAsync (this IBandTileManager manager, BandTile tile)
		{
			var tcs = new TaskCompletionSource<object> ();
			manager.RemoveTileAsync (tile, tcs.AttachCompletionHandler ());
			return tcs.Task;
		}
Пример #30
0
        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();
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // all the splicing is optional as we are going to populate 
            // the members/events from three different views (fragment/header/footer)

            var rootView = inflater.Inflate(Resource.Layout.fragment_tiles, container, false);
            Geneticist.Splice(this, rootView);

            var header = inflater.Inflate(Resource.Layout.fragment_tiles_header, null);
            Geneticist.Splice(this, header);

            var footer = inflater.Inflate(Resource.Layout.fragment_tiles_footer, null);
            Geneticist.Splice(this, footer);

            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;
        }
Пример #32
0
        private async Task RegisterBandTileInternalAsync(IBandClient client)
        {
            await this.UnRegisterBandTileInternalAsync(client);

            var bandHardwareVersion = int.Parse(await client.GetHardwareVersionAsync());

            if (bandHardwareVersion < 20)
                throw new CTimeException(CTime2CoreResources.Get("BandService.OnlyBand2Supported"));

            var availableTileCount = await client.TileManager.GetRemainingTileCapacityAsync();

            if (availableTileCount == 0)
                throw new CTimeException(CTime2CoreResources.Get("BandService.NoSpaceForBandTile"));

            var tile = new BandTile(BandConstants.TileId)
            {
                SmallIcon = await this.GetBandIcon("TileIcon24px.png"),
                TileIcon = await this.GetBandIcon("TileIcon48px.png"),
                Name = "c-time"
            };

            var testConnectionPageLayout = new TestConnectionPageLayout();
            tile.PageLayouts.Add(testConnectionPageLayout.Layout);

            var stampPageLayout = new StampPageLayout();
            tile.PageLayouts.Add(stampPageLayout.Layout);

            var startPageLayout = new StartPageLayout();
            tile.PageLayouts.Add(startPageLayout.Layout);

            await client.TileManager.AddTileAsync(tile);

            await this.ChangeTileDataToLoadingAsync(client);

            await client.SubscribeToBackgroundTileEventsAsync(tile.TileId);
        }
Пример #33
0
        private async Task<bool> CreateLayout(BandTile bandTile)
        {
            bool result = false;

            using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(band))
            {
                Microsoft.Band.Tiles.Pages.TextBlock myBandTextBlock = new Microsoft.Band.Tiles.Pages.TextBlock()
                {
                    ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                    Rect = new PageRect(0, 0, 200, 25)
                };

                FlowPanel panel = new FlowPanel(myBandTextBlock)
                {
                    Orientation = FlowPanelOrientation.Vertical,
                    Rect = new PageRect(60, 50, 250, 100)
                };
                
                bandTile.PageLayouts.Add(new PageLayout(panel));

                await bandClient.TileManager.RemoveTileAsync(bandTile.TileId);
                try
                {
                    // add the tile to the Band  
                    if (await bandClient.TileManager.AddTileAsync(bandTile))
                    {
                        // And create the page with the specified texts and values.
                        PageData page = new PageData(
                            Guid.NewGuid(), // the Id for the page
                            0, // the index of the layout to be used; we have only one layout in this sample app, but up to 5 layouts can be registered for a Tile
                            new TextBlockData(myBandTextBlock.ElementId.Value, "Hello Band!"));

                        await bandClient.TileManager.SetPagesAsync(bandTile.TileId, page);
                        result = true;
                    }
                }
                catch (Exception ex)
                {
                    result = false;
                }
                return result;
            }
        }
Пример #34
0
        private void CreateLayout(BandTile tile)
        {
            ScrollFlowPanel panel = new ScrollFlowPanel()
            {
                Rect = new PageRect(0, 0, 245, 102),
                Orientation = FlowPanelOrientation.Vertical
            };

            Icon icon = new Icon()
            {
                ElementId = 3,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                VerticalAlignment = VerticalAlignment.Top,
            };

            var nombre = new WrappedTextBlock
            {
                ElementId = 1,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                Color = new BandColor(0xFF, 0xFF, 0xFF),
                Font = WrappedTextBlockFont.Small,
                VerticalAlignment = VerticalAlignment.Top
            };

            var motto = new WrappedTextBlock
            {
                ElementId = 2,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                Color = new BandColor(0xFF, 0xFF, 0xFF),
                Font = WrappedTextBlockFont.Small,
                VerticalAlignment = VerticalAlignment.Top
            };

            panel.Elements.Add(icon); 
            panel.Elements.Add(nombre);
            panel.Elements.Add(motto);

            PageLayout layout = new PageLayout(panel);
            tile.PageLayouts.Add(layout);
        }