Add Int64Displayer control for long type support (#811)
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
<StackPanel HorizontalAlignment="Left">
|
<StackPanel HorizontalAlignment="Left">
|
||||||
<Button Command="{Binding IncreaseCommand}">Change</Button>
|
<Button Command="{Binding IncreaseCommand}">Change</Button>
|
||||||
<u:Int32Displayer Value="{Binding Value}" />
|
<u:Int32Displayer Value="{Binding Value}" />
|
||||||
|
<u:Int64Displayer Value="{Binding LongValue}" />
|
||||||
<u:DoubleDisplayer StringFormat="N2" Value="{Binding DoubleValue}" />
|
<u:DoubleDisplayer StringFormat="N2" Value="{Binding DoubleValue}" />
|
||||||
<u:DateDisplay
|
<u:DateDisplay
|
||||||
FontSize="30"
|
FontSize="30"
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
Value="{Binding DateValue}" />
|
Value="{Binding DateValue}" />
|
||||||
<TextBlock Text="Selectable: "></TextBlock>
|
<TextBlock Text="Selectable: "></TextBlock>
|
||||||
<u:Int32Displayer Value="{Binding Value}" IsSelectable="True" />
|
<u:Int32Displayer Value="{Binding Value}" IsSelectable="True" />
|
||||||
|
<u:Int64Displayer Value="{Binding LongValue}" IsSelectable="True" />
|
||||||
<u:DoubleDisplayer StringFormat="N2" Value="{Binding DoubleValue}" IsSelectable="True" />
|
<u:DoubleDisplayer StringFormat="N2" Value="{Binding DoubleValue}" IsSelectable="True" />
|
||||||
<u:DateDisplay
|
<u:DateDisplay
|
||||||
FontSize="30"
|
FontSize="30"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Ursa.Demo.ViewModels;
|
|||||||
public partial class NumberDisplayerDemoViewModel: ObservableObject
|
public partial class NumberDisplayerDemoViewModel: ObservableObject
|
||||||
{
|
{
|
||||||
[ObservableProperty] private int _value;
|
[ObservableProperty] private int _value;
|
||||||
|
[ObservableProperty] private long _longValue;
|
||||||
[ObservableProperty] private double _doubleValue;
|
[ObservableProperty] private double _doubleValue;
|
||||||
[ObservableProperty] private DateTime _dateValue;
|
[ObservableProperty] private DateTime _dateValue;
|
||||||
public ICommand IncreaseCommand { get; }
|
public ICommand IncreaseCommand { get; }
|
||||||
@@ -15,6 +16,7 @@ public partial class NumberDisplayerDemoViewModel: ObservableObject
|
|||||||
{
|
{
|
||||||
IncreaseCommand = new RelayCommand(OnChange);
|
IncreaseCommand = new RelayCommand(OnChange);
|
||||||
Value = 0;
|
Value = 0;
|
||||||
|
LongValue = 0L;
|
||||||
DoubleValue = 0d;
|
DoubleValue = 0d;
|
||||||
DateValue = DateTime.Now;
|
DateValue = DateTime.Now;
|
||||||
}
|
}
|
||||||
@@ -23,6 +25,7 @@ public partial class NumberDisplayerDemoViewModel: ObservableObject
|
|||||||
{
|
{
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
Value = r.Next(int.MaxValue);
|
Value = r.Next(int.MaxValue);
|
||||||
|
LongValue = ((long)r.Next(int.MaxValue)) * 1000 + r.Next(1000);
|
||||||
DoubleValue = r.NextDouble() * 100000;
|
DoubleValue = r.NextDouble() * 100000;
|
||||||
DateValue = DateTime.Today.AddDays(r.Next(1000));
|
DateValue = DateTime.Today.AddDays(r.Next(1000));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,29 @@ public class Int32Displayer : NumberDisplayer<int>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class Int64Displayer : NumberDisplayer<long>
|
||||||
|
{
|
||||||
|
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
|
||||||
|
|
||||||
|
protected override InterpolatingAnimator<long> GetAnimator()
|
||||||
|
{
|
||||||
|
return new LongAnimator();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class LongAnimator : InterpolatingAnimator<long>
|
||||||
|
{
|
||||||
|
public override long Interpolate(double progress, long oldValue, long newValue)
|
||||||
|
{
|
||||||
|
return oldValue + (long)((newValue - oldValue) * progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetString(long value)
|
||||||
|
{
|
||||||
|
return value.ToString(StringFormat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class DoubleDisplayer : NumberDisplayer<double>
|
public class DoubleDisplayer : NumberDisplayer<double>
|
||||||
{
|
{
|
||||||
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
|
protected override Type StyleKeyOverride { get; } = typeof(NumberDisplayerBase);
|
||||||
|
|||||||
Reference in New Issue
Block a user