ArcGISRuntime.UWP.Samples.AuthorMap.AuthorMap.UpdatePortalItemThumbnailAsync C# (CSharp) Метод

UpdatePortalItemThumbnailAsync() приватный Метод

private UpdatePortalItemThumbnailAsync ( string imageFileName ) : void
imageFileName string
Результат void
        private async void UpdatePortalItemThumbnailAsync(string imageFileName)
        {
            // Update the portal item with a thumbnail image of the current map
            try
            {
                // Get the map's portal item
                PortalItem newPortalItem = MyMapView.Map.Item as PortalItem;

                // Open the image file (stored in the device's Pictures folder)
                var mapImageFile = await KnownFolders.PicturesLibrary.GetFileAsync(imageFileName);

                if (mapImageFile != null)
                {
                    // Get a thumbnail image (scaled down version) of the original
                    var thumbnailData = await mapImageFile.GetScaledImageAsThumbnailAsync(0);

                    // Assign the thumbnail data (file stream) to the content object
                    newPortalItem.SetThumbnailWithImage(thumbnailData.AsStreamForRead());

                    // Update the portal item with the new content (just the thumbnail will be updated)
                    await newPortalItem.UpdateItemPropertiesAsync();

                    // Delete the map image file from disk
                    mapImageFile.DeleteAsync();
                }
            }
            catch (Exception ex)
            {
                // Warn the user that the thumbnail could not be updated
                var dialog = new MessageDialog("Unable to update thumbnail for portal item: " + ex.Message, "Portal Item Thumbnail");
                dialog.ShowAsync();
            }
        }