This commit is contained in:
2024-09-25 15:44:59 +08:00
parent a76546ebe6
commit 6bf0d5d7ba
72 changed files with 21606 additions and 1608 deletions

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace CapMachine.Shared.Controls
{
/// <summary>
/// 秒到字符串类型的展示
/// </summary>
public class SecToStrConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
return SecToString((int)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return null;
return StringToSec((string)value);
}
/// <summary>
/// 秒时间到 00:00:00字符串
/// </summary>
/// <returns></returns>
private string SecToString(int TotalSec)
{
try
{
TimeSpan TimeInfo = TimeSpan.FromSeconds(TotalSec);
return TimeInfo.ToString();
}
catch (Exception ex)
{
MessageBox.Show("请检查输入时间数据!", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
return "00:00:00";
}
}
/// <summary>
/// 00:00:00到秒时间
/// </summary>
/// <returns></returns>
private int StringToSec(string timeString)
{
try
{
TimeSpan TimeInfo = TimeSpan.Parse(timeString);
return (int)TimeInfo.TotalSeconds;
}
catch (Exception ex)
{
MessageBox.Show("请按照时间样式输入时间数据!", "提示", MessageBoxButton.OK, MessageBoxImage.Hand);
return 0;
}
}
}
}