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