PowerArgs.Cli.Dialog.OnAddedToVisualTree C# (CSharp) Method

OnAddedToVisualTree() private method

private OnAddedToVisualTree ( ) : void
return void
        private void OnAddedToVisualTree()
        {
            if(Parent != Application.LayoutRoot)
            {
                throw new InvalidOperationException("Dialogs must be added to the LayoutRoot of an application");
            }

            if (MaxHeight > 0)
            {
                this.Height = Math.Min(MaxHeight, Application.LayoutRoot.Height - 2);
            }
            else
            {
                this.Height = Application.LayoutRoot.Height - 2;
            }

            this.CenterVertically();
            this.FillHoriontally();
            ConsoleApp.Current.FocusManager.TryMoveFocus();

            Application.FocusManager.SubscribeForLifetime(nameof(FocusManager.StackDepth), () =>
            {
                if(Application.FocusManager.StackDepth != myFocusStackDepth)
                {
                    closeButton.Background = Application.Theme.DisabledColor;
                }
                else
                {
                    closeButton.Background = Application.Theme.H1Color;
                }
            }, this.LifetimeManager);
        }