Ejemplo n.º 1
0
 /// <summary>
 /// Creates screenshot of all available screens. <br/>
 /// If <paramref name="rectangle"/> is not null, returns image of this region.
 /// </summary>
 /// <param name="rectangle"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task <Bitmap> ShotAsync(
     Rectangle?rectangle = null,
     CancellationToken cancellationToken = default)
 {
     return(await Screenshoter.ShotAsync(rectangle, cancellationToken)
            .ConfigureAwait(false));
 }
Ejemplo n.º 2
0
        public async Task AsyncMultiShotTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            await Task.WhenAll(Enumerable
                               .Range(0, 10)
                               .Select(_ => Screenshoter.ShotAsync(cancellationToken: cancellationToken)));
        }
Ejemplo n.º 3
0
        public async Task AsyncShotTest()
        {
            using var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
            var cancellationToken = cancellationTokenSource.Token;

            var bitmap = await Screenshoter.ShotAsync(cancellationToken : cancellationToken);

            var path = $"{Path.GetTempFileName()}.bmp";

            bitmap.Save(path);

            Process.Start(new ProcessStartInfo(path)
            {
                UseShellExecute = true,
            });
        }