This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
nebolconsole [2020/02/22 23:06] – external edit 127.0.0.1 | nebolconsole [2021/11/04 12:45] (current) – nebol | ||
---|---|---|---|
Line 2: | Line 2: | ||
< | < | ||
+ | |||
+ | An example of a setup with a large output area and a small input area at the bottom: | ||
+ | <code csharp> | ||
+ | static void SetupConsole() | ||
+ | { | ||
+ | const int Width = 80; | ||
+ | const int Height = 50; | ||
+ | |||
+ | NebolConsole.Console.Instance.SetWindowSize(Width, | ||
+ | |||
+ | var output = new ConsoleArea(" | ||
+ | NebolConsole.Console.Instance.Areas.Add(output); | ||
+ | |||
+ | var input = new ConsoleArea(" | ||
+ | NebolConsole.Console.Instance.Areas.Add(input); | ||
+ | |||
+ | // add the main area last | ||
+ | var main = new ConsoleArea(" | ||
+ | NebolConsole.Console.Instance.Areas.Add(main); | ||
+ | |||
+ | // add borders, they are drawn on the main area in this case | ||
+ | // so they are not actually part of their own areas but around them | ||
+ | foreach (var carea in NebolConsole.Console.Instance.Areas.Where(item => item != main)) | ||
+ | { | ||
+ | main.WriteBorder(carea, | ||
+ | carea.Wrap = true; | ||
+ | carea.Scroll = true; | ||
+ | } | ||
+ | |||
+ | NebolConsole.Console.Instance.OnKeyPressed += OnKeyPressed; | ||
+ | NebolConsole.Console.Instance.OnStringEntered += OnStringEntered; | ||
+ | |||
+ | input.SetCursorPosition(); | ||
+ | |||
+ | NebolConsole.Console.Instance.Update(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | <code csharp> | ||
+ | protected static void OnStringEntered(object sender, ConsoleStringEnteredEventArgs ea) | ||
+ | { | ||
+ | var area = NebolConsole.Console.Instance.GetArea(" | ||
+ | area.WriteLine(" | ||
+ | } | ||
+ | |||
+ | protected static void OnKeyPressed(object sender, ConsoleKeyPressedEventArgs ea) | ||
+ | { | ||
+ | var area = NebolConsole.Console.Instance.GetArea(" | ||
+ | area.Write(ea.Key.KeyChar.ToString()); | ||
+ | |||
+ | area.SetCursorPosition(); | ||
+ | NebolConsole.Console.Instance.Update(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code csharp> | ||
+ | do | ||
+ | { | ||
+ | NebolConsole.Console.Instance.Update(); | ||
+ | Thread.Sleep(1000); | ||
+ | } | ||
+ | while (!shutdown); | ||
+ | </ | ||
+ |