feat: change hand length.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<ResourceDictionary
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:iri="https://irihi.tech/shared"
|
||||
xmlns:converter="clr-namespace:Ursa.Themes.Semi.Converters"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:Clock}" TargetType="u:Clock">
|
||||
@@ -18,8 +18,8 @@
|
||||
<UniformGrid Rows="2" IsVisible="{TemplateBinding ShowHourHand}">
|
||||
<Border
|
||||
Width="16"
|
||||
Margin="0,16,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Bounds.Width, Converter={x:Static converter:ClockHandLengthConverter.Hour}}"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="{TemplateBinding HandBrush}"
|
||||
CornerRadius="8" />
|
||||
<UniformGrid.RenderTransform>
|
||||
@@ -29,8 +29,8 @@
|
||||
<UniformGrid Rows="2" IsVisible="{TemplateBinding ShowMinuteHand}">
|
||||
<Border
|
||||
Width="8"
|
||||
Margin="0,8,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Bounds.Width, Converter={x:Static converter:ClockHandLengthConverter.Minute}}"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="{TemplateBinding HandBrush}"
|
||||
CornerRadius="4" />
|
||||
<UniformGrid.RenderTransform>
|
||||
@@ -40,8 +40,8 @@
|
||||
<UniformGrid Rows="2" IsVisible="{TemplateBinding ShowSecondHand}">
|
||||
<Border
|
||||
Width="4"
|
||||
Margin="0,4,0,0"
|
||||
VerticalAlignment="Stretch"
|
||||
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Bounds.Width, Converter={x:Static converter:ClockHandLengthConverter.Second}}"
|
||||
VerticalAlignment="Bottom"
|
||||
Background="{TemplateBinding HandBrush}"
|
||||
CornerRadius="4" />
|
||||
<UniformGrid.RenderTransform>
|
||||
|
||||
27
src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs
Normal file
27
src/Ursa.Themes.Semi/Converters/ClockHandLengthConverter.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user