async partial void ToggleCustomTileClick(UIButton sender)
        {
            if (client != null && client.IsDeviceConnected)
            {
                Output("Creating tile...");

                NSError operationError;
                var     tileName  = "A tile";
                var     tileIcon  = BandIcon.FromUIImage(UIImage.FromBundle("A.png"), out operationError);
                var     smallIcon = BandIcon.FromUIImage(UIImage.FromBundle("Aa.png"), out operationError);
                var     tile      = BandTile.Create(customId, tileName, tileIcon, smallIcon, out operationError);

                var textBlock = new BandTextBlock(BandRect.Create(0, 0, 230, 40), BandTextBlockFont.Small, 25);
                textBlock.ElementId           = 10;
                textBlock.HorizontalAlignment = BandPageElementHorizontalAlignment.Left;
                textBlock.BaselineAlignment   = BandTextBlockBaselineAlignment.Absolute;
                textBlock.Color = BandColor.FromRgb(0xff, 0xff, 0xff);

                var barcode = new BandBarcode(BandRect.Create(0, 5, 230, 95), BandBarcodeType.CODE39);
                barcode.ElementId = 11;
                barcode.Color     = BandColor.FromRgb(0xff, 0xff, 0xff);

                var flowList = new BandFlowList(BandRect.Create(15, 0, 260, 105), BandFlowListOrientation.Vertical);
                flowList.Margins = BandMargins.Create(0, 0, 0, 0);
                flowList.Color   = null;
                flowList.Children.Add(textBlock);
                flowList.Children.Add(barcode);

                var pageLaypout = new BandPageLayout();
                pageLaypout.Root = flowList;
                tile.PageLayouts.Add(pageLaypout);

                try {
                    Output("Adding tile...");
                    await client.TileManager.AddTileTaskAsync(tile);
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                try {
                    Output("Creating page...");
                    var pageValues = new BandPageElementData [] {
                        BandPageBarcodeCode39Data.Create(11, "A1 B", out operationError),
                        BandPageTextData.Create(10, "Barcode value: A1 B", out operationError)
                    };
                    var page = BandPageData.Create(pageId, 0, pageValues);

                    await client.TileManager.SetPagesTaskAsync(new[] { page }, customId);

                    Output("Completed custom page!");
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }
            }
            else
            {
                Output("Band is not connected. Please wait....");
            }
        }
        async partial void ToggleAppTileClick(UIButton sender)
        {
            if (_client != null && _client.IsDeviceConnected)
            {
                Output("Creating tile...");

                // the number of tile spaces left
                var capacity = await _client.TileManager.RemainingTileCapacityTaskAsync();

                Output("Remaning tile space: " + capacity);

                // create the tile
                NSError      operationError;
                const string tileName  = "CRM Notifications";
                var          tileIcon  = BandIcon.FromUIImage(UIImage.FromBundle("CRM.png"), out operationError);
                var          smallIcon = BandIcon.FromUIImage(UIImage.FromBundle("CRMb.png"), out operationError);
                var          tile      = BandTile.Create(TileId, tileName, tileIcon, smallIcon, out operationError);

                // get the tiles
                try
                {
                    var tiles = await _client.TileManager.GetTilesTaskAsync();

                    if (tiles.Any(x => x.TileId.AsString() == TileId.AsString()))
                    {
                        // a tile exists, so remove it
                        await _client.TileManager.RemoveTileTaskAsync(TileId);

                        Output("Removed tile!");
                    }
                    else
                    {
                        // the tile does not exist, so add it
                        await _client.TileManager.AddTileTaskAsync(tile);

                        Output("Added tile!");
                    }
                }
                catch (BandException ex)
                {
                    Output("Error: " + ex.Message);
                }
            }
            else
            {
                Output("Band is not connected. Please wait....");
            }
        }
示例#3
0
        async partial void AddButtonPageClick(UIButton sender)
        {
            if (client != null && client.IsConnected)
            {
                Output("Creating tile...");

                // remove an old tile
                try {
                    var tiles = await client.TileManager.GetTilesTaskAsync();

                    if (tiles.Any(x => x.TileId.AsString() == tileId.AsString()))
                    {
                        // a tile exists, so remove it
                        await client.TileManager.RemoveTileTaskAsync(tileId);

                        Output("Removed tile!");
                    }
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                // create the tile
                NSError operationError;
                var     tileName  = "iOS Sample";
                var     tileIcon  = BandIcon.FromUIImage(UIImage.FromBundle("tile.png"), out operationError);
                var     smallIcon = BandIcon.FromUIImage(UIImage.FromBundle("badge.png"), out operationError);
                var     tile      = BandTile.Create(tileId, tileName, tileIcon, smallIcon, out operationError);
                tile.BadgingEnabled = true;

                // create the button page
                var textBlock = new TextBlock(PageRect.Create(0, 0, 200, 40), TextBlockFont.Small);
                textBlock.ElementId           = 10;
                textBlock.Baseline            = 25;
                textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Relative;
                textBlock.AutoWidth           = false;
                textBlock.Color   = BandColor.FromUIColor(UIColor.Red, out operationError);
                textBlock.Margins = Margins.Create(5, 2, 5, 2);

                var button = new TextButton(PageRect.Create(0, 0, 200, 40));
                button.ElementId           = 11;
                button.HorizontalAlignment = HorizontalAlignment.Center;
                button.PressedColor        = BandColor.FromUIColor(UIColor.Purple, out operationError);
                button.Margins             = Margins.Create(5, 2, 5, 2);

                var flowPanel = new FlowPanel(PageRect.Create(15, 0, 260, 105));
                flowPanel.AddElement(textBlock);
                flowPanel.AddElement(button);

                var pageLayout = new PageLayout();
                pageLayout.Root = flowPanel;
                tile.PageLayouts.Add(pageLayout);

                // add the tile to the band
                try {
                    Output("Adding tile...");
                    await client.TileManager.AddTileTaskAsync(tile);
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                // set the page data
                try {
                    Output("Creating page data...");
                    var pageValues = new PageElementData [] {
                        TextBlockData.Create(textBlock.ElementId, "TextButton sample", out operationError),
                        TextButtonData.Create(button.ElementId, "Press Me", out operationError)
                    };
                    var page = PageData.Create(barcodePageId, 0, pageValues);

                    await client.TileManager.SetPagesTaskAsync(new[] { page }, tileId);

                    Output("Completed custom page!");
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }
            }
            else
            {
                Output("Band is not connected. Please wait....");
            }
        }
示例#4
0
        async partial void RegisterNotificationsClick(UIButton sender)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var types      = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert;
                var mySettings = UIUserNotificationSettings.GetSettingsForTypes(types, null);
                UIApplication.SharedApplication.RegisterUserNotificationSettings(mySettings);
            }

            if (client != null && client.IsConnected)
            {
                Output("Creating tile...");

                // remove an old tile
                try {
                    var tiles = await client.TileManager.GetTilesTaskAsync();

                    if (tiles.Any(x => x.TileId.AsString() == tileId.AsString()))
                    {
                        // a tile exists, so remove it
                        await client.TileManager.RemoveTileTaskAsync(tileId);

                        Output("Removed tile!");
                    }
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                // create the tile
                NSError operationError;
                var     tileName  = "iOS Sample";
                var     tileIcon  = BandIcon.FromUIImage(UIImage.FromBundle("tile.png"), out operationError);
                var     smallIcon = BandIcon.FromUIImage(UIImage.FromBundle("badge.png"), out operationError);
                var     tile      = BandTile.Create(tileId, tileName, tileIcon, smallIcon, out operationError);
                tile.BadgingEnabled = true;

                // add the tile to the band
                try {
                    Output("Adding tile...");
                    await client.TileManager.AddTileTaskAsync(tile);
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                try {
                    Output("Registering notification...");
                    await client.NotificationManager.RegisterNotificationTaskAsync();

                    Output("Completed registration!");

                    Output("Sending notification...");

                    var localNotification = new UILocalNotification();
                    localNotification.FireDate    = NSDate.Now.AddSeconds(20);
                    localNotification.TimeZone    = NSTimeZone.DefaultTimeZone;
                    localNotification.AlertBody   = "Local notification";
                    localNotification.AlertAction = "View Details";
                    localNotification.SoundName   = UILocalNotification.DefaultSoundName;

                    UIApplication.SharedApplication.PresentLocalNotificationNow(localNotification);

                    Output("Notification sent!");
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }
            }
            else
            {
                Output("Band is not connected. Please wait....");
            }
        }