2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2015-10-18 22:04:03 +01:00
|
|
|
// The Disc Image Chef
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : DicConsole.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-10-18 22:04:03 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Console.
|
2015-10-18 22:04:03 +01:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Handlers for normal, verbose and debug consoles.
|
2015-10-18 22:04:03 +01:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2015-10-18 22:04:03 +01:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
2015-10-18 22:04:03 +01:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-10-18 22:04:03 +01:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2017-12-19 03:50:57 +00:00
|
|
|
// Copyright © 2011-2018 Natalia Portillo
|
2015-10-18 22:04:03 +01:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
namespace DiscImageChef.Console
|
|
|
|
|
{
|
|
|
|
|
public delegate void WriteLineHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void ErrorWriteLineHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void VerboseWriteLineHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void DebugWriteLineHandler(string format, params object[] arg);
|
|
|
|
|
|
|
|
|
|
public delegate void WriteHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void ErrorWriteHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void VerboseWriteHandler(string format, params object[] arg);
|
2017-12-19 20:33:03 +00:00
|
|
|
|
2015-10-18 22:04:03 +01:00
|
|
|
public delegate void DebugWriteHandler(string format, params object[] arg);
|
|
|
|
|
|
|
|
|
|
public static class DicConsole
|
|
|
|
|
{
|
|
|
|
|
public static event WriteLineHandler WriteLineEvent;
|
|
|
|
|
public static event ErrorWriteLineHandler ErrorWriteLineEvent;
|
|
|
|
|
public static event VerboseWriteLineHandler VerboseWriteLineEvent;
|
|
|
|
|
public static event DebugWriteLineHandler DebugWriteLineEvent;
|
|
|
|
|
|
|
|
|
|
public static event WriteHandler WriteEvent;
|
|
|
|
|
public static event ErrorWriteHandler ErrorWriteEvent;
|
|
|
|
|
public static event VerboseWriteHandler VerboseWriteEvent;
|
|
|
|
|
public static event DebugWriteHandler DebugWriteEvent;
|
|
|
|
|
|
|
|
|
|
public static void WriteLine(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(WriteLineEvent != null) WriteLineEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ErrorWriteLine(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(ErrorWriteLineEvent != null) ErrorWriteLineEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void VerboseWriteLine(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(VerboseWriteLineEvent != null) VerboseWriteLineEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DebugWriteLine(string module, string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(DebugWriteLineEvent != null) DebugWriteLineEvent("DEBUG (" + module + "): " + format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void WriteLine()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(WriteLineEvent != null) WriteLineEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ErrorWriteLine()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(ErrorWriteLineEvent != null) ErrorWriteLineEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void VerboseWriteLine()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(VerboseWriteLineEvent != null) VerboseWriteLineEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DebugWriteLine()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(DebugWriteLineEvent != null) DebugWriteLineEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Write(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(WriteEvent != null) WriteEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ErrorWrite(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(ErrorWriteEvent != null) ErrorWriteEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void VerboseWrite(string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(VerboseWriteEvent != null) VerboseWriteEvent(format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DebugWrite(string module, string format, params object[] arg)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(DebugWriteEvent != null) DebugWriteEvent("DEBUG (" + module + "): " + format, arg);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Write()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(WriteEvent != null) WriteEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ErrorWrite()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(ErrorWriteEvent != null) ErrorWriteEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void VerboseWrite()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(VerboseWriteEvent != null) VerboseWriteEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DebugWrite()
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(DebugWriteEvent != null) DebugWriteEvent("", null);
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
2015-10-19 01:37:23 +01:00
|
|
|
|
|
|
|
|
public static void WriteLine(string format)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(WriteLineEvent != null) WriteLineEvent("{0}", format);
|
2015-10-19 01:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void ErrorWriteLine(string format)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(ErrorWriteLineEvent != null) ErrorWriteLineEvent("{0}", format);
|
2015-10-19 01:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void VerboseWriteLine(string format)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(VerboseWriteLineEvent != null) VerboseWriteLineEvent("{0}", format);
|
2015-10-19 01:37:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void DebugWriteLine(string module, string format)
|
|
|
|
|
{
|
2017-12-19 20:33:03 +00:00
|
|
|
if(DebugWriteLineEvent != null) DebugWriteLineEvent("{0}", "DEBUG (" + module + "): " + format);
|
2015-10-19 01:37:23 +01:00
|
|
|
}
|
2015-10-18 22:04:03 +01:00
|
|
|
}
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|