How to create and print on a Console

Before a console can be displayed, it must be as the SadConsole.Global.CurrentScreen or added as a child of the current screen.

Using the default console class

When you create a SadConsole.Console class instance, you are getting all of the basic functionality by default. However, the console will be blank, and you will need to configure it piece-by-piece. This means that you will have to print all of the things you want on the console every time you create it. This may work well for prototyping a design of some sort, but it doesn’t really give you anything reusable.

The following example shows the basic steps to create a console that has some text on it.

Loading a previously saved console

Saving and loading a console on the Windows platform is pretty simple. With only two lines of code, you can load and save your console. This lets you either design a console by hand, or through the SadConsole editor. The benefit of this is that you only have to design your console once, and then you can load it into multiple console instances, or just a single console instance.

The following code demonstrates how to load an entire console from a file.

Creating a new console type

If you want to create a console that is consistently created the same every time it is instantiated, you should create a newly derived type. You can hard code size, behavior settings, or even the look of the console.