A class that manages the focus of a CLI application
Inheritance: ObservableObject
示例#1
0
 /// <summary>
 /// Creates a new console app given a set of boundaries
 /// </summary>
 /// <param name="x">The left position on the target console to bound this app</param>
 /// <param name="y">The right position on the target console to bound this app</param>
 /// <param name="w">The width of the app</param>
 /// <param name="h">The height of the app</param>
 public ConsoleApp(int x, int y, int w, int h)
     : base(ConsoleProvider.Current)
 {
     SetFocusOnStart = true;
     Theme = new Theme();
     Bitmap = new ConsoleBitmap(x, y, w, h);
     LayoutRoot = new ConsolePanel { Width = w, Height = h };
     FocusManager = new FocusManager();
     LayoutRoot.Application = this;
     AutoFillOnConsoleResize = false;
     FocusManager.SubscribeForLifetime(nameof(FocusManager.FocusedControl), Paint, LifetimeManager);
     LayoutRoot.Controls.BeforeAdded.SubscribeForLifetime((c) => { c.Application = this; c.BeforeAddedToVisualTreeInternal(); }, LifetimeManager);
     LayoutRoot.Controls.BeforeRemoved.SubscribeForLifetime((c) => { c.BeforeRemovedFromVisualTreeInternal(); }, LifetimeManager);
     LayoutRoot.Controls.Added.SubscribeForLifetime(ControlAddedToVisualTree, LifetimeManager);
     LayoutRoot.Controls.Removed.SubscribeForLifetime(ControlRemovedFromVisualTree, LifetimeManager);
     WindowResized.SubscribeForLifetime(HandleDebouncedResize, LifetimeManager);
 }