V1版本
This commit is contained in:
26
CapMachine.Wpf/Converts/BoolOkStrConvert.cs
Normal file
26
CapMachine.Wpf/Converts/BoolOkStrConvert.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
{
|
||||
public class BoolOkStrConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
return (bool)value==true?"正常": "失败";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
CapMachine.Wpf/Converts/BoolStateStrConvert.cs
Normal file
26
CapMachine.Wpf/Converts/BoolStateStrConvert.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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
|
||||
{
|
||||
public class BoolStateStrConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
return (bool)value==true?"运行中": "未运行";
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,13 @@ namespace CapMachine.Wpf.Converts
|
||||
/// <returns></returns>
|
||||
private string SecToString(int TotalSec)
|
||||
{
|
||||
//int hour = TotalSec / 3600;
|
||||
//int minute = (TotalSec - hour * 3600) / 60;
|
||||
//int second = TotalSec % 60;
|
||||
|
||||
//return string.Format("{0}:{1}:{2}", hour, minute, second);
|
||||
////Console.WriteLine(result);
|
||||
|
||||
TimeSpan TimeInfo = TimeSpan.FromSeconds(TotalSec);
|
||||
return TimeInfo.ToString();
|
||||
}
|
||||
|
||||
45
CapMachine.Wpf/Converts/ValuePrecisionConverter.cs
Normal file
45
CapMachine.Wpf/Converts/ValuePrecisionConverter.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Arction.RenderingDefinitions;
|
||||
using MathNet.Numerics;
|
||||
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.Wpf.Converts
|
||||
{
|
||||
/// <summary>
|
||||
/// 多值转换
|
||||
/// </summary>
|
||||
public class ValuePrecisionConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value[0] is double doubleValue)
|
||||
{
|
||||
return Math.Round(doubleValue, int.Parse(value[1].ToString())).ToString();
|
||||
//
|
||||
//if (int.TryParse(precision, out int decimalPlaces))
|
||||
//{
|
||||
// return doubleValue.ToString($"F{decimalPlaces}", culture);
|
||||
//}
|
||||
}
|
||||
|
||||
//return value.All(v => (v is bool && (bool)v))
|
||||
//? Visibility.Visible
|
||||
//: Visibility.Hidden;
|
||||
|
||||
//return Math.Round(value[0], value[1]);
|
||||
return value[0].ToString();
|
||||
//return value[0];
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user