예제 #1
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;
        }