コード例 #1
0
        private async System.Threading.Tasks.Task CopyToClipboardAsMetafileAsync()
        {
            if (_rSession != null)
            {
                string fileName = Path.GetTempFileName();
                using (IRSessionEvaluation eval = await _rSession.BeginEvaluationAsync()) {
                    await eval.ExportToMetafile(fileName, PixelsToInches(_lastPixelWidth), PixelsToInches(_lastPixelHeight));

                    VsAppShell.Current.DispatchOnUIThread(
                        () => {
                        try {
                            var mf = new System.Drawing.Imaging.Metafile(fileName);
                            Clipboard.SetData(DataFormats.EnhancedMetafile, mf);

                            SafeFileDelete(fileName);
                        } catch (Exception e) when(!e.IsCriticalException())
                        {
                            MessageBox.Show(string.Format(Resources.PlotCopyToClipboardError, e.Message));
                        }
                    });
                }
            }
        }