public ProgressOperationControl(ProgressOperationsManager manager, ProgressOperation operation)
        {
            this.Tag                  = operation;
            this.Operation            = operation;
            this.manager              = manager;
            this.Height               = 2;
            messageAndOperationsPanel = Add(new StackPanel()
            {
                Orientation = Orientation.Vertical
            }).Fill();

            messageLabel = messageAndOperationsPanel.Add(new Label()
            {
                Mode = LabelRenderMode.ManualSizing
            }).FillHorizontally();
            messageLabel.CanFocus = true;

            messageLabel.KeyInputReceived.SubscribeForLifetime((k) =>
            {
                if (k.Key == ConsoleKey.Enter)
                {
                    var msg = operation.Message;
                    if (operation.Details != null)
                    {
                        msg += "\n" + operation.Details;
                    }
                    Dialog.ShowMessage(msg);
                }
                else if (k.Key == ConsoleKey.Delete)
                {
                    var app = Application;
                    manager.Operations.Remove(operation);
                    app.FocusManager.TryMoveFocus();
                }
            }, this);


            actionPanel = messageAndOperationsPanel.Add(new StackPanel()
            {
                Orientation = Orientation.Horizontal, Height = 1, Margin = 2
            }).FillHorizontally(messageAndOperationsPanel);
            spinner = actionPanel.Add(new Spinner()
            {
                CanFocus = false
            });
            timeLabel = actionPanel.Add(new Label()
            {
                Mode = LabelRenderMode.SingleLineAutoSize, Text = operation.StartTime.ToFriendlyPastTimeStamp().ToConsoleString()
            });


            spinner.IsSpinning = operation.State == OperationState.InProgress;

            foreach (var action in operation.Actions)
            {
                BindActionToActionPanel(action);
            }

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this);
        }
 public ProgressOperationManagerControl(ProgressOperationsManager manager)
 {
     this.manager = manager;
     this.scrollablePanel = Add(new ScrollablePanel()).Fill();
     operationsStackPanel = scrollablePanel.ScrollableContent.Add(new StackPanel() { Orientation = Orientation.Vertical, AutoSize=true }).FillHoriontally();
     noNotificationsLabel = Add(new Label() { Text = "No notifications".ToConsoleString(), X=1, Y=1 });
     manager.Operations.SynchronizeForLifetime(Operations_Added, Operations_Removed, Operations_Changed, this.LifetimeManager);
 }
        public NotificationButton(ProgressOperationsManager manager)
        {
            this.manager = manager;

            launcher = Add(new Button());
            launcher.Shortcut = new KeyboardShortcut(ConsoleKey.N, ConsoleModifiers.Alt);
            launcher.Pressed.SubscribeForLifetime(NotificationButton_Activated, LifetimeManager);
            launcherFg = launcher.Foreground;
            spinner = Add(new Spinner() { IsVisible = false, IsSpinning = false, CanFocus = false, X = 1, Foreground = ConsoleColor.Cyan });
            Manager_ProgressOperationsChanged();
            manager.ProgressOperationsChanged += Manager_ProgressOperationsChanged;
            this.AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
        }
 public ProgressOperationManagerControl(ProgressOperationsManager manager)
 {
     this.manager         = manager;
     this.scrollablePanel = Add(new ScrollablePanel()).Fill();
     operationsStackPanel = scrollablePanel.ScrollableContent.Add(new StackPanel()
     {
         Orientation = Orientation.Vertical, AutoSize = true
     }).FillHorizontally();
     noNotificationsLabel = Add(new Label()
     {
         Text = "No notifications".ToConsoleString(), X = 1, Y = 1
     });
     manager.Operations.SynchronizeForLifetime(Operations_Added, Operations_Removed, Operations_Changed, this);
 }
示例#5
0
        public NotificationButton(ProgressOperationsManager manager)
        {
            this.manager = manager;

            launcher          = Add(new Button());
            launcher.Shortcut = new KeyboardShortcut(ConsoleKey.N, ConsoleModifiers.Alt);
            launcher.Pressed.SubscribeForLifetime(NotificationButton_Activated, LifetimeManager);
            launcherFg = launcher.Foreground;
            spinner    = Add(new Spinner()
            {
                IsVisible = false, IsSpinning = false, CanFocus = false, X = 1, Foreground = ConsoleColor.Cyan
            });
            Manager_ProgressOperationsChanged();
            manager.ProgressOperationsChanged += Manager_ProgressOperationsChanged;
            this.AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
        }
        public ProgressOperationControl(ProgressOperationsManager manager, ProgressOperation operation)
        {
            this.Tag = operation;
            this.Operation = operation;
            this.manager = manager;
            this.Height = 2;
            messageAndOperationsPanel = Add(new StackPanel() { Orientation = Orientation.Vertical }).Fill();

            messageLabel = messageAndOperationsPanel.Add(new Label() { Mode = LabelRenderMode.ManualSizing }).FillHoriontally();
            messageLabel.CanFocus = true;

            messageLabel.KeyInputReceived.SubscribeForLifetime((k) =>
            {
                if (k.Key == ConsoleKey.Enter)
                {
                    var msg = operation.Message;
                    if (operation.Details != null)
                    {
                        msg += "\n" + operation.Details;
                    }
                    Dialog.ShowMessage(msg);
                }
                else if(k.Key == ConsoleKey.Delete)
                {
                    var app = Application;
                    manager.Operations.Remove(operation);
                    app.FocusManager.TryMoveFocus();
                }
            }, this.LifetimeManager);

            actionPanel = messageAndOperationsPanel.Add(new StackPanel() { Orientation = Orientation.Horizontal, Height = 1, Margin = 2 }).FillHoriontally(messageAndOperationsPanel);
            spinner = actionPanel.Add(new Spinner() { CanFocus=false});
            timeLabel = actionPanel.Add(new Label() { Mode = LabelRenderMode.SingleLineAutoSize, Text = operation.StartTime.ToFriendlyPastTimeStamp().ToConsoleString() });

            spinner.IsSpinning = operation.State == OperationState.InProgress;

            foreach (var action in operation.Actions)
            {
                BindActionToActionPanel(action);
            }

            AddedToVisualTree.SubscribeForLifetime(OnAddedToVisualTree, this.LifetimeManager);
        }