mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Build -> Prepare
This commit is contained in:
@@ -38,7 +38,7 @@ namespace RombaSharp
|
|||||||
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
SabreTools.Library.Data.Build.PrepareConsole("RombaSharp");
|
Prepare.SetConsoleHeader("RombaSharp");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we remove the script tag because it messes things up
|
// Now we remove the script tag because it messes things up
|
||||||
|
|||||||
@@ -5,33 +5,18 @@ namespace SabreTools.Library.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic console preparation for program output
|
/// Generic console preparation for program output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Build
|
public static class Prepare
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Returns true if running in a Mono or .NET Core environment
|
|
||||||
/// </summary>
|
|
||||||
public static bool MonoOrCoreEnvironment
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
#if NET_FRAMEWORK
|
|
||||||
return Type.GetType("Mono.Runtime") != null;
|
|
||||||
#else
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Readies the console and outputs the header
|
/// Readies the console and outputs the header
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name to be displayed as the program</param>
|
/// <param name="program">The name to be displayed as the program</param>
|
||||||
public static void PrepareConsole(string name)
|
public static void SetConsoleHeader(string program)
|
||||||
{
|
{
|
||||||
// Dynamically create the header string, adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string
|
// Dynamically create the header string, adapted from http://stackoverflow.com/questions/8200661/how-to-align-string-in-fixed-length-string
|
||||||
int width = Console.WindowWidth - 3;
|
int width = Console.WindowWidth - 3;
|
||||||
string border = $"+{new string('-', width)}+";
|
string border = $"+{new string('-', width)}+";
|
||||||
string mid = $"{name} {Constants.Version}";
|
string mid = $"{program} {Constants.Version}";
|
||||||
mid = $"|{mid.PadLeft(((width - mid.Length) / 2) + mid.Length).PadRight(width)}|";
|
mid = $"|{mid.PadLeft(((width - mid.Length) / 2) + mid.Length).PadRight(width)}|";
|
||||||
|
|
||||||
// If we're outputting to console, do fancy things
|
// If we're outputting to console, do fancy things
|
||||||
@@ -49,7 +34,7 @@ namespace SabreTools.Library.Data
|
|||||||
Console.BackgroundColor = ConsoleColor.Blue;
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.Title = $"{name} {Constants.Version}";
|
Console.Title = $"{program} {Constants.Version}";
|
||||||
|
|
||||||
// Output the header
|
// Output the header
|
||||||
Console.WriteLine(border);
|
Console.WriteLine(border);
|
||||||
@@ -65,5 +50,20 @@ namespace SabreTools.Library.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if running in a Mono or .NET Core environment
|
||||||
|
/// </summary>
|
||||||
|
private static bool MonoOrCoreEnvironment
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
#if NET_FRAMEWORK
|
||||||
|
return Type.GetType("Mono.Runtime") != null;
|
||||||
|
#else
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace SabreTools
|
|||||||
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
if (!Console.IsOutputRedirected && scriptLocation == -1)
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Build.PrepareConsole("SabreTools");
|
Prepare.SetConsoleHeader("SabreTools");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now we remove the script tag because it messes things up
|
// Now we remove the script tag because it messes things up
|
||||||
|
|||||||
Reference in New Issue
Block a user