feat: add clock template.
This commit is contained in:
@@ -9,12 +9,6 @@
|
|||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Grid>
|
<Grid>
|
||||||
<u:ClockTicks
|
<u:Clock HorizontalAlignment="Left"></u:Clock>
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HourTickWidth="4"
|
|
||||||
MinuteTickWidth="1"
|
|
||||||
HourTickForeground="Black"
|
|
||||||
MinuteTickForeground="Red" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
21
src/Ursa.Themes.Semi/Controls/Clock.axaml
Normal file
21
src/Ursa.Themes.Semi/Controls/Clock.axaml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:iri="https://irihi.tech/shared"
|
||||||
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
<ControlTheme x:Key="{x:Type u:Clock}" TargetType="u:Clock">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:Clock">
|
||||||
|
<Grid>
|
||||||
|
<u:ClockTicks HorizontalAlignment="{TemplateBinding HorizontalAlignment}" HourTickForeground="{DynamicResource SemiGrey6}" MinuteTickForeground="{DynamicResource SemiGrey4}" />
|
||||||
|
<Rectangle Width="8" Height="100" Fill="White" />
|
||||||
|
<Rectangle Width="4" />
|
||||||
|
<iri:PureCircle
|
||||||
|
Diameter="16"
|
||||||
|
Background="Red" />
|
||||||
|
</Grid>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
<ResourceInclude Source="ButtonGroup.axaml" />
|
<ResourceInclude Source="ButtonGroup.axaml" />
|
||||||
<ResourceInclude Source="Breadcrumb.axaml" />
|
<ResourceInclude Source="Breadcrumb.axaml" />
|
||||||
<ResourceInclude Source="ControlClassesInput.axaml" />
|
<ResourceInclude Source="ControlClassesInput.axaml" />
|
||||||
|
<ResourceInclude Source="Clock.axaml" />
|
||||||
<ResourceInclude Source="Dialog.axaml" />
|
<ResourceInclude Source="Dialog.axaml" />
|
||||||
<ResourceInclude Source="DialogShared.axaml" />
|
<ResourceInclude Source="DialogShared.axaml" />
|
||||||
<ResourceInclude Source="DisableContainer.axaml" />
|
<ResourceInclude Source="DisableContainer.axaml" />
|
||||||
|
|||||||
@@ -36,4 +36,37 @@ public class Clock: TemplatedControl
|
|||||||
set => SetValue(ShowMinuteTicksProperty, value);
|
set => SetValue(ShowMinuteTicksProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<double> HourHandMarginProperty = AvaloniaProperty.Register<Clock, double>(
|
||||||
|
nameof(HourHandMargin));
|
||||||
|
|
||||||
|
public double HourHandMargin
|
||||||
|
{
|
||||||
|
get => GetValue(HourHandMarginProperty);
|
||||||
|
set => SetValue(HourHandMarginProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<double> MinuteHandMarginProperty = AvaloniaProperty.Register<Clock, double>(
|
||||||
|
nameof(MinuteHandMargin));
|
||||||
|
|
||||||
|
public double MinuteHandMargin
|
||||||
|
{
|
||||||
|
get => GetValue(MinuteHandMarginProperty);
|
||||||
|
set => SetValue(MinuteHandMarginProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Size MeasureOverride(Size availableSize)
|
||||||
|
{
|
||||||
|
double min = Math.Min(availableSize.Height, availableSize.Width);
|
||||||
|
var newSize = new Size(min, min);
|
||||||
|
var size = base.MeasureOverride(newSize);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Size ArrangeOverride(Size finalSize)
|
||||||
|
{
|
||||||
|
double min = Math.Min(finalSize.Height, finalSize.Width);
|
||||||
|
var newSize = new Size(min, min);
|
||||||
|
var size = base.ArrangeOverride(newSize);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,18 @@ public class ClockTicks: Control
|
|||||||
AffectsRender<ClockTicks>(ShowHourTicksProperty);
|
AffectsRender<ClockTicks>(ShowHourTicksProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override Size MeasureOverride(Size availableSize)
|
||||||
|
{
|
||||||
|
double minSize= Math.Min(availableSize.Width, availableSize.Height);
|
||||||
|
return new Size(minSize, minSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override Size ArrangeOverride(Size finalSize)
|
||||||
|
{
|
||||||
|
var minSize = Math.Min(finalSize.Width, finalSize.Height);
|
||||||
|
return new Size(minSize, minSize);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
{
|
{
|
||||||
base.Render(context);
|
base.Render(context);
|
||||||
|
|||||||
Reference in New Issue
Block a user