diff --git a/src/Ursa.Themes.Semi/Controls/Clock.axaml b/src/Ursa.Themes.Semi/Controls/Clock.axaml index 14b554a..58809b8 100644 --- a/src/Ursa.Themes.Semi/Controls/Clock.axaml +++ b/src/Ursa.Themes.Semi/Controls/Clock.axaml @@ -1,7 +1,7 @@  @@ -18,8 +18,8 @@ @@ -29,8 +29,8 @@ @@ -40,8 +40,8 @@ diff --git a/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs b/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs new file mode 100644 index 0000000..6715eef --- /dev/null +++ b/src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs @@ -0,0 +1,27 @@ +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); + + private double _ratio = ratio; + + 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(); + } +} \ No newline at end of file