コード例 #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);
     }
 }
コード例 #2
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     _pending += output;
     if (output.IndexOfAny(new[] { '\r', '\n' }) == 0)
     {
         _output.Add(_pending);
         _pending = string.Empty;
     }
 }
コード例 #3
0
 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
ファイル: ConsoleOutput.cs プロジェクト: Hornster/Sector5
        /// <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
ファイル: Program.cs プロジェクト: atom0s/Steamless.NET
        /// <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
ファイル: ConsoleDevice.cs プロジェクト: xposure/rdotnet
 /// <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
ファイル: Program.cs プロジェクト: gibbed/Steamless.NET
        /// <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;
        }
コード例 #9
0
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     if (saveStream)
         savedStream.Append(output);
 }
コード例 #10
0
ファイル: MockDevice.cs プロジェクト: tjaskula/rdotnet
 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
ファイル: ConsoleOutput.cs プロジェクト: equadon/alttp
 public ConsoleOutput(string output, ConsoleOutputType type)
 {
     Output = output;
     Type   = type;
 }
コード例 #14
0
ファイル: ConsoleDevice.cs プロジェクト: defelix/rdotnet
 /// <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
ファイル: MockDevice.cs プロジェクト: wolfhesse/rdotnet
 public void WriteConsole(string output, int length, ConsoleOutputType outputType)
 {
     this.builder.Append(output);
 }
コード例 #16
0
 /// <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
ファイル: OutputEventArgs.cs プロジェクト: equadon/alttp
 public OutputEventArgs(string output, ConsoleOutputType type)
 {
     Output = output;
     Type   = type;
 }