private void DisplayWindow(int width, int height, Drawing.Theme theme) { WPFFormattedTextViewer viewer = new WPFFormattedTextViewer(width, height, 8, 17, 14.5, theme); Window window = new Window(); window.Content = viewer; window.Background = new SolidColorBrush(theme.Palette[MooTUI.Drawing.Color.Base03]); window.SizeToContent = SizeToContent.WidthAndHeight; new MooInterface(viewer, Widget); Widget.ClaimFocus(); Widget.Render(); //System.Console.WriteLine("Showing window"); Widget.Render(); window.ShowDialog(); //System.Console.WriteLine("Window closed"); }
/// <summary> /// Generates and displays a new Console. /// </summary> /// <param name="width">The width of the console (must be at least 8)</param> /// <param name="height">The height of the console (must be at least 4)</param> /// <param name="theme">The color scheme of the console (optional)</param> public Console(int width, int height, TextSpan?title, Drawing.Theme theme) { if (width < 8) { throw new ArgumentOutOfRangeException(nameof(width), "Width must be at least 8."); } if (height < 4) { throw new ArgumentOutOfRangeException(nameof(height), "Height must be at least 4."); } Widget = new ConsoleWidget(new Layout.LayoutRect(width, height), title); Thread thread = new Thread(() => DisplayWindow(width, height, theme ?? Drawing.Theme.Basic.Value)); thread.SetApartmentState(ApartmentState.STA); thread.Start(); Widget.Render(); }