-
Notifications
You must be signed in to change notification settings - Fork 0
/
Format.cs
193 lines (189 loc) · 6.19 KB
/
Format.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System;
using System.Collections.Generic;
namespace Kookaburra.SDK
{
/// <summary>
/// Format Class for the Kookaburra SDK.
/// </summary>
public static class Format
{
/// <summary>
/// Returns True if the string start with a uppercase letter.
/// </summary>
public static bool StartsWithUpper(string str)
{
if (string.IsNullOrWhiteSpace(str))
return false;
char ch = str[0];
return char.IsUpper(ch);
}
/// <summary>
/// Returns True if the string start with a lowercase letter.
/// </summary>
public static bool StartsWithLower(string str)
{
if (string.IsNullOrWhiteSpace(str))
return false;
char ch = str[0];
return char.IsLower(ch);
}
/// <summary>
/// Returns a lowercase version of the string.
/// </summary>
public static string ToLower(string Value)
{
return Value.ToLower();
}
/// <summary>
/// Returns an uppercase version of the string.
/// </summary>
public static string ToUpper(string Value)
{
return Value.ToUpper();
}
/// <summary>
/// Returns True if the selected string is in the array.
/// </summary>
public static bool IsInArray(string[] List, string Value)
{
bool Return = false;
foreach (string Array in List)
{
if (Array == Value)
Return = true;
}
return Return;
}
/// <summary>
/// Returns True if the selected int is in the array.
/// </summary>
public static bool IsInIntArray(int[] List, int Value)
{
bool Return = false;
foreach (int Array in List)
{
if (Array == Value)
Return = true;
}
return Return;
}
/// <summary>
/// Deletes specified character from the string and returns it.
/// </summary>
public static string DeleteChar(char Char, string Value)
{
return Value.Replace(Char, '\0');
}
/// <summary>
/// Deletes specified charaters (string) from the string and returns it.
/// </summary>
public static string DeleteString(string Remove, string Value)
{
return Value.Replace(Remove, string.Empty);
}
/// <summary>
/// Sets the foreground color to the specified string.
/// </summary>
public static void SetForegroundColor(string Color)
{
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), Color);
}
/// <summary>
/// Sets the background color to the specified string.
/// </summary>
public static void SetBackgroundColor(string Color)
{
Console.BackgroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), Color);
}
/// <summary>
/// Sets the foreground color to the specified ConsoleColor.
/// </summary>
public static void SetForeground(ConsoleColor Color)
{
Console.ForegroundColor = Color;
}
/// <summary>
/// Sets the background color to the specified ConsoleColor.
/// </summary>
public static void SetBackground(ConsoleColor Color)
{
Console.BackgroundColor = Color;
}
/// <summary>
/// Creates a blank line.
/// </summary>
public static void WhiteSpace()
{
Console.WriteLine(Environment.NewLine);
}
/// <summary>
/// Creates a blank line using ANSI charaters. '\x0A'
/// </summary>
public static void WhiteSpaceANSI()
{
Console.Write("\x0A");
}
/// <summary>
/// Removes the first character from string and returns it.
/// </summary>
public static string RemoveFirstChar(string Value)
{
return Value.Remove(0, 1);
}
/// <summary>
/// Removes the last character from string and returns it.
/// </summary>
public static string RemoveLastChar(string Value)
{
return Value.Remove(Value.Length - 1);
}
/// <summary>
/// Clears the terminal window and resets the colors.
/// </summary>
public static void Reset()
{
Console.WriteLine("\x1b[3J");
Console.Clear();
Console.ResetColor();
}
/// <summary>
/// Clears the terminal window using ANCI characters.
/// </summary>
public static void Clear()
{
Console.WriteLine("\x1b[3J");
Console.Clear();
}
/// <summary>
/// Returns the coorinates of the console cursor.
/// </summary>
public static Tuple<int, int> GetPos()
{
return Tuple.Create(Console.CursorTop, Console.CursorLeft);
}
/// <summary>
/// Sets the coorinates of the console cursor.
/// </summary>
public static void SetPos(int top, int left)
{
Console.CursorTop = top;
Console.CursorLeft = left;
}
/// <summary>
/// Splits the string and removes the part where it got splitted.
/// </summary>
public static string[] SplitAndRemove(string Value, string SplitValue)
{
var ListValue = new List<string>(Value.Split(SplitValue));
ListValue.Remove(SplitValue);
return ListValue.ToArray();
}
/// <summary>
/// Removes the mentioned value from string and returns it.
/// </summary>
public static string RemoveString(string Value, string RemoveValue)
{
return Value.Replace(RemoveValue, string.Empty);
}
}
}