示例#1
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     using (var file = File.Open(FileName, FileMode.OpenOrCreate))
     {
         file.Seek(0, SeekOrigin.End);
         using (var stream = new StreamWriter(file))
             stream.WriteLine(output);
     }
 }
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     _pending += output;
     if (output.IndexOfAny(new[] { '\r', '\n' }) == 0)
     {
         _output.Add(_pending);
         _pending = string.Empty;
     }
 }
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     _pending += output;
     if (output.IndexOfAny(new[] { '\r', '\n' }) == 0)
     {
         _output.Add(_pending);
         _pending = string.Empty;
     }
 }
示例#4
0
        /// <summary>
        /// Prints provided message.
        /// </summary>
        /// <param name="consoleOutputType">What is the type of the response and what color should be it in?
        /// Details in enum file.</param>
        /// <param name="messagePrefix">Prefix input before the main message. Will take the color accordingly to consoleOutputType.</param>
        /// <param name="message">Main message to display. Will take the color accordingly to consoleOutputType.</param>
        public void PrintMessage(ConsoleOutputType consoleOutputType, string messagePrefix, string message)
        {
            var messageToShow           = messagePrefix + message;
            var newResponse             = Instantiate(_consoleOutputTextPrefab, _responseContainerTransform);
            var textControlConfigurator = newResponse.GetComponentInChildren <ConsoleOutputConfigurator>();
            var responseColor           = _consoleColors.GetConsoleColor(consoleOutputType);

            textControlConfigurator.SetTextControl(messageToShow, responseColor);

            _onPrintMessage?.Invoke();
        }
示例#5
0
        //[Tooltip("Console text color for regular response.")]
        //[SerializeField]
        //private Color _regularResponseColor;
        //[Tooltip("Console text color for error response.")]
        //[SerializeField]
        //private Color _errorResponseColor;

        /// <summary>
        /// Retrieves proper color for the response type. If no color found, returns
        /// regular color.
        /// </summary>
        /// <param name="consoleConsoleOutputType"></param>
        /// <returns></returns>
        public Color GetConsoleColor(ConsoleOutputType consoleConsoleOutputType)
        {
            var consoleColors = _consoleColorsData.dictionary;

            if (consoleColors.TryGetValue(consoleConsoleOutputType, out var color))
            {
                return(color);
            }

            return(consoleColors[ConsoleOutputType.Regular]);
        }
示例#6
0
        /// <summary>
        /// Outputs a message to the console with the given color.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="outType"></param>
        /// <param name="color"></param>
        public static void Output(string message, ConsoleOutputType outType, ConsoleColor color = ConsoleColor.White)
        {
            // Store the original foreground color..
            var c = Console.ForegroundColor;

            // Prepare the new message build..
            var msg = "[!] ";

            // Set the color based on our message type..
            switch (outType)
            {
            case ConsoleOutputType.Info:
                Console.ForegroundColor = ConsoleColor.White;
                msg += "Info: " + message;
                break;

            case ConsoleOutputType.Warning:
                Console.ForegroundColor = ConsoleColor.Yellow;
                msg += "Warn: " + message;
                break;

            case ConsoleOutputType.Error:
                Console.ForegroundColor = ConsoleColor.Red;
                msg += "Error: " + message;
                break;

            case ConsoleOutputType.Success:
                Console.ForegroundColor = ConsoleColor.Green;
                msg += "Success: " + message;
                break;

            case ConsoleOutputType.Custom:
                Console.ForegroundColor = color;
                msg += message;
                break;
            }

            // Print the message..
            Console.WriteLine(msg);

            // Restore the foreground color..
            Console.ForegroundColor = c;
        }
示例#7
0
 /// <summary>
 /// Write output on console.
 /// </summary>
 /// <param name="output">The output message</param>
 /// <param name="length">Parameter is ignored</param>
 /// <param name="outputType">Parameter is ignored</param>
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     Console.Write(output);
 }
示例#8
0
        /// <summary>
        /// Outputs a message to the console with the given color.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="outType"></param>
        /// <param name="color"></param>
        public static void Output(string message, ConsoleOutputType outType, ConsoleColor color = ConsoleColor.White)
        {
            // Store the original foreground color..
            var c = Console.ForegroundColor;

            // Prepare the new message build..
            var msg = "[!] ";

            // Set the color based on our message type..
            switch (outType)
            {
                case ConsoleOutputType.Info:
                    Console.ForegroundColor = ConsoleColor.White;
                    msg += "Info: " + message;
                    break;
                case ConsoleOutputType.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    msg += "Warn: " + message;
                    break;
                case ConsoleOutputType.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    msg += "Error: " + message;
                    break;
                case ConsoleOutputType.Success:
                    Console.ForegroundColor = ConsoleColor.Green;
                    msg += "Success: " + message;
                    break;
                case ConsoleOutputType.Custom:
                    Console.ForegroundColor = color;
                    msg += message;
                    break;
            }

            // Print the message..
            Console.WriteLine(msg);

            // Restore the foreground color..
            Console.ForegroundColor = c;
        }
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     if (saveStream)
         savedStream.Append(output);
 }
示例#10
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     this.builder.Append(output);
 }
示例#11
0
 private void WriteConsoleEx(string buffer, int length, ConsoleOutputType outputType)
 {
     Device.WriteConsole(buffer, length, outputType);
 }
示例#12
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     SqlContext.Pipe.Send(output);
 }
示例#13
0
 public ConsoleOutput(string output, ConsoleOutputType type)
 {
     Output = output;
     Type   = type;
 }
示例#14
0
 /// <summary>
 /// Write output on console.
 /// </summary>
 /// <param name="output">The output message</param>
 /// <param name="length">Parameter is ignored</param>
 /// <param name="outputType">Parameter is ignored</param>
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     output = output.Trim(' ');
     Console.Write(output);
 }
示例#15
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     this.builder.Append(output);
 }
 /// <summary>
 /// This implementation has no effect
 /// </summary>
 /// <param name="output">The output message</param>
 /// <param name="length">The output's length in byte.</param>
 /// <param name="outputType">The output type.</param>
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 { }
示例#17
0
 public OutputEventArgs(string output, ConsoleOutputType type)
 {
     Output = output;
     Type   = type;
 }