Browse Source

change Validation to ValidationServices.

master
Craig Oates 5 years ago
parent
commit
981d632468
  1. 2
      DeathSocket/DeathSocket.fsproj
  2. 2
      DeathSocket/GridPainter.fs
  3. 2
      DeathSocket/ImageServices.fs
  4. 4
      DeathSocket/ScratchPad.fsx
  5. 39
      DeathSocket/Validation.fs

2
DeathSocket/DeathSocket.fsproj

@ -23,7 +23,7 @@
<ItemGroup>
<Compile Include="Domain.fs" />
<Compile Include="Validation.fs" />
<Compile Include="ValidationServices.fs" />
<Compile Include="ColourServices.fs" />
<Compile Include="ImageServices.fs" />
<Compile Include="GridPainter.fs" />

2
DeathSocket/GridPainter.fs

@ -13,7 +13,7 @@ namespace DeathSocket
/// functions.
module GridPainter =
open Validation
open ValidationServices
open ImageServices
open SkiaSharp

2
DeathSocket/ImageServices.fs

@ -5,7 +5,7 @@
open System.Drawing
open System.Drawing.Imaging
open DeathSocket
open Validation
open ValidationServices
open ColourServices
open SkiaSharp

4
DeathSocket/ScratchPad.fsx

@ -4,7 +4,7 @@
//#r @"C:/Users/craig/.nuget/packages/skiasharp/1.60.3/runtimes/win-x64/native/libSkiaSharp.dll"
#load "Domain.fs"
#load "Validation.fs"
#load "ValidationServices.fs"
#load "ColourServices.fs"
#load "ImageServices.fs"
#load "GridPainter.fs"
@ -12,7 +12,7 @@
open System
open System.Drawing
open SkiaSharp
open Validation
open ValidationServices
open ImageServices
open DeathSocket

39
DeathSocket/Validation.fs

@ -1,39 +0,0 @@
module internal Validation
open System.IO
open DeathSocket
let validateFilePath path =
match File.Exists path with
| true -> ()
| false -> raise (new FileNotFoundException ("No file found at " + path))
let validateSaveFileType file =
match Path.GetExtension file with
| ".jpg" -> ()
| ".JPG" -> ()
| ".png" -> ()
| ".PNG" -> ()
| _ -> invalidArg "savePath" "The file type must be a .jpg or .png file."
let validateIO iPath oPath =
validateFilePath iPath
validateSaveFileType oPath
let validateDimensions dimensions =
match dimensions with
| (0, _) -> invalidArg "Width" "Width must be greater than 0."
| (_, 0) -> invalidArg "Height" "Height must be greater than 0."
| (_, _) -> ()
let validateLineThickness thickness =
match thickness with
| thickness when thickness <= 0.0 -> invalidArg "LineThickness" "LineThickness must be greater than 0."
| _ -> ()
let validateLongestDimension pDims aDims =
let width = (fst pDims) - (fst aDims)
let height = (snd pDims) - (snd aDims)
match width >= height with
| true -> Width
| false -> Height
Loading…
Cancel
Save