ArcGISRuntimeXamarin.Samples.AuthorEditSaveMap.AuthorEditSaveMap.OnCloseSaveDialog C# (CSharp) Method

OnCloseSaveDialog() private method

private OnCloseSaveDialog ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private async void OnCloseSaveDialog(object sender, EventArgs e)
        {
            if (_saveDialog != null)
            {
                // Get title and description text
                var title = _titleText.Text;
                var description = _descriptionText.Text;

                // Dismiss the dialog
                _saveDialog.Dismiss();

                // Return if the text is null or empty for either
                if (string.IsNullOrEmpty(title) || string.IsNullOrEmpty(description))
                {
                    return;
                }

                // Get the map view's current extent (viewpoint) to use as the web map initial extent
                Viewpoint initialMapViewpoint = _mapView.GetCurrentViewpoint(ViewpointType.BoundingGeometry);

                // Provide some default tags for the item
                var tags = new string[] { "ArcGIS Runtime SDK", "tutorial" };

                try
                {
                    // Call a function on the view model to save the map as a new portal item
                    await _mapViewModel.SaveNewMapAsync(initialMapViewpoint, title, description, tags);

                    // Report a successful save
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                    dialogBuilder.SetTitle("Map Saved!");
                    dialogBuilder.SetMessage("Your map ('" + title + "' was saved to ArcGIS Online");
                    dialogBuilder.Show();
                }
                catch (Exception ex)
                {
                    // Show the exception message
                    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
                    dialogBuilder.SetTitle("Error");
                    dialogBuilder.SetMessage("Unable to save: " + ex.Message);
                    dialogBuilder.Show();
                }
            }
        }
        #endregion