Ejemplo n.º 1
0
        public Task Invoke(IReadOnlyDictionary <string, string> parameters, HSSettings settingsContext)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (settingsContext == null)
            {
                throw new ArgumentNullException(nameof(settingsContext));
            }

            ScreenshotAggregator.OpenPictureSaveDirectory(settingsContext);
            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        protected static async Task ProcessCapturing(Screenshot screenshot, HSSettings settingsContext)
        {
            if (screenshot == null)
            {
                throw new ArgumentNullException(nameof(screenshot));
            }
            if (settingsContext == null)
            {
                throw new ArgumentNullException(nameof(settingsContext));
            }

            ScreenshotAggregator.HandleScreenshot(screenshot, settingsContext);

            switch (settingsContext.ActionAfterImageCapture)
            {
            case ImageCaptureHandlingAction.OpenEditor:
                var shower = new ShotEditor(screenshot, HolzShotsApplication.Instance.Uploaders, settingsContext);
                shower.Show();
                return;

            case ImageCaptureHandlingAction.Upload:
                try
                {
                    var result = await UploadDispatcher.InitiateUploadToDefaultUploader(screenshot.Image, settingsContext, HolzShotsApplication.Instance.Uploaders, null, null).ConfigureAwait(true);

                    UploadHelper.InvokeUploadFinishedUI(result, settingsContext);
                }
                catch (UploadCanceledException)
                {
                    NotificationManager.ShowOperationCanceled();
                }
                catch (UploadException ex)
                {
                    await NotificationManager.UploadFailed(ex);
                }
                return;

            case ImageCaptureHandlingAction.Copy:
                try
                {
                    Clipboard.SetImage(screenshot.Image);
                    NotificationManager.ShowImageCopiedConfirmation();
                }
                catch (Exception ex) when(ex is ExternalException ||
                                          ex is System.Threading.ThreadStateException ||
                                          ex is ArgumentNullException)
                {
                    NotificationManager.CopyImageFailed(ex);
                }
                return;

            case ImageCaptureHandlingAction.SaveAs:
                PromptSaveAs(screenshot, settingsContext);
                return;

            case ImageCaptureHandlingAction.None:
                return;     // Intentionally do nothing

            default:
                return;
            }
        }