Provides an interactive console for debugging.

Namespace: DigitalRune.Game.UI.Controls
Assembly: DigitalRune.Game.UI (in DigitalRune.Game.UI.dll) Version: 1.1.0.0 (1.1.1.9392)

Syntax

C#
public class Console : UIControl, IConsole
Visual Basic
Public Class Console _
	Inherits UIControl _
	Implements IConsole
Visual C++
public ref class Console : public UIControl, 
	IConsole

Remarks

If the user enters a command, the CommandEntered event is raised. If this event is not handled (see Handled), the Interpreter handles the command.

To add new commands, you can either handle the CommandEntered event, or add new commands to the Interpreter (see Commands).

The console has a command history that can be accessed with the up/down keys. The console content can be scrolled with the page up/down keys or a vertical scroll bar.

" can be used to group several words. To write " in a command argument it must be escaped using \".

The Console assumes that a fixed-width Font is used.

Examples

The following example opens a window containing a console.
C# Copy imageCopy
void ShowConsoleWindow(UIScreen screen)
{
  var window = new Window
  {
    Title = "Console Window",
    Width = 480,
    Height = 240
  };
  var console = new Console
  {
    HorizontalAlignment = HorizontalAlignment.Stretch,
    VerticalAlignment = VerticalAlignment.Stretch
  };
  window.Content = console;

  // Print a message in the console.
  console.WriteLine("Enter 'help' to see all available commands.");

  // Register a new command 'close', which closes the console window.
  var closeCommand = new ConsoleCommand("close", "Close console.", _ => window.Close());
  console.Interpreter.Commands.Add(closeCommand);

  window.Show(_screen);
}

Inheritance Hierarchy

System..::..Object
  DigitalRune.Game..::..GameObject
    DigitalRune.Game.UI.Controls..::..UIControl
      DigitalRune.Game.UI.Controls..::..Console

See Also