diff --git a/DeathSocketCLI/Commands.fs b/DeathSocketCLI/Commands.fs index e0b5bd6..ac782e1 100644 --- a/DeathSocketCLI/Commands.fs +++ b/DeathSocketCLI/Commands.fs @@ -6,15 +6,34 @@ open Validation open System.IO open Console.Waterworks + open Console.Waterworks.Attributes let showEndOfCommandMessage = "[INFO.] Task completed." + [] + [] + [] + [] let test () = "[SUCCESS] Death Socket is working." + [] + [] + [] + [] let help () = CW_Liaison().RequestHelpDocumentation("Commands") + [] + [] + [] + [] let exit () = Environment.Exit (Environment.ExitCode) + [] + [] + [] + [] let ``add-default`` imgPath newPath = try printfn "[INFO.] Adding default grid to image..." @@ -27,6 +46,13 @@ | :? ArgumentException as ex -> "[ERROR] Invalid argument: " + ex.Message | _ as ex -> ex.Message + [] + [] + [] + [] let ``add-grid`` imgPath numRows numColumns pWidth colour newPath = try printfn "[INFO.] Adding grid to image..." @@ -39,6 +65,11 @@ | :? ArgumentException as ex -> "[ERROR] Invalid argument: " + ex.Message | _ as ex -> ex.Message + [] + [] + [] + [] let ``list-colours`` () = printfn "[INFO.] Listing available colours..." for item in colourList do diff --git a/DeathSocketCLI/Validation.fs b/DeathSocketCLI/Validation.fs index 5deb9db..1df6f1f 100644 --- a/DeathSocketCLI/Validation.fs +++ b/DeathSocketCLI/Validation.fs @@ -3,6 +3,7 @@ open DeathSocket open System.Drawing open System + open System.IO let colourList = [ "blue", Brushes.AliceBlue @@ -30,6 +31,13 @@ (String.Concat("The colour specifed is invalid.\n", "Please use the 'list-colours' command to see what you can use.")) + let setPenWidth imgWidth imgHeight = + let width = float32 imgWidth + let height = float32 imgHeight + if (width >= height) then + height * (float32 0.01) + else width * (float32 0.01) + let buildSpec imgPath numRows numColumns pWidth colour newPath = { originalPath = imgPath savePath = newPath @@ -39,9 +47,15 @@ columns = numColumns } let buildDefaultSpec imgPath newPath = - { originalPath = imgPath - savePath = newPath - colour = Brushes.White - penWidth = float32 (2) - rows = 10 - columns = 10 } \ No newline at end of file + let stream = new FileStream (imgPath, FileMode.Open) + let image = Image.FromStream (stream, false, false) + let spec = + { originalPath = imgPath + savePath = newPath + colour = Brushes.White + penWidth = setPenWidth (image.Width) (image.Height) + rows = 10 + columns = 10 } + stream.Dispose () + image.Dispose () + spec \ No newline at end of file