using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RsenkTest
{
class Prompter
{
private const ConsoleColor NORMAL_COLOR = ConsoleColor.White;
private const ConsoleColor WARNING_COLOR = ConsoleColor.Yellow;
private const ConsoleColor ERROR_COLOR = ConsoleColor.Red;
private const string SYM_ROOT = "#";
private const string SYM_NORM = "$";
///
/// The different message types possible
///
private enum MessageType
{
Normal,
Warning,
Error
}
///
/// Displays the prompt string
///
/// The current user.
/// The current path.
public static void Prompt(string user, string path)
{
Console.ForegroundColor = NORMAL_COLOR;
Console.Write(user + ":" + path + SYM_NORM + " ");
}
///
/// Prints the welcome message to the console.
///
/// Additional messages to be displayed.
public static void PrintWelcome(string additional)
{
Console.ForegroundColor = ConsoleColor.DarkMagenta;
Console.WriteLine("Welcome to Cosmos Commander!\n\n");
Console.ForegroundColor = ConsoleColor.White;
}
///
/// Prints an error message to the console.
///
public static void PrintError(string error)
{
PrintMessage(error, MessageType.Error);
}
///
/// Prints a warning message to the console.
///
public static void PrintWarning(string warning)
{
PrintMessage(warning, MessageType.Warning);
}
///
/// Prints a message to the console.
///
public static void PrintMessage(string message)
{
PrintMessage(message, MessageType.Normal);
}
///
/// Prints a message to the console and sets the foreground color depending on the message type.
///
private static void PrintMessage(string message, MessageType type)
{
switch (type)
{
case MessageType.Error:
Console.ForegroundColor = ERROR_COLOR;
break;
case MessageType.Warning:
Console.ForegroundColor = WARNING_COLOR;
break;
case MessageType.Normal:
default:
Console.ForegroundColor = NORMAL_COLOR;
break;
}
Console.WriteLine(message);
}
public static void PrintCommandError(string name, bool invalidArg)
{
if (invalidArg)
{
PrintError("The argument(s) for '" + name + "' were incorrect. Type 'help [command]' for help.");
}
else
{
PrintError("'" + name + "' is not a valid command. Type 'help' for a list of valid commands.");
}
}
}
}