diff --git a/src/Ursa.Themes.Semi/Controls/NumberDisplayer.axaml b/src/Ursa.Themes.Semi/Controls/NumberDisplayer.axaml index 1a62aec..7b34b4b 100644 --- a/src/Ursa.Themes.Semi/Controls/NumberDisplayer.axaml +++ b/src/Ursa.Themes.Semi/Controls/NumberDisplayer.axaml @@ -14,7 +14,7 @@ FontFamily="{TemplateBinding FontFamily}" Background="{TemplateBinding Background}" FontWeight="{TemplateBinding FontWeight}" - FontStyle="{TemplateBinding FontSize}" + FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" Text="{TemplateBinding InternalText, Mode=OneWay}" /> @@ -28,7 +28,7 @@ FontFamily="{TemplateBinding FontFamily}" Background="{TemplateBinding Background}" FontWeight="{TemplateBinding FontWeight}" - FontStyle="{TemplateBinding FontSize}" + FontStyle="{TemplateBinding FontStyle}" FontStretch="{TemplateBinding FontStretch}" Text="{TemplateBinding InternalText, Mode=OneWay}" /> diff --git a/src/Ursa/AssemblyInfo.cs b/src/Ursa/AssemblyInfo.cs index af243bf..5fb4320 100644 --- a/src/Ursa/AssemblyInfo.cs +++ b/src/Ursa/AssemblyInfo.cs @@ -3,3 +3,4 @@ using Avalonia.Metadata; [assembly:XmlnsPrefix("https://irihi.tech/ursa", "u")] [assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa")] [assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls")] +[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls.Shapes")] \ No newline at end of file diff --git a/src/Ursa/Controls/NumberDisplayer/Implementations.cs b/src/Ursa/Controls/NumberDisplayer/Implementations.cs index a43fa0a..f895dfe 100644 --- a/src/Ursa/Controls/NumberDisplayer/Implementations.cs +++ b/src/Ursa/Controls/NumberDisplayer/Implementations.cs @@ -62,7 +62,15 @@ public class DateDisplay : NumberDisplayer public override DateTime Interpolate(double progress, DateTime oldValue, DateTime newValue) { var diff = (newValue - oldValue).TotalSeconds; - return oldValue + TimeSpan.FromSeconds(diff * progress); + try + { + return oldValue + TimeSpan.FromSeconds(diff * progress); + } + catch + { + return oldValue; + } + } } diff --git a/src/Ursa/Controls/Shapes/PureCircle.cs b/src/Ursa/Controls/Shapes/PureCircle.cs new file mode 100644 index 0000000..b964f63 --- /dev/null +++ b/src/Ursa/Controls/Shapes/PureCircle.cs @@ -0,0 +1,45 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Controls.Primitives; +using Avalonia.Media; + +namespace Ursa.Controls.Shapes; + +public class PureCircle: Control +{ + public static readonly StyledProperty BackgroundProperty = + TemplatedControl.BackgroundProperty.AddOwner(); + + public IBrush? Background + { + get => GetValue(BackgroundProperty); + set => SetValue(BackgroundProperty, value); + } + + public static readonly StyledProperty DiameterProperty = AvaloniaProperty.Register( + nameof(Diameter)); + + public double Diameter + { + get => GetValue(DiameterProperty); + set => SetValue(DiameterProperty, value); + } + + static PureCircle() + { + FocusableProperty.OverrideDefaultValue(false); + AffectsMeasure(DiameterProperty); + AffectsRender(DiameterProperty, BackgroundProperty); + } + + protected override Size MeasureOverride(Size availableSize) + { + return new Size(Diameter, Diameter); + } + + public override void Render(DrawingContext context) + { + double value = Diameter / 2; + context.DrawEllipse(Background, null, new(value, value), value, value); + } +} \ No newline at end of file diff --git a/src/Ursa/Controls/Shapes/PureRectangle.cs b/src/Ursa/Controls/Shapes/PureRectangle.cs index 1dbdc33..e4eb0dc 100644 --- a/src/Ursa/Controls/Shapes/PureRectangle.cs +++ b/src/Ursa/Controls/Shapes/PureRectangle.cs @@ -1,6 +1,8 @@ using Avalonia; using Avalonia.Controls; +using Avalonia.Controls.Primitives; using Avalonia.Controls.Shapes; +using Avalonia.Markup.Xaml.Templates; using Avalonia.Media; namespace Ursa.Controls.Shapes; @@ -10,8 +12,8 @@ namespace Ursa.Controls.Shapes; /// public class PureRectangle: Control { - public static readonly StyledProperty BackgroundProperty = AvaloniaProperty.Register( - nameof(Background)); + public static readonly StyledProperty BackgroundProperty = + TemplatedControl.BackgroundProperty.AddOwner(); public IBrush? Background { @@ -21,6 +23,7 @@ public class PureRectangle: Control static PureRectangle() { FocusableProperty.OverrideDefaultValue(false); + AffectsRender(BackgroundProperty); } public override void Render(DrawingContext context)