mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2024-11-23 20:36:33 +01:00
Added padding to the upload/download progress numbers to reduce left-right message "jumping".
Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
parent
233dc66026
commit
7188a79263
@ -151,7 +151,7 @@ namespace XenAdmin.Actions
|
||||
private void UpdateProgress(int percent)
|
||||
{
|
||||
var descr = string.Format(Messages.UPLOAD_PATCH_UPLOADING_PROGRESS_DESCRIPTION, _patchName,
|
||||
Util.DiskSizeString(percent * _totalPatchSize / 100), Util.DiskSizeString(_totalPatchSize));
|
||||
Util.DiskSizeString(percent * _totalPatchSize / 100, "F1"), Util.DiskSizeString(_totalPatchSize));
|
||||
|
||||
ByteProgressDescription = descr;
|
||||
Tick(percent, descr);
|
||||
|
@ -152,7 +152,7 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
var sr1 = sr;
|
||||
var descr = string.Format(Messages.UPLOAD_PATCH_UPLOADING_TO_SR_PROGRESS_DESCRIPTION, _updateName, sr1.Name(),
|
||||
Util.DiskSizeString(percent * _totalUpdateSize / 100), Util.DiskSizeString(_totalUpdateSize));
|
||||
Util.DiskSizeString(percent * _totalUpdateSize / 100, "F1"), Util.DiskSizeString(_totalUpdateSize));
|
||||
|
||||
var actionPercent = (int)((totalUploaded * 100 + percent) / totalCount);
|
||||
ByteProgressDescription = descr;
|
||||
|
@ -293,7 +293,7 @@ namespace XenAdmin.Actions
|
||||
{
|
||||
int pc = (int)(95.0 * e.BytesReceived / e.TotalBytesToReceive);
|
||||
var descr = string.Format(Messages.DOWNLOAD_AND_EXTRACT_ACTION_DOWNLOADING_DETAILS_DESC, updateName,
|
||||
Util.DiskSizeString(e.BytesReceived),
|
||||
Util.DiskSizeString(e.BytesReceived, "F1"),
|
||||
Util.DiskSizeString(e.TotalBytesToReceive));
|
||||
ByteProgressDescription = descr;
|
||||
Tick(pc, descr);
|
||||
|
@ -138,16 +138,16 @@ namespace XenAdmin
|
||||
return string.Format(Messages.VAL_FORMAT, value, unit);
|
||||
}
|
||||
|
||||
public static string DiskSizeString(long bytes)
|
||||
public static string DiskSizeString(long bytes, string format = null)
|
||||
{
|
||||
return DiskSizeString(bytes, 1);
|
||||
return DiskSizeString(bytes, 1, format);
|
||||
}
|
||||
|
||||
public static string DiskSizeString(long bytes, int dp)
|
||||
public static string DiskSizeString(long bytes, int dp, string format = null)
|
||||
{
|
||||
ulong abs = (ulong)Math.Abs(bytes);
|
||||
string unit;
|
||||
string value = ByteSizeString(abs, dp, false, out unit);
|
||||
string value = ByteSizeString(abs, dp, false, out unit, format);
|
||||
return string.Format(Messages.VAL_FORMAT, value, unit);
|
||||
}
|
||||
|
||||
@ -169,24 +169,27 @@ namespace XenAdmin
|
||||
return ByteSizeString(bytes, 0, false, out unit);
|
||||
}
|
||||
|
||||
private static string ByteSizeString(double bytes, int decPlaces, bool isRate, out string unit)
|
||||
private static string ByteSizeString(double bytes, int decPlaces, bool isRate, out string unit, string format = null)
|
||||
{
|
||||
if (bytes >= BINARY_GIGA)
|
||||
{
|
||||
unit = isRate ? Messages.VAL_GIGRATE : Messages.VAL_GIGB;
|
||||
return Math.Round(bytes / BINARY_GIGA, decPlaces).ToString();
|
||||
var result = Math.Round(bytes / BINARY_GIGA, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
if (bytes >= BINARY_MEGA)
|
||||
{
|
||||
unit = isRate ? Messages.VAL_MEGRATE : Messages.VAL_MEGB;
|
||||
return Math.Round(bytes / BINARY_MEGA, decPlaces).ToString();
|
||||
var result = Math.Round(bytes / BINARY_MEGA, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
if (bytes >= BINARY_KILO)
|
||||
{
|
||||
unit = isRate ? Messages.VAL_KILRATE : Messages.VAL_KILB;
|
||||
return Math.Round(bytes / BINARY_KILO, decPlaces).ToString();
|
||||
var result = Math.Round(bytes / BINARY_KILO, decPlaces);
|
||||
return string.IsNullOrEmpty(format) ? result.ToString() : result.ToString(format);
|
||||
}
|
||||
|
||||
unit = isRate ? Messages.VAL_RATE : Messages.VAL_BYTE;
|
||||
|
Loading…
Reference in New Issue
Block a user