From e820f3522d30282f15df38f0c908a7d16f351374 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 27 Nov 2022 20:46:15 +0500 Subject: [PATCH] Converter error was fixed --- .../UI/Converters/CommonOperation.cs | 2 +- Infrastructure/UI/Converters/Units/Area.cs | 6 +- .../UI/Converters/Units/Curvature.cs | 6 +- Infrastructure/UI/Converters/Units/Force.cs | 6 +- Infrastructure/UI/Converters/Units/Length.cs | 6 +- Infrastructure/UI/Converters/Units/Moment.cs | 6 +- Infrastructure/UI/Converters/Units/Stress.cs | 6 +- .../UI/Converters/Units/UnitBase.cs | 21 +++++-- .../UI/DataContexts/PointViewPrimitive.cs | 17 ++++-- Models/Forces/ForceTupleViewObject.cs | 59 +++++++++++++++++++ StructureHelper.csproj | 16 +++++ .../CalculationPropertyView.xaml | 6 +- Windows/Forces/ForceCombinationView.xaml | 40 +++++++++++++ Windows/Forces/ForceCombinationView.xaml.cs | 27 +++++++++ Windows/Forces/ForceTupleControl.xaml | 26 ++++++++ Windows/Forces/ForceTupleControl.xaml.cs | 28 +++++++++ .../RCs/RectangleBeam/RectangleBeamView.xaml | 10 ++-- 17 files changed, 250 insertions(+), 38 deletions(-) create mode 100644 Models/Forces/ForceTupleViewObject.cs create mode 100644 Windows/Forces/ForceCombinationView.xaml create mode 100644 Windows/Forces/ForceCombinationView.xaml.cs create mode 100644 Windows/Forces/ForceTupleControl.xaml create mode 100644 Windows/Forces/ForceTupleControl.xaml.cs diff --git a/Infrastructure/UI/Converters/CommonOperation.cs b/Infrastructure/UI/Converters/CommonOperation.cs index 332d745..fe7c8a0 100644 --- a/Infrastructure/UI/Converters/CommonOperation.cs +++ b/Infrastructure/UI/Converters/CommonOperation.cs @@ -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 = ""; diff --git a/Infrastructure/UI/Converters/Units/Area.cs b/Infrastructure/UI/Converters/Units/Area.cs index 35b5d02..383fb7f 100644 --- a/Infrastructure/UI/Converters/Units/Area.cs +++ b/Infrastructure/UI/Converters/Units/Area.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/Curvature.cs b/Infrastructure/UI/Converters/Units/Curvature.cs index 45176dd..ec5a34b 100644 --- a/Infrastructure/UI/Converters/Units/Curvature.cs +++ b/Infrastructure/UI/Converters/Units/Curvature.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/Force.cs b/Infrastructure/UI/Converters/Units/Force.cs index 0cd5645..408660d 100644 --- a/Infrastructure/UI/Converters/Units/Force.cs +++ b/Infrastructure/UI/Converters/Units/Force.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/Length.cs b/Infrastructure/UI/Converters/Units/Length.cs index a9d56bf..e991a30 100644 --- a/Infrastructure/UI/Converters/Units/Length.cs +++ b/Infrastructure/UI/Converters/Units/Length.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/Moment.cs b/Infrastructure/UI/Converters/Units/Moment.cs index 360d1ba..76f8d6d 100644 --- a/Infrastructure/UI/Converters/Units/Moment.cs +++ b/Infrastructure/UI/Converters/Units/Moment.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/Stress.cs b/Infrastructure/UI/Converters/Units/Stress.cs index 254c936..eec20ab 100644 --- a/Infrastructure/UI/Converters/Units/Stress.cs +++ b/Infrastructure/UI/Converters/Units/Stress.cs @@ -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"; } } } diff --git a/Infrastructure/UI/Converters/Units/UnitBase.cs b/Infrastructure/UI/Converters/Units/UnitBase.cs index f63219d..ef778b0 100644 --- a/Infrastructure/UI/Converters/Units/UnitBase.cs +++ b/Infrastructure/UI/Converters/Units/UnitBase.cs @@ -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; + } + } } } diff --git a/Infrastructure/UI/DataContexts/PointViewPrimitive.cs b/Infrastructure/UI/DataContexts/PointViewPrimitive.cs index 5231aec..cff5884 100644 --- a/Infrastructure/UI/DataContexts/PointViewPrimitive.cs +++ b/Infrastructure/UI/DataContexts/PointViewPrimitive.cs @@ -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)); + } } } diff --git a/Models/Forces/ForceTupleViewObject.cs b/Models/Forces/ForceTupleViewObject.cs new file mode 100644 index 0000000..bebab6b --- /dev/null +++ b/Models/Forces/ForceTupleViewObject.cs @@ -0,0 +1,59 @@ +using StructureHelperCommon.Models.Forces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Models.Forces +{ + internal class ForceTupleViewObject + { + IForceTuple forceTuple; + + private double mx; + + public double Mx + { + get { return mx; } + set { mx = value; } + } + private double my; + + public double My + { + get { return my; } + set { my = value; } + } + private double nz; + + public double Nz + { + get { return nz; } + set { nz = value; } + } + private double qx; + + public double Qx + { + get { return qx; } + set { qx = value; } + } + private double qy; + + public double Qy + { + get { return qy; } + set { qy = value; } + } + private double mz; + + public double Mz + { + get { return mz; } + set { mz = value; } + } + + + } +} diff --git a/StructureHelper.csproj b/StructureHelper.csproj index ea2414f..5655bec 100644 --- a/StructureHelper.csproj +++ b/StructureHelper.csproj @@ -153,6 +153,7 @@ PrimitivePopup.xaml + @@ -201,6 +202,12 @@ EllipseTemplate.xaml + + ForceCombinationView.xaml + + + ForceTupleControl.xaml + @@ -286,6 +293,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -336,5 +351,6 @@ false + \ No newline at end of file diff --git a/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml index cb73f6c..b967b94 100644 --- a/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml +++ b/Windows/CalculationWindows/CalculationPropertyWindow/CalculationPropertyView.xaml @@ -39,9 +39,9 @@ SelectedItem="{Binding Path=SelectedCombination}"> - - - + + + diff --git a/Windows/Forces/ForceCombinationView.xaml b/Windows/Forces/ForceCombinationView.xaml new file mode 100644 index 0000000..a3e63c7 --- /dev/null +++ b/Windows/Forces/ForceCombinationView.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Windows/Forces/ForceCombinationView.xaml.cs b/Windows/Forces/ForceCombinationView.xaml.cs new file mode 100644 index 0000000..1dc4a80 --- /dev/null +++ b/Windows/Forces/ForceCombinationView.xaml.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.Forces +{ + /// + /// Логика взаимодействия для ForceCombinationView.xaml + /// + public partial class ForceCombinationView : Window + { + public ForceCombinationView() + { + InitializeComponent(); + } + } +} diff --git a/Windows/Forces/ForceTupleControl.xaml b/Windows/Forces/ForceTupleControl.xaml new file mode 100644 index 0000000..6166d4d --- /dev/null +++ b/Windows/Forces/ForceTupleControl.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Windows/Forces/ForceTupleControl.xaml.cs b/Windows/Forces/ForceTupleControl.xaml.cs new file mode 100644 index 0000000..446b197 --- /dev/null +++ b/Windows/Forces/ForceTupleControl.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.Forces +{ + /// + /// Логика взаимодействия для ForceTupleControl.xaml + /// + public partial class ForceTupleControl : UserControl + { + public ForceTupleControl() + { + InitializeComponent(); + } + } +} diff --git a/Windows/PrimitiveTemplates/RCs/RectangleBeam/RectangleBeamView.xaml b/Windows/PrimitiveTemplates/RCs/RectangleBeam/RectangleBeamView.xaml index ea787f9..1a68ce0 100644 --- a/Windows/PrimitiveTemplates/RCs/RectangleBeam/RectangleBeamView.xaml +++ b/Windows/PrimitiveTemplates/RCs/RectangleBeam/RectangleBeamView.xaml @@ -35,11 +35,11 @@ - - - - - + + + + +