public async Task <string> CaptureScreenshot(string game)
        {
            var context = GameContext.Get(game);

            using (var client = new AdbClient("emulator-5554"))
            {
                var bitmap = client.CaptureScreenshot();
                return(ImageStorage.Save(context, bitmap));
                //using (var stream = new System.IO.MemoryStream())
                //{
                //    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                //    var bytes = stream.ToArray();

                //    var name = $"{DateTime.UtcNow:yyMMdd.HHmmss}";

                //    System.IO.File.WriteAllBytes(System.IO.Path.Combine(context.StorageDir, $"{name}.png"), bytes);

                //    return name;
                //}
            }
        }
示例#2
0
 static void Adb(Action <AdbClient> f)
 {
     using (var adb = new AdbClient("emulator-5554"))
         f(adb);
 }
示例#3
0
 static T Adb <T>(Func <AdbClient, T> f)
 {
     using (var adb = new AdbClient("emulator-5554"))
         return(f(adb));
 }