From e77baa242dcddb7dcda12f50c2e8aa278991302a Mon Sep 17 00:00:00 2001 From: "OPTIMUS-PRIME\\craig" Date: Mon, 1 Oct 2018 16:44:33 +0100 Subject: [PATCH] remove allSystemBrushes from Grid Painter. Update drawGrid to use "use" statements and remove the manual Dispose calls. Make minor spelling/editing chanes (in comments). --- DeathSocket/GridPainter.fs | 15 ++------------- DeathSocket/ImageServices.fs | 14 +++++--------- TestCentre/Script.fsx | 2 +- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/DeathSocket/GridPainter.fs b/DeathSocket/GridPainter.fs index ae0b7b0..b0d8a2d 100644 --- a/DeathSocket/GridPainter.fs +++ b/DeathSocket/GridPainter.fs @@ -6,8 +6,6 @@ namespace DeathSocket open Validation open ImageServices - open System.Drawing - open System.Reflection // Needs XML comments. let applyGridAsync spec = @@ -17,7 +15,7 @@ namespace DeathSocket drawGrid spec |> ignore with | :? FileNotFoundException as ex -> - printfn "File could not be found at %s" ex.Message + printfn "File could not be found at %s" ex.Message } // Needs XML comments. @@ -28,13 +26,4 @@ namespace DeathSocket // Needs XML comments. // Tests have not been written. let determineVerticalLines width height columns = - createVerticalLines width height columns - - // Needs XML comments. - // Tests have not been written. - let allSystemBrushes = - let properties = - typeof.GetProperties - (BindingFlags.Public ||| BindingFlags.Static) - seq { for prop in properties -> prop } - |> Seq.toList \ No newline at end of file + createVerticalLines width height columns \ No newline at end of file diff --git a/DeathSocket/ImageServices.fs b/DeathSocket/ImageServices.fs index 8b077ab..51b4fa9 100644 --- a/DeathSocket/ImageServices.fs +++ b/DeathSocket/ImageServices.fs @@ -18,19 +18,15 @@ let drawGrid spec = // The originalImg is for images with indexed pixels. - let orignialImg = Bitmap.FromFile spec.originalPath - let img = new Bitmap (orignialImg.Width, orignialImg.Height) - let graphics = Graphics.FromImage img + use orignialImg = Bitmap.FromFile spec.originalPath + use img = new Bitmap (orignialImg.Width, orignialImg.Height) + use graphics = Graphics.FromImage img graphics.DrawImage (orignialImg, 0, 0) - let pen = new Pen (spec.colour, width = spec.penWidth) + use pen = new Pen (spec.colour, width = spec.penWidth) let horizontalLines = createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows) let verticalLines = createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns) for line in horizontalLines do graphics.DrawLines (pen, line) for line in verticalLines do graphics.DrawLines (pen, line) - img.Save (spec.savePath, ImageFormat.Png) - orignialImg.Dispose () - img.Dispose () - graphics.Dispose () - pen.Dispose () \ No newline at end of file + img.Save (spec.savePath, ImageFormat.Png) \ No newline at end of file diff --git a/TestCentre/Script.fsx b/TestCentre/Script.fsx index 7c24da5..e053c75 100644 --- a/TestCentre/Script.fsx +++ b/TestCentre/Script.fsx @@ -44,7 +44,7 @@ resetLoadingTestArea () (* Populating LoadingTestArea Folder Scripts =============================================================================== -The following scripts are to help you populate a test folder of images. +The following scripts are to help you populate a test folder with test images. You can then use these images in LibraryTests.fs -- Property Tests. The tests consists of loading images from LoadingTestArea, transforming them and saving them in SavingTestArea. *)