|
|
|
module internal Validation
|
|
|
|
|
|
|
|
open System.Drawing
|
|
|
|
open SmoulderingBeachBall.Domain.DomainTypes
|
|
|
|
open System
|
|
|
|
|
|
|
|
let colourList =
|
|
|
|
[ "blue", Brushes.AliceBlue;
|
|
|
|
"brown", Brushes.Brown;
|
|
|
|
"black", Brushes.Black;
|
|
|
|
"gray", Brushes.Gray;
|
|
|
|
"green", Brushes.Green;
|
|
|
|
"purple", Brushes.Purple;
|
|
|
|
"red", Brushes.Red;
|
|
|
|
"white", Brushes.White;
|
|
|
|
"yellow", Brushes.Yellow;]
|
|
|
|
|> Map.ofList
|
|
|
|
|
|
|
|
let isColourValid (colour: string) =
|
|
|
|
colourList
|
|
|
|
|> Map.containsKey (colour.ToLower())
|
|
|
|
|
|
|
|
let parseColour colour =
|
|
|
|
match (isColourValid colour) with
|
|
|
|
| true ->
|
|
|
|
colourList
|
|
|
|
|> Map.find (colour.ToLower())
|
|
|
|
| false ->
|
|
|
|
invalidArg "Colour"
|
|
|
|
(String.Concat("[ERROR] The colour specifed is invalid.\n",
|
|
|
|
"Please use the 'list-colours' command to see what you can use."))
|
|
|
|
|
|
|
|
let getDesktopPath =
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
|
|
|
|
|
|
|
|
let parsePath (path: string) =
|
|
|
|
match path with
|
|
|
|
| path when ((path.ToLower()).Equals "desktop") -> getDesktopPath
|
|
|
|
| path when ((path.ToLower()).Equals "d") -> getDesktopPath
|
|
|
|
| _ -> path
|
|
|
|
|
|
|
|
let buildDefaultSpec iWidth iHeight =
|
|
|
|
let oSpec =
|
|
|
|
{ colour = Brushes.Black
|
|
|
|
overlayType = Full }
|
|
|
|
let spec =
|
|
|
|
{ width = iWidth
|
|
|
|
height = iHeight
|
|
|
|
colour = Brushes.AntiqueWhite
|
|
|
|
filePath = getDesktopPath
|
|
|
|
overlay = Some oSpec
|
|
|
|
}
|
|
|
|
spec
|
|
|
|
|
|
|
|
let buildBasicSpec iWidth iHeight mainColour path =
|
|
|
|
let spec =
|
|
|
|
{ width = iWidth;
|
|
|
|
height = iHeight;
|
|
|
|
colour = parseColour mainColour
|
|
|
|
filePath = parsePath path
|
|
|
|
overlay = None }
|
|
|
|
spec
|
|
|
|
|
|
|
|
let parseOverlay (oType: string) =
|
|
|
|
match oType.ToLower() with
|
|
|
|
| "border" -> Border
|
|
|
|
| "b" -> Border
|
|
|
|
| "full" -> Full
|
|
|
|
| "f" -> Full
|
|
|
|
| _ -> invalidArg "Overlay Type" "The overlay type must be either 'border' or 'full'."
|
|
|
|
|
|
|
|
// Need to think about building the two spec's seperately and bring them together in one place.
|
|
|
|
// I'm repeating myself a little too much here.
|
|
|
|
// Also, need to adjust pen width to match the image size (in library proj.).
|
|
|
|
let buildOverlaySpec iWidth iHeight mainColour oColour oType path =
|
|
|
|
let oSpec =
|
|
|
|
{ colour = parseColour oColour;
|
|
|
|
overlayType = parseOverlay oType }
|
|
|
|
let spec =
|
|
|
|
{width = iWidth;
|
|
|
|
height = iHeight;
|
|
|
|
colour = parseColour mainColour;
|
|
|
|
filePath = parsePath path;
|
|
|
|
overlay = Some oSpec }
|
|
|
|
spec
|