diff --git a/SmoulderingBeachBall/InternalServices.fs b/SmoulderingBeachBall/InternalServices.fs index 1f80d0e..e13d5aa 100644 --- a/SmoulderingBeachBall/InternalServices.fs +++ b/SmoulderingBeachBall/InternalServices.fs @@ -19,6 +19,7 @@ | true -> () module Drawing = + open System.Text let penOffset penWidth = int (penWidth / (float32 2)) @@ -52,6 +53,15 @@ | Border -> drawBorder graphics pen spec | Full -> drawFullOverlay graphics pen spec + let buildFileName spec = + let sb = new StringBuilder () + sb.Append (spec.width.ToString ()) |> ignore + sb.Append "x" |> ignore + sb.Append (spec.height.ToString ()) |> ignore + sb.Append ".png" |> ignore + (sb.ToString ()) + + let drawImage spec = let bitmap = new Bitmap (spec.width, spec.height) let graphics = Graphics.FromImage (bitmap) @@ -59,7 +69,7 @@ graphics.FillRectangle (spec.colour, rectangle) match spec.overlay.IsSome with | true -> addOverlayToImage graphics spec - | false -> printfn "[INFO.] No overlay specified. Creating image withoutone." - bitmap.Save (spec.filePath) + | false -> printfn "[INFO.] No overlay specified. Creating image without one." + bitmap.Save (Path.Combine (spec.filePath, (buildFileName spec))) graphics.Dispose() bitmap.Dispose() \ No newline at end of file diff --git a/SmoulderingBeachBallCLI/Validation.fs b/SmoulderingBeachBallCLI/Validation.fs index c9963f8..e237ebe 100644 --- a/SmoulderingBeachBallCLI/Validation.fs +++ b/SmoulderingBeachBallCLI/Validation.fs @@ -2,6 +2,7 @@ open System.Drawing open SmoulderingBeachBall.Domain.DomainTypes + open System let colourList = [ "blue", Brushes.AliceBlue; @@ -28,12 +29,21 @@ invalidArg "Colour" "The colour specifed is invalid." // "Please use the ListAvailableColours command for a list"? + 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 = path + filePath = parsedPath overlay = None } spec \ No newline at end of file