feat: several fixes.
This commit is contained in:
@@ -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}" />
|
||||
</ControlTemplate>
|
||||
@@ -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}" />
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -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")]
|
||||
@@ -62,7 +62,15 @@ public class DateDisplay : NumberDisplayer<DateTime>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
45
src/Ursa/Controls/Shapes/PureCircle.cs
Normal file
45
src/Ursa/Controls/Shapes/PureCircle.cs
Normal file
@@ -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<IBrush?> BackgroundProperty =
|
||||
TemplatedControl.BackgroundProperty.AddOwner<PureCircle>();
|
||||
|
||||
public IBrush? Background
|
||||
{
|
||||
get => GetValue(BackgroundProperty);
|
||||
set => SetValue(BackgroundProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<double> DiameterProperty = AvaloniaProperty.Register<PureCircle, double>(
|
||||
nameof(Diameter));
|
||||
|
||||
public double Diameter
|
||||
{
|
||||
get => GetValue(DiameterProperty);
|
||||
set => SetValue(DiameterProperty, value);
|
||||
}
|
||||
|
||||
static PureCircle()
|
||||
{
|
||||
FocusableProperty.OverrideDefaultValue<PureCircle>(false);
|
||||
AffectsMeasure<PureCircle>(DiameterProperty);
|
||||
AffectsRender<PureCircle>(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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
/// </summary>
|
||||
public class PureRectangle: Control
|
||||
{
|
||||
public static readonly StyledProperty<IBrush?> BackgroundProperty = AvaloniaProperty.Register<PureRectangle, IBrush?>(
|
||||
nameof(Background));
|
||||
public static readonly StyledProperty<IBrush?> BackgroundProperty =
|
||||
TemplatedControl.BackgroundProperty.AddOwner<PureRectangle>();
|
||||
|
||||
public IBrush? Background
|
||||
{
|
||||
@@ -21,6 +23,7 @@ public class PureRectangle: Control
|
||||
static PureRectangle()
|
||||
{
|
||||
FocusableProperty.OverrideDefaultValue<PureRectangle>(false);
|
||||
AffectsRender<PureRectangle>(BackgroundProperty);
|
||||
}
|
||||
|
||||
public override void Render(DrawingContext context)
|
||||
|
||||
Reference in New Issue
Block a user