V1.2
This commit is contained in:
29
CapMachine.Wpf/Converts/MeterSlopCycleConver.cs
Normal file
29
CapMachine.Wpf/Converts/MeterSlopCycleConver.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace CapMachine.Wpf.Converts
|
||||
{
|
||||
/// <summary>
|
||||
/// 循环次数的显示
|
||||
/// </summary>
|
||||
public class MeterSlopCycleConver : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
return " ×" + value.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
65
CapMachine.Wpf/Converts/SecToStrConvert.cs
Normal file
65
CapMachine.Wpf/Converts/SecToStrConvert.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
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;
|
||||
using static ICSharpCode.SharpZipLib.Zip.ZipEntryFactory;
|
||||
|
||||
namespace CapMachine.Wpf.Converts
|
||||
{
|
||||
/// <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)
|
||||
{
|
||||
TimeSpan TimeInfo = TimeSpan.FromSeconds(TotalSec);
|
||||
return TimeInfo.ToString();
|
||||
}
|
||||
|
||||
/// <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("时间格式输入不正确");
|
||||
return (int)0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user