Files
Ursa.Avalonia/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs
2024-07-30 18:33:30 +08:00

25 lines
769 B
C#

using System.Globalization;
using Avalonia.Data.Converters;
namespace Ursa.Themes.Semi.Converters;
public class ClockHandLengthConverter(double ratio) : IValueConverter
{
public static ClockHandLengthConverter Hour { get; } = new(1-0.618);
public static ClockHandLengthConverter Minute { get; } = new(0.618);
public static ClockHandLengthConverter Second { get; } = new(1);
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is double d)
{
return d * ratio / 2;
}
return 0.0;
}
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}