예제 #1
0
        public async Task ScreenshotTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            using var app = await TestWpfApp.CreateAsync(cancellationToken);

            using var runner = new SelectRunner(app.Dispatcher).WithLogging();

            var process = new Process <ICommand>();
            var task    = runner.SelectAsync(process, cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);

            await process.StopAsync(cancellationToken);

            var rectangle = await task;

            Console.WriteLine($"{rectangle.Left}, {rectangle.Top}, {rectangle.Right}, {rectangle.Bottom}");

            using var screenshotRunner = new ScreenshotRunner().WithLogging();
            var image = await screenshotRunner.ShotAsync(rectangle, cancellationToken);

            using var clipboardRunner = new ClipboardRunner(app.Dispatcher).WithLogging();
            await clipboardRunner.SetClipboardImageAsync(image, cancellationToken);
        }
예제 #2
0
        public async Task SelectTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            using var app = await TestWpfApp.CreateAsync(cancellationToken);

            using var runner = new SelectRunner(app.Dispatcher).WithLogging();

            var process = new Process <ICommand>();
            var task    = runner.SelectAsync(process, cancellationToken);

            await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken).ConfigureAwait(false);

            await process.StopAsync(cancellationToken).ConfigureAwait(false);

            var rectangle = await task.ConfigureAwait(false);

            Console.WriteLine($"{rectangle.Left}, {rectangle.Top}, {rectangle.Right}, {rectangle.Bottom}");
        }