using System;
using System.Linq;
namespace Galactic_Colors_Control_Common
{
public static class Common
{
///
/// Write line in console with correct colors
///
/// Text to write
/// Foreground color
/// Background color
public static void ConsoleWrite(string v, ConsoleColor Fore = ConsoleColor.White, ConsoleColor Back = ConsoleColor.Black)
{
Console.Write("\b");
Console.ForegroundColor = Fore;
Console.BackgroundColor = Back;
Console.WriteLine(v);
ConsoleResetColor();
Console.Write(">");
}
///
/// Reset Console Colors
/// For non black background console as Ubuntu
///
public static void ConsoleResetColor()
{
Console.ResetColor();
Console.BackgroundColor = ConsoleColor.Black;
}
///
/// Simpler string array creation
///
public static string[] Strings(params string[] args)
{
return args;
}
public static string ArrayToString(string[] array)
{
string text = "";
if (array != null)
{
foreach (string str in array)
{
text += ((text == "" ? "" : Environment.NewLine) + str);
}
}
return text;
}
public static string ArrayToString(int[] array)
{
string text = "";
foreach (int i in array)
{
text += ((text == "" ? "" : Environment.NewLine) + i.ToString());
}
return text;
}
public static string[] SplitArgs(string text)
{
return text.Split('"')
.Select((element, index) => index % 2 == 0
? element.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
: new string[] { element })
.SelectMany(element => element).ToArray();
}
}
}