using ExtendedGrid.Microsoft.Windows.Controls; using SciChart.Core.Extensions; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Text; using System.Threading.Tasks; using System.Windows.Data; namespace MECF.Framework.UI.Client.Converter { public class SecondsToHourMinConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return ""; if (value.ToString() is string stringValue) { if (double.TryParse(stringValue, out double totalSeconds)) { var secondAll = Math.Round(totalSeconds, 1, MidpointRounding.AwayFromZero); // 将总秒数转换为时间跨度 TimeSpan timeSpan = TimeSpan.FromSeconds(secondAll); // 格式化为 HH:mm:ss string formattedTime = $"{timeSpan.Hours:D2}:{timeSpan.Minutes:D2}:{timeSpan.Seconds:D2}.{timeSpan.Milliseconds / 10:D2}"; return formattedTime; } } return value; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }