82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace TabletTester2025.Helpers
|
|
{
|
|
public class BasketOffsetConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool isUp = (bool)value;
|
|
double maxOffset = System.Convert.ToDouble(parameter);
|
|
return isUp ? 0 : maxOffset;
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
public class PassToTextConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool isPass = (bool)value;
|
|
return isPass ? "合格" : "不合格";
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
public class BoolToColorConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool flag = (bool)value;
|
|
return flag ? "Green" : "Red";
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
public class StatusColorConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
string status = value as string;
|
|
return status switch
|
|
{
|
|
"已连接" => "Green",
|
|
"连接中" => "Orange",
|
|
_ => "Red"
|
|
};
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
public class BoolToTextConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool isClockwise = (bool)value;
|
|
return isClockwise ? "顺时针" : "逆时针";
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
// 用于将 bool 方向转换为 "顺时针"/"逆时针"
|
|
public class BoolToDirectionConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
bool isClockwise = (bool)value;
|
|
return isClockwise ? "顺时针" : "逆时针";
|
|
}
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
=> throw new NotImplementedException();
|
|
}
|
|
|
|
|
|
}
|