/// <summary> /// Creates a new ConsoleControl /// </summary> public ConsoleControl() { CanFocus = true; Background = DefaultColors.BackgroundColor; this.Foreground = DefaultColors.ForegroundColor; this.IsVisible = true; this.Id = GetType().FullName + "-" + Guid.NewGuid().ToString(); this.SubscribeForLifetime(ObservableObject.AnyProperty, () => { if (Application != null && Application.IsRunning) { ConsoleApp.AssertAppThread(Application); Application.Paint(); } }, this); this.AddedToVisualTree.SubscribeOnce(() => { if (Application.IsRunning) { Ready.Fire(); } else { Application.QueueAction(Ready.Fire); } }); }
/// <summary> /// Creates a new ConsoleControl /// </summary> public ConsoleControl() { CanFocus = true; this.Bitmap = new ConsoleBitmap(1, 1); this.SubscribeForLifetime(nameof(Bounds), () => { if (Width > 0 && Height > 0) { this.Bitmap.Resize(Width, Height); } }, this); Background = DefaultColors.BackgroundColor; this.Foreground = DefaultColors.ForegroundColor; this.IsVisible = true; this.Id = GetType().FullName + "-" + Guid.NewGuid().ToString(); this.SubscribeForLifetime(ObservableObject.AnyProperty, () => { if (Application != null && Application.IsRunning && Application.IsDrainingOrDrained == false) { ConsoleApp.AssertAppThread(Application); Application.Paint(); } }, this); this.AddedToVisualTree.SubscribeOnce(() => { if (Application.IsRunning) { Ready.Fire(); } else { Application.InvokeNextCycle(Ready.Fire); } }); }