feat: several fixes.
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
FontFamily="{TemplateBinding FontFamily}"
|
FontFamily="{TemplateBinding FontFamily}"
|
||||||
Background="{TemplateBinding Background}"
|
Background="{TemplateBinding Background}"
|
||||||
FontWeight="{TemplateBinding FontWeight}"
|
FontWeight="{TemplateBinding FontWeight}"
|
||||||
FontStyle="{TemplateBinding FontSize}"
|
FontStyle="{TemplateBinding FontStyle}"
|
||||||
FontStretch="{TemplateBinding FontStretch}"
|
FontStretch="{TemplateBinding FontStretch}"
|
||||||
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
FontFamily="{TemplateBinding FontFamily}"
|
FontFamily="{TemplateBinding FontFamily}"
|
||||||
Background="{TemplateBinding Background}"
|
Background="{TemplateBinding Background}"
|
||||||
FontWeight="{TemplateBinding FontWeight}"
|
FontWeight="{TemplateBinding FontWeight}"
|
||||||
FontStyle="{TemplateBinding FontSize}"
|
FontStyle="{TemplateBinding FontStyle}"
|
||||||
FontStretch="{TemplateBinding FontStretch}"
|
FontStretch="{TemplateBinding FontStretch}"
|
||||||
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ using Avalonia.Metadata;
|
|||||||
[assembly:XmlnsPrefix("https://irihi.tech/ursa", "u")]
|
[assembly:XmlnsPrefix("https://irihi.tech/ursa", "u")]
|
||||||
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa")]
|
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa")]
|
||||||
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls")]
|
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls")]
|
||||||
|
[assembly:XmlnsDefinition("https://irihi.tech/ursa", "Ursa.Controls.Shapes")]
|
||||||
@@ -62,8 +62,16 @@ public class DateDisplay : NumberDisplayer<DateTime>
|
|||||||
public override DateTime Interpolate(double progress, DateTime oldValue, DateTime newValue)
|
public override DateTime Interpolate(double progress, DateTime oldValue, DateTime newValue)
|
||||||
{
|
{
|
||||||
var diff = (newValue - oldValue).TotalSeconds;
|
var diff = (newValue - oldValue).TotalSeconds;
|
||||||
|
try
|
||||||
|
{
|
||||||
return oldValue + TimeSpan.FromSeconds(diff * progress);
|
return oldValue + TimeSpan.FromSeconds(diff * progress);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetString(DateTime value)
|
protected override string GetString(DateTime value)
|
||||||
|
|||||||
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;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Controls.Shapes;
|
using Avalonia.Controls.Shapes;
|
||||||
|
using Avalonia.Markup.Xaml.Templates;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace Ursa.Controls.Shapes;
|
namespace Ursa.Controls.Shapes;
|
||||||
@@ -10,8 +12,8 @@ namespace Ursa.Controls.Shapes;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class PureRectangle: Control
|
public class PureRectangle: Control
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<IBrush?> BackgroundProperty = AvaloniaProperty.Register<PureRectangle, IBrush?>(
|
public static readonly StyledProperty<IBrush?> BackgroundProperty =
|
||||||
nameof(Background));
|
TemplatedControl.BackgroundProperty.AddOwner<PureRectangle>();
|
||||||
|
|
||||||
public IBrush? Background
|
public IBrush? Background
|
||||||
{
|
{
|
||||||
@@ -21,6 +23,7 @@ public class PureRectangle: Control
|
|||||||
static PureRectangle()
|
static PureRectangle()
|
||||||
{
|
{
|
||||||
FocusableProperty.OverrideDefaultValue<PureRectangle>(false);
|
FocusableProperty.OverrideDefaultValue<PureRectangle>(false);
|
||||||
|
AffectsRender<PureRectangle>(BackgroundProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
|
|||||||
Reference in New Issue
Block a user