Force combination was added

This commit is contained in:
Evgeny Redikultsev
2022-11-27 17:04:34 +05:00
parent c5e503252e
commit 96b331f14c
52 changed files with 427 additions and 214 deletions

View File

@@ -1,4 +1,6 @@
using System;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -10,35 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
{
internal class Force : UnitBase
{
private double coeffficient = UnitConstatnts.Force;
public override UnitTypes unitType { get => UnitTypes.Force; }
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "kN"); }
public override string unitName { get => "Force"; }
public override string MeasureUnit => throw new NotImplementedException();
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;
try
{
var strVal = value as string;
val = CommonOperation.ConvertToDoubleChangeComma(strVal);
}
catch
{
return null;
}
val /= coeffficient;
return val;
}
}
}