Example #1
0
 public void Update(string message, ConsoleColor? color = null)
 {
     int prevX, prevY;
     prevX = Console.CursorLeft;
     prevY = Console.CursorTop;
     if (message?.Length > (MaxWidth ?? _fw))
         message = message.Substring(0, (MaxWidth ?? _fw) - 3) + "...";
     // Clear Message Space
     Console.SetCursorPosition(_x, _y);
     Consoul.Write(new string(' ', MaxWidth ?? _fw), writeLine: false);
     // Write Message
     Console.SetCursorPosition(_x, _y);
     Consoul.Write(message, color, false);
     Console.SetCursorPosition(prevX, prevY);
 }
Example #2
0
        /// <summary>
        /// Prompts the user to input a file path.
        /// </summary>
        /// <param name="message"><inheritdoc cref="Write" path="/param[@name='message']"/></param>
        /// <param name="checkExists">Indicates whether to check the file exists before allowing the user exit the loop.</param>
        /// <param name="color"><inheritdoc cref="Write" path="/param[@name='color']"/></param>
        /// <returns></returns>
        public static string PromptForFilepath(string message, bool checkExists, ConsoleColor?color = null)
        {
            string path;

            do
            {
                Consoul.Write(message, color);
                path = Consoul.Read();
            } while (string.IsNullOrEmpty(path) && (checkExists ? !File.Exists(path) : true));
            if (path.StartsWith("\"") && path.EndsWith("\""))
            {
                path = path.Substring(1, path.Length - 2);
            }
            return(path);
        }