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 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<Brushes>.GetProperties
(BindingFlags.Public ||| BindingFlags.Static)
seq { for prop in properties -> prop }
|> Seq.toList
createVerticalLines width height columns

14
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 ()
img.Save (spec.savePath, ImageFormat.Png)

2
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. *)

Loading…
Cancel
Save