using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VisimBox
{
    public class Console : Singleton<Console>
    {
        public delegate void ConsoleCallback(string line);

        public event ConsoleCallback OnWriteLine;
        public event ConsoleCallback OnWriteDebugLine;


        /// <summary>
        /// Writes normal line to console output
        /// </summary>
        /// <param name="line">string to write</param>
        public void Write(string line)
        {
            System.Console.WriteLine(line);
            if (OnWriteLine != null)
                OnWriteLine(line);
        }

        /// <summary>
        /// Writes debug line to console output
        /// </summary>
        /// <param name="line">string to write</param>
        public void DebugWrite(string line)
        {
            System.Console.WriteLine(line);
            if (OnWriteDebugLine != null)
                OnWriteDebugLine(line);
        }


        /// <summary>
        /// static helper (so no need to call instance)
        /// </summary>
        /// <param name="line">Text to write</param>
        public static void WriteLine(string line)
        {
            Instance.Write(line);
        }

        /// <summary>
        /// static helper (so no need to call instance)
        /// </summary>
        /// <param name="line">Text to write</param>
        public static void DebugLine(string line)
        {
            Instance.DebugWrite(line);
        }

        //todo!!! better console, this line requires otherwise needless reference to windows.forms
        public static void MessageBox(string line)
        {
            System.Windows.Forms.MessageBox.Show(line);
        }
    }
}
