5 DeathSockets Main Files Overview
Craig Oates edited this page 4 years ago

Instead of running through every line of code in the project, I will provide a summary of what each file aims to do. That way, you should find how the pieces fit together in a more intuitive way. That's the plan at least.

GridPainter.fs (public)

  • Name-space: DeathSocket
  • Module: GridPainter

This is the public facing part of the library, the API. When people add this project to theirs, they will call the functions in here. Which, in turn, will call the internal functions within the rest of the library. End-users will use this file and the types defined in "Domain.fs" extensively.

ValidationServices.fs (internal)

  • Name-space: N.A.
  • Module: ValidationServices

The functions is this file perform validation checks -- as the name implies. File extension and path checks are examples of the types of checks found in here.

ColourServices.fs (internal)

  • Name-space: N.A.
  • Module: ColourServices

This file deals with converting/creating Colors and Brushes which are used to draw the grid. The colours and brushes are derived from the System.Drawing name-space.

There are no functions for the SkiaSharp part of the library because it does not have a notion of Brushes like System.Drawing. So, I have found little need to add any functions for this part of library in here.

If you are unfamiliar with either System.Drawing or SkiaSharp, please use the following links:

It is, also, worth pointing out the .Net Framework provides a name-space called System.Media. The Colors and Brushes in here are not compatible or interchangeable with System.Drawing. 

If you're wondering, I decided to go with System.Drawing, instead of system.media, because is works better with Windows Presentation Foundation (W.P.F.).

ImagePrep.fs

  • Name-space: N.A.
  • Module: ImagePrep

This file provides functions which aids the functions in "ImageServices.fs". Within this file, you will find the SkiaSharp functions separated from the System.Drawing ones via comments. The functions not grouped together via those comments work with both libraries/name-spaces.

ImageServices.fs (internal)

  • Name-space: N.A.
  • Module: ImageServices

This file focuses on creating and saving the new image, with its grid. You will see a lot of duplicated code in here but do not worry too much. There are comments within the file explaining the rationale behind it. The short version why is to reduce the memory footprint of the library at run-time. I decided to solve this by utilising the use keyword. This means I do not need to manually dispose of images which reduces the chances of memory leaks. The result of this is duplicated but self-contained (I.E. function bound/scoped) code.

If you are unsure what the use keyword does, please you the following link for more information:

Like "ImagePrep.fs", this file separates the System.Drawing and SkiaSharp based functions with comments.