feat: re-org files.

This commit is contained in:
rabbitism
2024-02-17 15:56:37 +08:00
parent 40454bcfe0
commit a4c214cfc2
2 changed files with 73 additions and 73 deletions

View File

@@ -0,0 +1,73 @@
using Avalonia.Animation;
namespace Ursa.Controls;
public class Int32Displayer : NumberDisplayer<int>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<int> GetAnimator()
{
return new IntAnimator();
}
private class IntAnimator : InterpolatingAnimator<int>
{
public override int Interpolate(double progress, int oldValue, int newValue)
{
return oldValue + (int)((newValue - oldValue) * progress);
}
}
protected override string GetString(int value)
{
return value.ToString(StringFormat);
}
}
public class DoubleDisplayer : NumberDisplayer<double>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<double> GetAnimator()
{
return new DoubleAnimator();
}
private class DoubleAnimator : InterpolatingAnimator<double>
{
public override double Interpolate(double progress, double oldValue, double newValue)
{
return oldValue + (newValue - oldValue) * progress;
}
}
protected override string GetString(double value)
{
return value.ToString(StringFormat);
}
}
public class DateDisplay : NumberDisplayer<DateTime>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<DateTime> GetAnimator()
{
return new DateAnimator();
}
private class DateAnimator : InterpolatingAnimator<DateTime>
{
public override DateTime Interpolate(double progress, DateTime oldValue, DateTime newValue)
{
var diff = (newValue - oldValue).TotalSeconds;
return oldValue + TimeSpan.FromSeconds(diff * progress);
}
}
protected override string GetString(DateTime value)
{
return value.ToString(StringFormat);
}
}

View File

@@ -1,10 +1,7 @@
using Avalonia;
using Avalonia.Animation;
using Avalonia.Controls;
using Avalonia.Controls.Documents;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Media;
using Avalonia.Styling;
namespace Ursa.Controls;
@@ -125,73 +122,3 @@ public abstract class NumberDisplayer<T>: NumberDisplayerBase
protected abstract string GetString(T? value);
}
public class Int32Displayer : NumberDisplayer<int>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<int> GetAnimator()
{
return new IntAnimator();
}
private class IntAnimator : InterpolatingAnimator<int>
{
public override int Interpolate(double progress, int oldValue, int newValue)
{
return oldValue + (int)((newValue - oldValue) * progress);
}
}
protected override string GetString(int value)
{
return value.ToString(StringFormat);
}
}
public class DoubleDisplayer : NumberDisplayer<double>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<double> GetAnimator()
{
return new DoubleAnimator();
}
private class DoubleAnimator : InterpolatingAnimator<double>
{
public override double Interpolate(double progress, double oldValue, double newValue)
{
return oldValue + (newValue - oldValue) * progress;
}
}
protected override string GetString(double value)
{
return value.ToString(StringFormat);
}
}
public class DateDisplay : NumberDisplayer<DateTime>
{
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
protected override InterpolatingAnimator<DateTime> GetAnimator()
{
return new DateAnimator();
}
private class DateAnimator : InterpolatingAnimator<DateTime>
{
public override DateTime Interpolate(double progress, DateTime oldValue, DateTime newValue)
{
var diff = (newValue - oldValue).TotalSeconds;
return oldValue + TimeSpan.FromSeconds(diff * progress);
}
}
protected override string GetString(DateTime value)
{
return value.ToString(StringFormat);
}
}