本文整理汇总了C#中System.TimeSpan.ToDescriptiveText方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.ToDescriptiveText方法的具体用法?C# TimeSpan.ToDescriptiveText怎么用?C# TimeSpan.ToDescriptiveText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TimeSpan
的用法示例。
在下文中一共展示了TimeSpan.ToDescriptiveText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AppendCharacterTrainingTime
/// <summary>
/// Appends the given training time for the specified character to the provided <see cref="StringBuilder"/>. *
/// Format is : "1d, 5h, 32m John Doe (Eidetic Memory)"
/// Used to update the window's title.
/// </summary>
/// <param name="character">The character.</param>
/// <param name="time">The time.</param>
/// <returns></returns>
private static string AppendCharacterTrainingTime(Character character, TimeSpan time)
{
StringBuilder builder = new StringBuilder();
builder.Append($"{time.ToDescriptiveText(DescriptiveTextOptions.None)} {character.Name}");
if (Settings.UI.MainWindow.ShowSkillNameInWindowTitle)
builder.Append($" ({character.CurrentlyTrainingSkill.SkillName})");
return builder.ToString();
}
示例2: UpdateDisplay
/// <summary>
/// Updates control contents.
/// </summary>
private void UpdateDisplay()
{
trainTime = TimeSpan.Zero;
// Default all known flag to true. Will be set to false in UpdateNode() if a requirement is not met
bool allCertsKnown = true;
// Default unplanned certificates flag to false. Will be set to true in UpdateNode() if a requirement is neither met nor planned
bool certsUnplanned = false;
// Treeview update
tvCertList.BeginUpdate();
try
{
tvCertList.Nodes.Clear();
if (m_object != null && m_plan != null)
{
// Recursively create nodes
foreach (var cert in StaticCertificates.AllCertificates.Where(x=> x.Recommendations.Contains(m_object)))
{
tvCertList.Nodes.Add(GetCertNode(cert));
}
}
// Update the nodes
foreach (TreeNode node in tvCertList.Nodes)
{
UpdateNode(node, ref allCertsKnown, ref certsUnplanned);
}
}
finally
{
tvCertList.EndUpdate();
}
// Set training time required label
if (allCertsKnown)
{
lblTimeRequired.Text = "No training required";
}
else
{
lblTimeRequired.Text = trainTime.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas);
}
// Set minimun control size
Size timeRequiredTextSize = TextRenderer.MeasureText(lblTimeRequired.Text, Font);
Size newMinimumSize = new Size(timeRequiredTextSize.Width + btnAddCerts.Width, 0);
if (this.MinimumSize.Width < newMinimumSize.Width)
this.MinimumSize = newMinimumSize;
// Enable / disable button
btnAddCerts.Enabled = certsUnplanned;
}
示例3: UpdateTimeStatusLabel
internal void UpdateTimeStatusLabel(bool selected, int skillCount, TimeSpan totalTime)
{
TimeStatusLabel.AutoToolTip = false;
TimeStatusLabel.Text = String.Format(CultureConstants.DefaultCulture, "{0} to train {1}",
totalTime.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas),
selected ?
String.Format("selected skill{0}", skillCount == 1 ? String.Empty : "s")
: "whole plan");
}
示例4: TimeSpanToText
/// <summary>
/// Transpose the timespan to text.
/// </summary>
/// <param name="time"></param>
/// <param name="includeSeconds"></param>
/// <returns></returns>
private string TimeSpanToText(TimeSpan time, bool includeSeconds)
{
return time.ToDescriptiveText(
DescriptiveTextOptions.FirstLetterUppercase
| DescriptiveTextOptions.SpaceText
| DescriptiveTextOptions.FullText
| DescriptiveTextOptions.IncludeCommas,
includeSeconds);
}
示例5: TimeSpanToText
/// <summary>
/// Transpose the timespan to text.
/// </summary>
/// <param name="time"></param>
/// <param name="includeSeconds"></param>
/// <returns></returns>
private static string TimeSpanToText(TimeSpan time, bool includeSeconds)
=> time.ToDescriptiveText(DescriptiveTextOptions.IncludeCommas, includeSeconds);
示例6: AppendCharacterTrainingTime
/// <summary>
/// Appends the given training time for the specified character to the provided <see cref="StringBuilder"/>. *
/// Format is : "1d, 5h, 32m John Doe (Eidetic Memory)"
/// Used to update the window's title.
/// </summary>
/// <param name="builder"></param>
/// <param name="character"></param>
/// <param name="time"></param>
private static string AppendCharacterTrainingTime(CCPCharacter character, TimeSpan time)
{
StringBuilder builder = new StringBuilder();
string skillDescriptionText = time.ToDescriptiveText(DescriptiveTextOptions.Default);
builder.AppendFormat(CultureConstants.DefaultCulture,"{0} {1}", skillDescriptionText, character.Name);
if (Settings.UI.MainWindow.ShowSkillNameInWindowTitle)
builder.AppendFormat(CultureConstants.DefaultCulture, " ({0})", character.CurrentlyTrainingSkill.SkillName);
return builder.ToString();
}