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);
}