コード例 #1
0
        private async void OnAddBarcodeButtonClick(object sender, EventArgs e)
        {
            try
            {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.InScaled = false;
                BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options));

                BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options));

                // create layout 1

                Barcode barcode1 = new Barcode(new PageRect(0, 0, 221, 70), BarcodeType.Code39);
                barcode1.Margins   = new Margins(3, 0, 0, 0);
                barcode1.ElementId = 11;

                TextBlock textBlock1 = new TextBlock(new PageRect(0, 0, 230, 30), TextBlockFont.Small, 0);
                textBlock1.Color     = Color.Red;
                textBlock1.ElementId = 21;

                FlowPanel flowPanel1 = new FlowPanel(new PageRect(15, 0, 245, 105), FlowPanelOrientation.Vertical);
                flowPanel1.AddElements(barcode1);
                flowPanel1.AddElements(textBlock1);

                PageLayout pageLayout1 = new PageLayout(flowPanel1);

                // create layout 2

                Barcode barcode2 = new Barcode(0, 0, 221, 70, BarcodeType.Pdf417);
                barcode2.Margins   = new Margins(3, 0, 0, 0);
                barcode2.ElementId = 11;

                TextBlock textBlock2 = new TextBlock(0, 0, 230, 30, TextBlockFont.Small, 0);
                textBlock2.Color     = Color.Red;
                textBlock2.ElementId = 21;

                FlowPanel flowPanel2 = new FlowPanel(15, 0, 245, 105, FlowPanelOrientation.Vertical);
                flowPanel2.AddElements(barcode2);
                flowPanel2.AddElements(textBlock2);

                PageLayout pageLayout2 = new PageLayout(flowPanel2);

                // create the tile

                BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon);
                if (mCheckboxBadging.Checked)
                {
                    builder.SetTileSmallIcon(badgeIcon);
                }
                if (mCheckboxCustomTheme.Checked)
                {
                    builder.SetTheme(mThemeView.Theme);
                }
                builder.SetPageLayouts(pageLayout1, pageLayout2);
                BandTile tile = builder.Build();

                // add tile

                try
                {
                    var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile);

                    if (result)
                    {
                        Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show();
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(Activity, "Add tile", ex);
                }

                PageData pageData1 = new PageData(Java.Util.UUID.RandomUUID(), 0);
                pageData1.Update(new BarcodeData(11, "MK12345509", BarcodeType.Code39));
                pageData1.Update(new TextButtonData(21, "MK12345509"));

                PageData pageData2 = new PageData(Java.Util.UUID.RandomUUID(), 1);
                pageData2.Update(new BarcodeData(11, "901234567890123456", BarcodeType.Pdf417));
                pageData2.Update(new TextButtonData(21, "901234567890123456"));

                await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData1, pageData2);

                Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show();

                // Refresh our tile list and count
                await RefreshData();

                RefreshControls();
            }
            catch (Exception ex)
            {
                Util.ShowExceptionAlert(Activity, "Add tile", ex);
            }
        }
コード例 #2
0
        private async void OnAddButtonTileClick(object sender, EventArgs e)
        {
            try
            {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.InScaled = false;
                BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options));

                BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options));

                FilledButton button = new FilledButton(0, 5, 210, 45);
                button.BackgroundColor = Color.Red;
                button.Margins         = new Margins(0, 5, 0, 0);
                button.ElementId       = 12;

                TextButton button2 = new TextButton(0, 0, 210, 45);
                button2.PressedColor = Color.Blue;
                button2.Margins      = new Margins(0, 5, 0, 0);
                button2.ElementId    = 21;

                FlowPanel flowPanel = new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.Vertical);
                flowPanel.AddElements(button);
                flowPanel.AddElements(button2);

                PageLayout pageLayout = new PageLayout(flowPanel);

                BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon);
                if (mCheckboxBadging.Checked)
                {
                    builder.SetTileSmallIcon(badgeIcon);
                }
                if (mCheckboxCustomTheme.Checked)
                {
                    builder.SetTheme(mThemeView.Theme);
                }
                builder.SetPageLayouts(pageLayout);
                BandTile tile = builder.Build();

                try
                {
                    var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile);

                    if (result)
                    {
                        Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show();
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(Activity, "Add tile", ex);
                }

                PageData pageData = new PageData(Java.Util.UUID.RandomUUID(), 0);
                pageData.Update(new FilledButtonData(12, Color.Yellow));
                pageData.Update(new TextButtonData(21, "Text Button"));
                await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData);

                Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show();

                // Refresh our tile list and count
                await RefreshData();

                RefreshControls();
            }
            catch (Exception ex)
            {
                Util.ShowExceptionAlert(Activity, "Add tile", ex);
            }
        }