From 6ef653714c5c3756c3c1eef53db6db55c15f95c4 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sat, 29 Dec 2018 15:44:39 +0000 Subject: [PATCH] add XML comments and minor refactoring to GridPainter. --- DeathSocket/Domain.fs | 2 +- DeathSocket/GridPainter.fs | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/DeathSocket/Domain.fs b/DeathSocket/Domain.fs index 5d93eef..4bde64e 100644 --- a/DeathSocket/Domain.fs +++ b/DeathSocket/Domain.fs @@ -106,7 +106,7 @@ | SkiaRGB of SkiaRGBSpec /// Discriminated Union representing the graphics libraries used by - /// Desth Socket. Useful for selecting which one you want to use. + /// Death Socket. Useful for selecting which one you want to use. /// System.Drawing for using Windows/Mono and SkiaSharp for Xamarin. type ImageType = | SkiaSharp of string diff --git a/DeathSocket/GridPainter.fs b/DeathSocket/GridPainter.fs index 500bcdd..726e2ae 100644 --- a/DeathSocket/GridPainter.fs +++ b/DeathSocket/GridPainter.fs @@ -15,7 +15,6 @@ namespace DeathSocket open Validation open ImageServices - open System /// /// Uses the information included in spec to create a gridded image. @@ -26,10 +25,6 @@ namespace DeathSocket /// ImageSpec is a discriminated union, consisting of a Brush, RGBA, /// Skia or SkiaRGB spec. /// - /// - /// If the file the grid is being applied to cannot be found, - /// a FileNotFoundException will be thrown. - /// /// /// Make sure the image, which is having the overlay added to it, /// is not in use or needed by another program/process. @@ -85,12 +80,22 @@ namespace DeathSocket // NOT TESTED /// - /// + /// Reads an (jpg or png) image and return its width and height as a + /// tuple, (width * hight). /// - /// - let determineImageDimensions imageType = + /// + /// The name of the graphics library used to read and determine the + /// images dimensions. + /// + /// + /// The image type is determined by the graphics library used. It is + /// called "ImageType" and not "GraphicsLibUsed" because the image/file + /// information is the thing this function cares about most of all. How + /// it is read and what library it uses it secondary. + /// + let determineImageDimensions (iType: ImageType) = try - match imageType with + match iType with | SkiaSharp s -> validateFilePath s |> ignore determineSkiaDimensions s @@ -100,7 +105,7 @@ namespace DeathSocket with | :? FileNotFoundException as ex -> printfn "%s" ex.Message - (0,0) + reraise () // System.Drawing Functions // ======================================================================== @@ -151,8 +156,8 @@ namespace DeathSocket /// Use this function when targeting .Net/Mono). /// /// - ///The specification which the brush is made from. - /// + /// The specification which the brush is made from. + /// /// /// Death Socket uses System.Drawing and not System.Media for colours /// and brushes.