Click here to Skip to main content
Click here to Skip to main content

xConsole Project

, 23 May 2014
Rate this:
Please Sign up or sign in to vote.
Coloring the window console

Introduction

Hi, it`s my project called xConsole, in few words this DLL gives you the ability to color, animate comfortably the console window, parse input, modify fonts and more.

It has been written in C# .NET 4.5.

Using the Library

  1. Add Reference > xConsole.dll
  2. using xConsoleProject;

Example of coloring:

xConsole.WriteLine("^yLorem ipsum dolor sit amet^r, consectetur adipiscing elit. " + 
     "^.Nullam porttitor lectus justo, vel viverra est pellentesque non.^!"); 

^y Set Yellow Color
^r Set Red Color
^. Set a Random Color (different from the background)
^! Restore default font color

*y *r *m Sets Colors
*. Random background Color
*! Restore default bg.

xConsole.CoolWriteLine("I like write like a boss.");
 
// OR

xConsole.CoolWriting = true;
xConsole.WriteLine("^600I like write ^F00like a boss"); // Or 6 digits (^FF00FF)..
xConsole.WriteLine("Yes ^ycolors is ^msupported^!");
xConsole.CoolWriting = false;

[Updated] List of Colors

Using enum (now same of Microsoft):

public enum ConsoleColor
{
    Black = 0,
    DarkBlue = 1,
    DarkGreen = 2,
    DarkCyan = 3,
    DarkRed = 4,
    DarkMagenta = 5,
    DarkYellow = 6,
    Gray = 7,
    DarkGray = 8,
    Blue = 9,
    Green = 10,
    Cyan = 11,
    Red = 12,
    Magenta = 13,
    Yellow = 14,
    White = 15,
} 

HEX to ConsoleColor (the HEX code must be uppercase):

xConsole.WriteLine("^600I like to paint ^F00like a boss");

With letters:

xConsole.WriteLine("^yI like to paint ^rlike a boss");
w:    White
z:    Black
y:    Yellow
g:    Green
r:    Red
b:    Blue
c:    Cyan
m:    Magenta

Read Line

 var args = xConsole.ReadLine();

Will give back a List<string> (never null) contains the arguments parsed, entered by the user, Like:

Hi "this is a string" then 9999

[0] = Hi
[1] = This is a string
[2] = then
[3] = 9999

An empty input: (list size 1, value empty string)

[0] =

So you need to check if its string is Empty. Yeah, i don't like null values..

Spinner

This class allows you to create an animated spinner.

var spinner = new xConsole.Spinner();
                
new Thread(delegate()
{
    //Spin until user interruption
    Console.ReadKey(true);

    spinner.Break();
    xConsole.Write("^11OK!^!");
}).Start();

xConsole.Write("^2STATUS: ^7"); 
// Waiting the thread is done.
while (spinner.Turn());

Move window

SetWindowPos(int x, int y); 

Other

I also added console helper.

xConsole.SetFont(int);  

Set font, list font, change icon...

Next Update

  • Sound management?

History

23/05/2014
  • Now check updates every 30 days (only in debug)
  • No more create registry key in release
  • Removed Stats sending
  • Removed Settings
  • Fixed ClearColorsAtEnd function (restoring previous colors)
  • Added Test program (Both sources)
21/01/2014
  • Released source code (v 0.3)
  • It's not a spywere see above
18/01/2014
  • [NEW] Optional separate-thread writer (default ON)
  • [NEW] Random color always != from background
  • [NEW] Background colors using * tag
  • [NEW] Update Checking (only in debug)
  • [NEW] New Functions like WaitQueue (main program wait until the queue is resolved)
  • [UPDATED] Fixed a bug in the spinning
  • [UPDATED] Spinning now supports colors
  • [???] A lot of emoji in the code
  • [Source Code] will be available, I need to make it beautiful, btw you can reflect it
  • [It would] be nice to do a port to C++
27/07/2013
  • Improved method of color selection
    Now you can use ^RBG colors (3bytes), like ^F00 = red
    ^00F = Blue, ^0F0 = green, ^600 = darkred ...etc... (RBG colors is rounded to ConsoleColors)
    and ^y = yellow
    ^r = red
    ^m = magenta .. etc
  • Random color moved to ^.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

TheTrigger

Italy Italy
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinpremiumVolynsky Alex23-May-14 12:18 
GeneralMy vote of 1 PinmemberKenL4cp20-Jan-14 10:03 
Question5 PinmemberAssil20-Jan-14 5:15 
GeneralMy vote of 1 PinmemberSpirch20-Jan-14 5:10 
GeneralRe: My vote of 1 PinmemberTheTrigger21-Jan-14 6:15 
Bugwarning this code send information to third party PinmemberSpirch20-Jan-14 5:05 
GeneralRe: warning this code send information to third party PinmemberKenL4cp20-Jan-14 9:28 
GeneralRe: warning this code send information to third party - Updated and Fixed [modified] PinmentorDaveyM6921-Jan-14 1:37 
QuestionCould you please add a version of this code here on CodeProject.? PinprotectorPete O'Hanlon29-Jul-13 22:21 
GeneralMy vote of 5 PinmemberArash M. Dehghani29-Jul-13 9:45 
GeneralMy vote of 4 PinprofessionalAssil27-Jul-13 11:33 
GeneralMy vote of 4 PinprofessionalCarlos190726-Jul-13 6:36 
GeneralRe: My vote of 4 PinmemberTheTrigger26-Jul-13 21:43 
SuggestionRe: My vote of 4 PinprofessionalCarlos19073-Aug-13 5:27 
GeneralMy vote of 4 Pinmemberfredatcodeproject26-Jul-13 4:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 23 May 2014
Article Copyright 2013 by TheTrigger
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid