Ejemplo n.º 1
0
        public void Save()
        {
            var       toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            PopupMenu menu    = new PopupMenu(this, toolbar);

            menu.MenuItemClick += (s1, arg1) => {
                string type        = arg1.Item.TitleFormatted.ToString();
                string PathAndName = Path.Combine(Environment.ExternalStorageDirectory.ToString(), FILENAME) + "." + type;
                switch (type)
                {
                case "CSV":
                    grid.Save(PathAndName, GridFileFormat.Csv, System.Text.Encoding.UTF8, GridSaveOptions.SaveColumnHeaders);
                    menu.Dismiss();
                    break;

                case "Txt":
                    grid.Save(PathAndName, GridFileFormat.Text, System.Text.Encoding.UTF8, GridSaveOptions.SaveColumnHeaders);
                    menu.Dismiss();
                    break;

                case "HTML":
                    grid.Save(PathAndName, GridFileFormat.Html, System.Text.Encoding.UTF8, GridSaveOptions.SaveColumnHeaders);
                    menu.Dismiss();
                    break;
                }
                if (type != "Cancel")
                {
                    Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                    alert.SetTitle("Saved");
                    alert.SetMessage("File has been saved to: " + PathAndName);
                    alert.SetPositiveButton("OK", (senderAlert, args) => {});
                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
                if (type == "HTML")
                {
                    //Device.OpenUri(new Uri(PathAndName));
                }
            };
            menu.Inflate(Resource.Layout.PopUp);
            menu.Show();
        }