Exemple #1
0
 public Page()
 {
     CanFocus = false;
     ProgressOperationManager = ProgressOperationsManager.Default;
     RemovedFromVisualTree.SubscribeForLifetime(Page_Removed, this.LifetimeManager);
     BreadcrumbBar = Add(new BreadcrumbBar());
     SynchronizeForLifetime(nameof(Bounds), () => { BreadcrumbBar.Width = Width; }, this.LifetimeManager);
 }
Exemple #2
0
        /// <summary>
        /// Shows the dialog on top of the current app
        /// </summary>
        /// <returns>a promise that resolves when this dialog is dismissed. This promise never rejects.</returns>
        private Promise Show()
        {
            ConsoleApp.AssertAppThread();
            var deferred = Deferred.Create();

            ConsoleApp.Current.LayoutRoot.Add(this);
            RemovedFromVisualTree.SubscribeForLifetime(deferred.Resolve, this);
            return(deferred.Promise);
        }
Exemple #3
0
        /// <summary>
        /// Shows the dialog on top of the current app
        /// </summary>
        /// <returns>a Task that resolves when this dialog is dismissed. This Task never rejects.</returns>
        private Task Show()
        {
            ConsoleApp.AssertAppThread();
            var deferred = new TaskCompletionSource <bool>();

            ConsoleApp.Current.LayoutRoot.Add(this);
            RemovedFromVisualTree.SubscribeForLifetime(() => deferred.SetResult(true), this);
            return(deferred.Task);
        }
Exemple #4
0
 public Dialog(ConsoleControl content)
 {
     Add(content).Fill(padding: new Thickness(0, 0, 1, 1));
     closeButton = Add(new Button()
     {
         Text = "Close (ESC)", Background = Theme.DefaultTheme.H1Color, Foreground = ConsoleColor.Black
     }).DockToRight(padding: 1);
     closeButton.Activated.SubscribeForLifetime(Escape, this.LifetimeManager);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this.LifetimeManager);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this.LifetimeManager);
 }
Exemple #5
0
 private Dialog(DialogOptions options)
 {
     this.options = options;
     Add(options.GetContent()).Fill(padding: new Thickness(0, 0, 1, 1));
     closeButton = Add(new Button()
     {
         Text = "Close (ESC)".ToConsoleString(), Background = DefaultColors.H1Color, Foreground = ConsoleColor.Black
     }).DockToRight(padding: 1);
     closeButton.Pressed.SubscribeForLifetime(Escape, this);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
 }
Exemple #6
0
 public Dialog(ConsoleControl content)
 {
     Add(content).Fill(padding: new Thickness(0, 0, 1, 1));
     AllowEscapeToCancel = true;
     closeButton         = Add(new Button()
     {
         Text = "Close (ESC)".ToConsoleString(), Background = DefaultColors.H1Color, Foreground = ConsoleColor.Black
     }).DockToRight(padding: 1);
     closeButton.Pressed.SubscribeForLifetime(Escape, this);
     BeforeAddedToVisualTree.SubscribeForLifetime(OnBeforeAddedToVisualTree, this);
     AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
     RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
 }
Exemple #7
0
        public ScrollablePanel()
        {
            ScrollableContent = Add(new ConsolePanel()
            {
                IsVisible = false
            }).Fill();

            verticalScrollbar = Add(new Scrollbar(Orientation.Vertical)
            {
                Width = 1
            }).DockToRight();
            horizontalScrollbar = Add(new Scrollbar(Orientation.Horizontal)
            {
                Height = 1
            }).DockToBottom();

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
            RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this.LifetimeManager);
        }
Exemple #8
0
        public ScrollablePanel()
        {
            ScrollableContent = Add(new ConsolePanel()
            {
                IsVisible = true
            }).Fill();
            SynchronizeForLifetime(nameof(Background), () => ScrollableContent.Background = Background, this);
            verticalScrollbar = Add(new Scrollbar(Orientation.Vertical)
            {
                Width = 1
            }).DockToRight();
            horizontalScrollbar = Add(new Scrollbar(Orientation.Horizontal)
            {
                Height = 1
            }).DockToBottom();

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
            RemovedFromVisualTree.SubscribeForLifetime(OnRemovedFromVisualTree, this);
        }
Exemple #9
0
        /// <summary>
        /// Shows the dialog on top of the current app
        /// </summary>
        /// <returns>a Task that resolves when this dialog is dismissed. This Task never rejects.</returns>
        private Task Show()
        {
            ConsoleApp.AssertAppThread();
            var deferred = new TaskCompletionSource <bool>();

            ConsoleApp.Current.LayoutRoot.Add(this);
            RemovedFromVisualTree.SubscribeForLifetime(() => deferred.TrySetResult(true), this);

            if (options.AutoDismissTask != null)
            {
                ConsoleApp.Current.Invoke(async() =>
                {
                    await options.AutoDismissTask;
                    this.TryDispose();
                    deferred.TrySetResult(true);
                });
            }

            return(deferred.Task);
        }
Exemple #10
0
 internal void RemovedFromVisualTreeInternal()
 {
     RemovedFromVisualTree.Fire();
 }