/tools/PhyreFly/src/PFConsole.cs
C# | 61 lines | 51 code | 10 blank | 0 comment | 6 complexity | c8e9e6924be808a64710b28f3384e0dd MD5 | raw file
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Drawing;
-
- namespace PhyreFly
- {
- class PFConsole
- {
- private static Color[] m_colours = { Color.White, Color.Green, Color.Orange, Color.Red };
- public enum Severity { INFO = 0, SUCCESS, WARNING, ERROR };
-
- public static string SpreadText(string text)
- {
- bool bInToken = false;
- string spreadText = string.Empty;
- text = text.Replace(" ", " ");
-
- foreach (char c in text)
- {
- bInToken = (c == '{' || (bInToken && c != '}'));
- spreadText += c + (bInToken ? "" : " ");
- }
-
- return spreadText;
- }
-
- public static void WriteHeading(Severity severity, string msg, params object[] args)
- {
- WriteLine(severity, "\r\n***********************************************");
- WriteLine(severity, " " + SpreadText(msg), args);
- WriteLine(severity, "***********************************************");
- }
-
- public static void WriteLine(Color severity, string msg, params object[] args)
- {
- Write(severity, msg + Environment.NewLine, args);
- }
-
- public static void WriteLine(Severity severity, string msg, params object[] args)
- {
- Write(severity, msg + Environment.NewLine, args);
- }
-
- public static void Write(Severity severity, string msg, params object[] args)
- {
- Write(m_colours[(int)severity], msg, args);
- }
-
- public static void Write(Color severity, string msg, params object[] args)
- {
- if (OnWrite == null)
- return;
- OnWrite(severity, msg, args);
- }
-
- public delegate void OutputFunction(Color severity, string msg, params object[] args);
- public static event OutputFunction OnWrite = null;
- }
- }