示例#1
0
        //Close Window with fade out animation
        private async void CloseSnap(bool result, int delay = 0, string errorMessage = null)
        {
            await this.AnimateAsync(OpacityProperty, Opacity, 0, 150, delay);

            try {
                if (result)
                {
                    await ScreenshotHelper.FinishGif(SelectionStream, HwndName);

                    try {
                        DialogResult = true;
                    } catch {
                        // not dialog
                    }
                    return;
                }
                if (Error)
                {
                    await Statics.ShowNotificationAsync(string.Format(strings.uploadingErrorGif, errorMessage),
                                                        NotificationWindow.NotificationType.Error);
                }
            } catch {
                // could not finish screenshot
            }
            try {
                DialogResult = false;
            } catch {
                // not dialog
            }
        }
示例#2
0
        private async void StartWithArguments()
        {
            CommandlineArgs args = CommandLineHelper.GetCommandlineArguments();

            switch (args.Argument)
            {
            case CommandLineHelper.Argument.Autostart:
                //Tray with Hotkeys
                await StartTray.Initialize(this);

                break;

            case CommandLineHelper.Argument.Gif:
                //GIF Recording Capture
                using (GifWindow window = new GifWindow())
                    window.ShowDialog();
                break;

            case CommandLineHelper.Argument.Snipe:
                //Normal Image Capture
                using (ScreenshotWindow window = new ScreenshotWindow())
                    window.ShowDialog();
                break;

            case CommandLineHelper.Argument.Upload:
                //Context Menu Instant Upload
                if (args.UploadFiles.Count > 1)
                {
                    //1 or more files
                    //TODO: Implement "%1" more than 1
                    await StartUpload.UploadMultiple(args.UploadFiles);
                }
                else if (args.UploadFiles.Count == 1)
                {
                    //1 File
                    await StartUpload.UploadSingle(args.UploadFiles[0]);
                }
                else
                {
                    //No Image File detected
                    await Statics.ShowNotificationAsync(Properties.strings.notAnImage, NotificationWindow.NotificationType.Error);
                }
                break;
            }

            //Wait for every Notification to close
            if (NotificationWindow.IsShown)
            {
                await Task.Delay(NotificationWindow.ShowDuration);
            }

            Application.Current.Shutdown();
        }
示例#3
0
        //Close Window with fade out animation
        private async void CloseSnap(bool result, int delay = 0)
        {
            await this.AnimateAsync(OpacityProperty, Opacity, 0, 150, delay);

            try {
                if (result)
                {
                    await ScreenshotHelper.FinishScreenshot(SelectionStream, HwndName);

                    DialogResult = true;
                    return;
                }
                if (Error)
                {
                    await Statics.ShowNotificationAsync(strings.uploadingError, NotificationWindow.NotificationType.Error);
                }
            } catch {
                // could not finish screenshot
            }
            DialogResult = false;
        }
        //Close Window with fade out animation
        private async void CloseSnap(bool result, int delay = 0)
        {
            int duration = 70;

            this.Animate(OpacityProperty, Opacity, 1, duration, delay);
            SelectionRectangle.Animate(OpacityProperty, 0.3, 0, duration, delay);
            await PaintSurface.AnimateAsync(OpacityProperty, 1, 0, duration, delay);

            WindowState = WindowState.Minimized;

            try {
                if (result)
                {
                    //Send frozen window to back
                    NativeMethods.SetWindowPos(new WindowInteropHelper(this).Handle, NativeMethods.HwndBottom, 0, 0, 0, 0,
                                               NativeMethods.SwpNomove | NativeMethods.SwpNosize | NativeMethods.SwpNoactivate);
                    Focusable = false;

                    //Finish
                    await ScreenshotHelper.FinishScreenshot(SelectionStream, HwndName);

                    DialogResult = true;
                    return;
                }
                if (Error)
                {
                    await Statics.ShowNotificationAsync(strings.uploadingError, NotificationWindow.NotificationType.Error);
                }
            } catch {
                // could not finish screenshot
            }

            await Task.Delay(duration * 3);

            DialogResult = false;
        }