Unit constants was added
This commit is contained in:
39
Infrastructure/UI/Converters/Units/Stress.cs
Normal file
39
Infrastructure/UI/Converters/Units/Stress.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Stress : UnitBase
|
||||
{
|
||||
private double coeffficient = UnitConstatnts.Stress;
|
||||
|
||||
public override string unitName { get => "Stress"; }
|
||||
|
||||
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double val;
|
||||
if (value != null) { val = (double)value; }
|
||||
else { throw new Exception($"{unitName} value is null"); }
|
||||
val *= coeffficient;
|
||||
return val;
|
||||
}
|
||||
|
||||
public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double val;
|
||||
if (value != null)
|
||||
{
|
||||
var strVal = value as string;
|
||||
double.TryParse(strVal, out val);
|
||||
}
|
||||
else { throw new Exception($"{unitName} value is null"); }
|
||||
val /= coeffficient;
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user