AltitudeBand.Util.ShowExceptionAlert C# (CSharp) Method

ShowExceptionAlert() public static method

public static ShowExceptionAlert ( Android.App.Activity activity, string operation, Exception ex ) : void
activity Android.App.Activity
operation string
ex System.Exception
return void
        public static void ShowExceptionAlert(Activity activity, string operation, Exception ex)
        {
            new AlertDialog.Builder(activity)
                .SetMessage("Exception: " + ex)
                .SetTitle(operation + " failed")
                .SetPositiveButton("OK", delegate { })
                .Show()
                .Dispose();
        }
    }

Usage Example

示例#1
0
        async void AddTileButton_Click(object sender, EventArgs e)
        {
            if (0 == String.Compare(addTileButton.Text, AddTileString))
            {             // add tile
                try
                {
                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.InScaled = false;
                    var tile = new BandTile(tileId)
                    {
                        Icon      = BandImage.FromBitmap(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)),
                        Name      = "Altitude",
                        SmallIcon = BandImage.FromBitmap(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)),
                        IsScreenTimeoutDisabled = true
                    };
                    // define the page layout
                    var pageLayout = new PageLayout {
                        Root = new FlowPanel {
                            Orientation = FlowPanelOrientation.Vertical,
                            Rect        = new PageRect(0, 0, 258, 128),
                        }
                    };

                    // Page1 line1
                    var line1 = new FlowPanel {
                        Orientation = FlowPanelOrientation.Horizontal,
                        Rect        = new PageRect(0, 0, 258, 30),
                        Elements    =
                        {
                            new TextBlock {
                                ElementId         = 1,
                                Rect              = new PageRect(0, 0, 258, 30),
                                Margins           = new Margins(15, 0, 0, 0),
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Font              = TextBlockFont.Small,
                                ColorSource       = ElementColorSource.BandHighlight,
                            },
                            new TextBlock {
                                ElementId         = 2,
                                Rect              = new PageRect(0, 0, 258, 30),
                                Margins           = new Margins(10, 0, 0, 0),
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Font              = TextBlockFont.Small
                            }
                        }
                    };

                    // Page1 Line2
                    var line2 = new FlowPanel {
                        Orientation = FlowPanelOrientation.Horizontal,
                        Rect        = new PageRect(0, 38, 280, 90),
                        Elements    =
                        {
                            new Icon      {
                                ElementId         = 10,
                                Rect              = new PageRect(0, 0, 24, 24),
                                Margins           = new Margins(15, 35, 0, 0),
                                VerticalAlignment = VerticalAlignment.Top,
                                ColorSource       = ElementColorSource.BandBase
                            },
                            new Icon      {
                                ElementId         = 11,
                                Rect              = new PageRect(0, 0, 24, 24),
                                Margins           = new Margins(-24, 35, 0, 0),
                                VerticalAlignment = VerticalAlignment.Top,
                                Color             = new BandColor(0xff, 0, 0)                           //red
                            },
                            new Icon      {
                                ElementId         = 12,
                                Rect              = new PageRect(0, 0, 24, 24),
                                Margins           = new Margins(-24, 35, 0, 0),
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Color             = new BandColor(0xff, 0xff, 0)                        //yellow
                            },
                            new Icon      {
                                ElementId         = 13,
                                Rect              = new PageRect(0, 0, 24, 24),
                                Margins           = new Margins(-24, 35, 0, 0),
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Color             = new BandColor(0, 0xff, 0)                           //green
                            },
                            new TextBlock {
                                ElementId         = 5,
                                Rect              = new PageRect(0, 0, 228, 90),
                                Margins           = new Margins(10, 0, 0, 15),
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Font              = TextBlockFont.ExtraLargeNumbersBold
                            }
                        }
                    };



                    pageLayout.Root.Elements.Add(line1);
                    pageLayout.Root.Elements.Add(line2);

                    // add the page layout to the tile
                    tile.PageLayouts.Add(pageLayout);
                    // add the tile to the Band
                    await Model.Instance.Client.TileManager.AddTileAsync(tile);

                    addTileButton.Text = RemoveTileString;
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(this, "Add Tile", ex);
                }
            }
            else
            {             // remove tile
                try
                {
                    await Model.Instance.Client.TileManager.RemoveTileAsync(tileId);

                    addTileButton.Text = AddTileString;
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(this, "Remove Tile", ex);
                }
            }
        }
All Usage Examples Of AltitudeBand.Util::ShowExceptionAlert