コード例 #1
0
        //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;
        }
コード例 #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
                if (ConfigHelper.FreezeScreen)
                {
                    using (ScreenshotWindowFreeze window = new ScreenshotWindowFreeze())
                        window.ShowDialog();
                }
                else
                {
                    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();
        }