46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|