Files
CRSim/CRSim.ScreenSimulator/Converters/LocationToStringConverter.cs
2025-03-16 12:19:30 +08:00

36 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Globalization;
using System.Windows.Data;
namespace CRSim.ScreenSimulator.Converters
{
public class LocationToStringConverter : IMultiValueConverter
{
object IMultiValueConverter.Convert(object[] values, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (values[0] is int Length&& values[1] is int Location)
{
if (Location > Length)
{
return $"当前无车1-{Length}车向后。";
}
if (Location == Length)
{
return $"当前{Length}车1-{Length-1}车向后。";
}
if (Location == 1)
{
return $"当前1车2-{Length}车向前。";
}
return $"当前{Location}车1-{Location - 1}车向前,{Location + 1}-{Length}车向后。";
}
return string.Empty;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
// 通常不需要实现 ConvertBack
return null;
}
}
}