コード例 #1
0
        private async Task <ImageSource> TakeSnapshotSend(FunctionType sendType)
        {
            ImageSource outputImg = null;

            if (sendType == FunctionType.TakeSnapshot)
            {
                outputImg = await AutomationAPIHelper.TakeSnapshot();
            }
            return(outputImg);
        }
コード例 #2
0
        private async void SaveImage()
        {
            try
            {
                // Set save file options.
                SaveFileDialog dialog = new SaveFileDialog
                {
                    Filter           = "Jpeg Files|*.jpg|Png Files|*.png|Tiff Files|*.tif",
                    FileName         = "ArcGIS Earth.jpg",
                    DefaultExt       = "jpg",
                    OverwritePrompt  = true,
                    RestoreDirectory = true
                };
                if (dialog.ShowDialog() == true)
                {
                    // Get screenshot from ArcGIS Earth.
                    var bitmapImage = await AutomationAPIHelper.TakeSnapshot() as BitmapImage;

                    if (bitmapImage == null)
                    {
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Failed to save image.");
                        return;
                    }
                    using (var outStream = new MemoryStream())
                    {
                        var encoder = new BmpBitmapEncoder();
                        encoder.Frames.Add(BitmapFrame.Create(bitmapImage));
                        encoder.Save(outStream);
                        var bitmap = new Bitmap(outStream);
                        bitmap.Save(dialog.FileName);
                    }
                }
            }
            catch (Exception)
            {
                ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Failed to save image.");
            }
        }