Files
spectre.console/src/Spectre.Console/Live/Progress/Columns/TransferSpeedColumn.cs
Patrik Svensson fa5a1e88ec Clean up Widgets
* Move /Widgets/Live/* to /Live/*
* Move /Widgets/Prompt/* to /Prompts/*
* Move tests and expectations to match the new locations
2021-07-14 08:38:44 -04:00

30 lines
820 B
C#

using System;
using System.Globalization;
using Spectre.Console.Rendering;
namespace Spectre.Console
{
/// <summary>
/// A column showing transfer speed.
/// </summary>
public sealed class TransferSpeedColumn : ProgressColumn
{
/// <summary>
/// Gets or sets the <see cref="CultureInfo"/> to use.
/// </summary>
public CultureInfo? Culture { get; set; }
/// <inheritdoc/>
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
{
if (task.Speed == null)
{
return new Text("?/s");
}
var size = new FileSize(task.Speed.Value);
return new Markup(string.Format("{0}/s", size.ToString(suffix: true, Culture)));
}
}
}