/// <inheritdoc/>
 public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
 {
     return(new ProgressBar
     {
         MaxValue = task.MaxValue,
         Value = task.Value,
         Width = Width,
         CompletedStyle = CompletedStyle,
         FinishedStyle = FinishedStyle,
         RemainingStyle = RemainingStyle,
         IndeterminateStyle = IndeterminateStyle,
         IsIndeterminate = task.IsIndeterminate,
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a task.
        /// </summary>
        /// <param name="description">The task description.</param>
        /// <param name="settings">The task settings.</param>
        /// <returns>The newly created task.</returns>
        public ProgressTask AddTask(string description, ProgressTaskSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            lock (_taskLock)
            {
                var task = new ProgressTask(_taskId++, description, settings.MaxValue, settings.AutoStart);

                _tasks.Add(task);

                return(task);
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
        {
            var remaining = task.RemainingTime;

            if (remaining == null)
            {
                return(new Markup("--:--:--"));
            }

            if (remaining.Value.TotalHours > 99)
            {
                return(new Markup("**:**:**"));
            }

            return(new Text($"{remaining.Value:hh\\:mm\\:ss}", Style ?? Style.Plain));
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
        {
            var total = new FileSize(task.MaxValue);

            if (task.IsFinished)
            {
                return(new Markup(string.Format(
                                      "[green]{0} {1}[/]",
                                      total.Format(Culture),
                                      total.Suffix)));
            }
            else
            {
                var downloaded = new FileSize(task.Value, total.Unit);

                return(new Markup(string.Format(
                                      "{0}[grey]/[/]{1} [grey]{2}[/]",
                                      downloaded.Format(Culture),
                                      total.Format(Culture),
                                      total.Suffix)));
            }
        }
        /// <inheritdoc/>
        public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
        {
            var text = task.Description?.RemoveNewLines()?.Trim();

            return(new Markup(text ?? string.Empty).Overflow(Overflow.Ellipsis).RightAligned());
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gets a renderable representing the column.
 /// </summary>
 /// <param name="context">The render context.</param>
 /// <param name="task">The task.</param>
 /// <param name="deltaTime">The elapsed time since last call.</param>
 /// <returns>A renderable representing the column.</returns>
 public abstract IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime);