Browse Source

remove allSystemBrushes from Grid Painter.

Update drawGrid to use "use" statements and remove the manual Dispose calls. Make minor spelling/editing chanes (in comments).
master
Craig Oates 6 years ago
parent
commit
e77baa242d
  1. 15
      DeathSocket/GridPainter.fs
  2. 14
      DeathSocket/ImageServices.fs
  3. 2
      TestCentre/Script.fsx

15
DeathSocket/GridPainter.fs

@ -6,8 +6,6 @@ namespace DeathSocket
open Validation open Validation
open ImageServices open ImageServices
open System.Drawing
open System.Reflection
// Needs XML comments. // Needs XML comments.
let applyGridAsync spec = let applyGridAsync spec =
@ -17,7 +15,7 @@ namespace DeathSocket
drawGrid spec |> ignore drawGrid spec |> ignore
with with
| :? FileNotFoundException as ex -> | :? 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. // Needs XML comments.
@ -28,13 +26,4 @@ namespace DeathSocket
// Needs XML comments. // Needs XML comments.
// Tests have not been written. // Tests have not been written.
let determineVerticalLines width height columns = let determineVerticalLines width height columns =
createVerticalLines width height columns createVerticalLines width height columns
// Needs XML comments.
// Tests have not been written.
let allSystemBrushes =
let properties =
typeof<Brushes>.GetProperties
(BindingFlags.Public ||| BindingFlags.Static)
seq { for prop in properties -> prop }
|> Seq.toList

14
DeathSocket/ImageServices.fs

@ -18,19 +18,15 @@
let drawGrid spec = let drawGrid spec =
// The originalImg is for images with indexed pixels. // The originalImg is for images with indexed pixels.
let orignialImg = Bitmap.FromFile spec.originalPath use orignialImg = Bitmap.FromFile spec.originalPath
let img = new Bitmap (orignialImg.Width, orignialImg.Height) use img = new Bitmap (orignialImg.Width, orignialImg.Height)
let graphics = Graphics.FromImage img use graphics = Graphics.FromImage img
graphics.DrawImage (orignialImg, 0, 0) 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 = let horizontalLines =
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows) createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows)
let verticalLines = let verticalLines =
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns) createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns)
for line in horizontalLines do graphics.DrawLines (pen, line) for line in horizontalLines do graphics.DrawLines (pen, line)
for line in verticalLines do graphics.DrawLines (pen, line) for line in verticalLines do graphics.DrawLines (pen, line)
img.Save (spec.savePath, ImageFormat.Png) img.Save (spec.savePath, ImageFormat.Png)
orignialImg.Dispose ()
img.Dispose ()
graphics.Dispose ()
pen.Dispose ()

2
TestCentre/Script.fsx

@ -44,7 +44,7 @@ resetLoadingTestArea ()
(* Populating LoadingTestArea Folder Scripts (* 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. You can then use these images in LibraryTests.fs -- Property Tests.
The tests consists of loading images from LoadingTestArea, transforming them The tests consists of loading images from LoadingTestArea, transforming them
and saving them in SavingTestArea. *) and saving them in SavingTestArea. *)

Loading…
Cancel
Save