diff --git a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value.cs b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value.cs
index a3514ca..87781f8 100644
--- a/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value.cs
+++ b/Advanced Software Engineering/Advanced Software Engineering/Verbs/Value.cs
@@ -6,27 +6,70 @@ using System.Text;
using System.Threading.Tasks;
namespace Advanced_Software_Engineering.Verbs {
+ ///
+ /// This class contains a large amount of useful conversions
+ ///
public class Value {
+ ///
+ /// Converts string to int (if possible)
+ ///
+ /// String to be converted to int
+ /// Integer representation of string
public static int ConvertToInt(string text) {
text = SettingsAndHelperFunctions.Strip(text);
return int.Parse(text);
}
+ ///
+ /// Converts string to double (if possible)
+ ///
+ /// String to be converted to double
+ /// Double representation of string
public static double ConvertToDouble(string text) {
text = SettingsAndHelperFunctions.Strip(text);
return double.Parse(text);
}
- //TODO: Make unit tests for this function
+ ///
+ /// Converts two strings to a point object.
+ ///
+ /// X parameter
+ /// Y parameter
+ /// A Point object
+ /// Make unit tests for this function
public static Point ConvertToPoint(string text1, string text2) {
return new Point(ConvertToInt(text1), ConvertToInt(text2));
}
//TODO: Make unit tests for this function
+ ///
+ /// This function convers text to Color.
+ ///
+ ///
+ /// It can parse several different types of strings.
+ /// Types of string accepted:
+ /// - A string that is the name of a predefined color. See class for full list.
+ /// - A string that represents a Hex Triplet (#rrggbb). See .
+ /// - A string that represents a Hex Quadruplet (#rrggbbaa, where aa represents alpha).
+ ///
+ ///
+ /// Color tmp = TextToColor("red");
+ /// Console.WriteLine("Name: " + tmp.toString()) //=> "red"
+ ///
+ /// tmp = TextToColor("deadbe");
+ /// Console.WriteLine("Name: " + tmp.toString()) //=> "00deadbe"
+ ///
+ /// //It's important to remember that C# doesn't work like HTML colors, putting alpha first, rather than last.
+ ///
+ /// tmp = TextToColor("deadbeef");
+ /// Console.WriteLine("Name: " + tmp.toString()) //=> "efdeadbe"
+ ///
+ ///
+ /// a string with a valid name or format
+ /// color of the string
public static Color TextToColor(string text) {
Color color = Color.FromName(text);
if (color.IsKnownColor) return color;
-
if (text.StartsWith("#"))
text = text.Substring(1);
@@ -51,6 +94,14 @@ namespace Advanced_Software_Engineering.Verbs {
}
}
+ ///
+ /// Generate a color from RGB(A) int values
+ ///
+ /// Red
+ /// Green
+ /// Blue
+ /// Optional: Alpha/Transparancy (default is 0)
+ ///
public static Color IntsToColor(int r, int g, int b, int a = 0) {
return Color.FromArgb(a, r, g, b);
}