Fix Modifier ValueStr
This commit is contained in:
@ -9,6 +9,7 @@ using System.IO.Ports;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using Elwig.Dialogs;
|
using Elwig.Dialogs;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Numerics;
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public static partial class Utils {
|
public static partial class Utils {
|
||||||
@ -234,5 +235,12 @@ namespace Elwig.Helpers {
|
|||||||
return Text;
|
return Text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetSign<T>(T number) where T : INumber<T>
|
||||||
|
=> T.Sign(number) switch {
|
||||||
|
< 0 => "\u2212", // minus
|
||||||
|
0 => "\u00b1", // plus minus
|
||||||
|
> 0 => "+",
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
@ -43,8 +44,9 @@ namespace Elwig.Models {
|
|||||||
public virtual Season Season { get; private set; }
|
public virtual Season Season { get; private set; }
|
||||||
|
|
||||||
public string ValueStr =>
|
public string ValueStr =>
|
||||||
(Abs != null) ? $"{(Abs.Value < 0 ? "\u00a0-" : "+")}{Math.Abs(Abs.Value)}\u00a0{Season.Currency.Symbol}/kg" :
|
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value)}\u00a0{Season.Currency.Symbol}/kg" :
|
||||||
(Rel != null) ? $"{(Math.Abs(Rel.Value) < 0.1 ? "\u2007" : "")}{(Rel.Value < 0 ? "\u00a0-" : "+")}{Math.Abs(Rel.Value):0.00##\u00a0%}" : "";
|
(Rel != null) ? $"{Utils.GetSign(Rel.Value)}{Math.Abs(Rel.Value):0.00##\u00a0%}" :
|
||||||
|
"";
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return Name;
|
return Name;
|
||||||
|
Reference in New Issue
Block a user