Skip to content

Commit

Permalink
fix for #225
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Dec 2, 2015
1 parent 7effbe9 commit 8074b90
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/canopy/canopy.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<byte>

let private takeScreenshot directory filename =
try
Expand Down

0 comments on commit 8074b90

Please sign in to comment.