Converter error was fixed
This commit is contained in:
@@ -33,7 +33,7 @@ namespace StructureHelper.Infrastructure.UI.Converters
|
||||
public static IStringDoublePair DivideIntoStringDoublePair(string s)
|
||||
{
|
||||
s = s.Replace(" ", "");
|
||||
string digitPattern = @"\d+(\.?|\,?)\d+";
|
||||
string digitPattern = @"\d+(\.?|\,?)\d*";
|
||||
string textPattern = @"[0-9]|\.|\,";
|
||||
string caracterPattern = "[a-z]+$";
|
||||
string target = "";
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Area : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Area; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "mm2"); }
|
||||
public override string unitName { get => "Area"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Area; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
|
||||
public override string UnitName { get => "Area"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Curvature : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Curvature; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "1/mm"); }
|
||||
public override string unitName { get => "Curvature"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
|
||||
public override string UnitName { get => "Curvature"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Force : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Force; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "kN"); }
|
||||
public override string unitName { get => "Force"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Force; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
|
||||
public override string UnitName { get => "Force"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Length : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Length; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "mm"); }
|
||||
public override string unitName { get => "Length"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Length; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
|
||||
public override string UnitName { get => "Length"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Moment : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Moment; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "kNm"); }
|
||||
public override string unitName { get => "Moment"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Moment; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
|
||||
public override string UnitName { get => "Moment"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Stress : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Stress; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "MPa"); }
|
||||
public override string unitName { get => "Stress"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Stress; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
|
||||
public override string UnitName { get => "Stress"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,33 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal abstract class UnitBase : IValueConverter
|
||||
{
|
||||
public abstract UnitTypes unitType { get; }
|
||||
public abstract IUnit currentUnit { get; }
|
||||
public abstract string unitName { get;}
|
||||
public abstract UnitTypes UnitType { get; }
|
||||
public abstract IUnit CurrentUnit { get; }
|
||||
public abstract string UnitName { get;}
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return CommonOperation.Convert(currentUnit, unitName, value);
|
||||
return CommonOperation.Convert(CurrentUnit, UnitName, value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return CommonOperation.ConvertBack(unitType, currentUnit, value);
|
||||
try
|
||||
{
|
||||
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Value of {UnitName}={(string)value} is not correct", "Error of conversion", MessageBoxButtons.OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
set
|
||||
{
|
||||
primitive.Area = value;
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
RefreshPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +42,15 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
|
||||
private void RefreshPlacement()
|
||||
{
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user