|
|
|
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 parsePath (path: string) =
|
|
|
|
match path with
|
|
|
|
| path when ((path.ToLower()).Equals "desktop") ->
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
|
|
|
|
| path when ((path.ToLower()).Equals "d") ->
|
|
|
|
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
|
|
|
|
| _ -> path
|
|
|
|
|
|
|
|
let buildBasicSpec iWidth iHeight mainColour path =
|
|
|
|
let brush = (parseColour mainColour)
|
|
|
|
let parsedPath = parsePath path
|
|
|
|
let spec =
|
|
|
|
{ width = iWidth;
|
|
|
|
height = iHeight;
|
|
|
|
colour = brush
|
|
|
|
filePath = parsedPath
|
|
|
|
overlay = None }
|
|
|
|
spec
|