From 8074b90af6bd0d2ec87e1127cfe55e98c965d8d4 Mon Sep 17 00:00:00 2001 From: Chris Holt Date: Wed, 2 Dec 2015 10:56:15 -0600 Subject: [PATCH] fix for #225 --- src/canopy/canopy.fs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index b7c878f8..965c0f54 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -41,14 +41,18 @@ let private saveScreenshot directory filename pic = IO.File.WriteAllBytes(Path.Combine(directory,filename + ".png"), pic) let private takeScreenShotIfAlertUp () = - let bitmap = new Bitmap(width= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, height= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, format=PixelFormat.Format32bppArgb); - use graphics = Graphics.FromImage(bitmap) - graphics.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); - use stream = new MemoryStream() - bitmap.Save(stream, ImageFormat.Png) - stream.Close() - stream.ToArray() - + try + let bitmap = new Bitmap(width= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, height= System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height, format=PixelFormat.Format32bppArgb); + use graphics = Graphics.FromImage(bitmap) + graphics.CopyFromScreen(System.Windows.Forms.Screen.PrimaryScreen.Bounds.X, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Y, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy); + use stream = new MemoryStream() + bitmap.Save(stream, ImageFormat.Png) + stream.Close() + stream.ToArray() + with ex -> + printfn "Sorry, unable to take a screenshot. An alert was up, and the backup plan failed! + Exception: %s" ex.Message + Array.empty let private takeScreenshot directory filename = try