diff --git a/StructureHelper/Documentation/Manuals/UserManual.docx b/StructureHelper/Documentation/Manuals/UserManual.docx
new file mode 100644
index 0000000..5da5d18
Binary files /dev/null and b/StructureHelper/Documentation/Manuals/UserManual.docx differ
diff --git a/StructureHelper/Infrastructure/Enums/MaterialType.cs b/StructureHelper/Infrastructure/Enums/MaterialType.cs
new file mode 100644
index 0000000..df36580
--- /dev/null
+++ b/StructureHelper/Infrastructure/Enums/MaterialType.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Infrastructure.Enums
+{
+ internal enum MaterialType
+ {
+ Concrete,
+ Reinforcement,
+ Elastic
+ }
+}
diff --git a/StructureHelper/Infrastructure/UI/Converters/Units/UnitConstatnts.cs b/StructureHelper/Infrastructure/UI/Converters/Units/UnitConstants.cs
similarity index 88%
rename from StructureHelper/Infrastructure/UI/Converters/Units/UnitConstatnts.cs
rename to StructureHelper/Infrastructure/UI/Converters/Units/UnitConstants.cs
index 26e085b..420de44 100644
--- a/StructureHelper/Infrastructure/UI/Converters/Units/UnitConstatnts.cs
+++ b/StructureHelper/Infrastructure/UI/Converters/Units/UnitConstants.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace StructureHelper.Infrastructure.UI.Converters.Units
{
- internal static class UnitConstatnts
+ internal static class UnitConstants
{
public static double Length = 1e3d;
public static double Force = 1e-3d;
diff --git a/StructureHelper/Infrastructure/UI/Resources/Materials.xaml b/StructureHelper/Infrastructure/UI/Resources/Materials.xaml
new file mode 100644
index 0000000..4789ac4
--- /dev/null
+++ b/StructureHelper/Infrastructure/UI/Resources/Materials.xaml
@@ -0,0 +1,107 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs b/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
index dd4a280..60b9db3 100644
--- a/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
+++ b/StructureHelper/Services/ResultViewers/ResultFuncFactory.cs
@@ -18,12 +18,12 @@ namespace StructureHelper.Services.ResultViewers
resultFuncs.Add(new ResultFunc() { Name = "Total Strain with prestrain", ResultFunction = stressLogic.GetTotalStrainWithPresrain });
resultFuncs.Add(new ResultFunc() { Name = "Elastic Strain", ResultFunction = stressLogic.GetElasticStrain });
resultFuncs.Add(new ResultFunc() { Name = "Plastic Strain", ResultFunction = stressLogic.GetPlasticStrain });
- resultFuncs.Add(new ResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = UnitConstatnts.Stress });
- resultFuncs.Add(new ResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = UnitConstatnts.Stress });
+ resultFuncs.Add(new ResultFunc() { Name = "Stress", ResultFunction = stressLogic.GetStress, UnitFactor = UnitConstants.Stress });
+ resultFuncs.Add(new ResultFunc() { Name = "Secant modulus", ResultFunction = stressLogic.GetSecantModulus, UnitFactor = UnitConstants.Stress });
resultFuncs.Add(new ResultFunc() { Name = "Modulus degradation", ResultFunction = stressLogic.GetModulusDegradation });
- resultFuncs.Add(new ResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = UnitConstatnts.Force });
- resultFuncs.Add(new ResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = UnitConstatnts.Force });
- resultFuncs.Add(new ResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = UnitConstatnts.Force });
+ resultFuncs.Add(new ResultFunc() { Name = "Force", ResultFunction = stressLogic.GetForce, UnitFactor = UnitConstants.Force });
+ resultFuncs.Add(new ResultFunc() { Name = "Moment X", ResultFunction = stressLogic.GetMomentX, UnitFactor = UnitConstants.Force });
+ resultFuncs.Add(new ResultFunc() { Name = "Moment Y", ResultFunction = stressLogic.GetMomentY, UnitFactor = UnitConstants.Force });
return resultFuncs;
}
}
diff --git a/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs b/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs
index 6b71193..0ac9c22 100644
--- a/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs
+++ b/StructureHelper/Services/ResultViewers/ShowAnchorageResult.cs
@@ -58,7 +58,7 @@ namespace StructureHelper.Services.ResultViewers
{
inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress);
}
- var val = inputData.ReinforcementStress * UnitConstatnts.Stress;
+ var val = inputData.ReinforcementStress * UnitConstants.Stress;
var valuePrimitive = GetValuePrimitive(primitive, val);
primitives.Add(valuePrimitive);
}
@@ -78,7 +78,7 @@ namespace StructureHelper.Services.ResultViewers
var primitive = item as ReinforcementPrimitive;
var inputData = InputDataFactory.GetInputData(primitive, strainMatrix, limitState, calcTerm, 1d);
var calculator = new AnchorageCalculator(inputData);
- var val = calculator.GetBaseDevLength() * UnitConstatnts.Length;
+ var val = calculator.GetBaseDevLength() * UnitConstants.Length;
var valuePrimitive = GetValuePrimitive(primitive, val);
primitives.Add(valuePrimitive);
}
@@ -101,7 +101,7 @@ namespace StructureHelper.Services.ResultViewers
inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress);
}
var calculator = new AnchorageCalculator(inputData);
- var val = calculator.GetDevLength() * UnitConstatnts.Length;
+ var val = calculator.GetDevLength() * UnitConstants.Length;
var valuePrimitive = GetValuePrimitive(primitive, val);
primitives.Add(valuePrimitive);
}
@@ -125,7 +125,7 @@ namespace StructureHelper.Services.ResultViewers
inputData.ReinforcementStress = inputData.ReinforcementStrength * Math.Sign(inputData.ReinforcementStress);
}
var calculator = new AnchorageCalculator(inputData);
- var val = calculator.GetLapLength() * UnitConstatnts.Length;
+ var val = calculator.GetLapLength() * UnitConstants.Length;
var valuePrimitive = GetValuePrimitive(primitive, val);
primitives.Add(valuePrimitive);
}
diff --git a/StructureHelper/StructureHelper.csproj b/StructureHelper/StructureHelper.csproj
index ae28479..2a86384 100644
--- a/StructureHelper/StructureHelper.csproj
+++ b/StructureHelper/StructureHelper.csproj
@@ -48,4 +48,8 @@
+
+
+
+
diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user
index a249422..afb63e6 100644
--- a/StructureHelper/StructureHelper.csproj.user
+++ b/StructureHelper/StructureHelper.csproj.user
@@ -18,6 +18,9 @@
Code
+
+ Code
+
Code
@@ -29,6 +32,9 @@
Designer
+
+ Designer
+
Designer
@@ -38,6 +44,9 @@
Designer
+
+ Designer
+
Designer
diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml
new file mode 100644
index 0000000..0892d01
--- /dev/null
+++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs
new file mode 100644
index 0000000..32f7811
--- /dev/null
+++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml.cs
@@ -0,0 +1,76 @@
+using StructureHelper.Models.Materials;
+using StructureHelper.Windows.ViewModels.Materials;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperLogics.Models.Materials;
+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.MainWindow.Materials
+{
+ ///
+ /// Логика взаимодействия для HeadMaterialView.xaml
+ ///
+ public partial class HeadMaterialView : Window
+ {
+ IHeadMaterial headMaterial;
+ HeadMaterialViewModel vm;
+
+ public HeadMaterialView(IHeadMaterial headMaterial)
+ {
+ InitializeComponent();
+ this.headMaterial = headMaterial;
+ vm = new HeadMaterialViewModel(this.headMaterial);
+ DataContext = vm;
+ AddDataTemplates();
+ }
+
+ private void AddDataTemplates()
+ {
+ StpMaterialProperties.Children.Clear();
+ var bindings = new Dictionary();
+ var helperMaterial = headMaterial.HelperMaterial;
+ string templateName;
+ var binding = new Binding();
+ if (helperMaterial is IConcreteLibMaterial)
+ {
+ templateName = "ConcreteMaterial";
+ binding.Source = vm.HelperMaterialViewModel;
+ }
+ else if (helperMaterial is IReinforcementLibMaterial)
+ {
+ templateName = "ReinforcementMaterial";
+ binding.Source = vm.HelperMaterialViewModel;
+ }
+ else if (helperMaterial is IElasticMaterial)
+ {
+ templateName = "ElasticMaterial";
+ binding.Source = vm.HelperMaterialViewModel;
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(IHelperMaterial)}, but was: {helperMaterial.GetType()}");
+ }
+
+ bindings.Add(templateName, binding);
+ foreach (var item in bindings)
+ {
+ ContentControl contentControl = new ContentControl();
+ contentControl.SetResourceReference(ContentTemplateProperty, item.Key);
+ contentControl.SetBinding(ContentProperty, item.Value);
+ StpMaterialProperties.Children.Add(contentControl);
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml
index 01450a3..ca0c51f 100644
--- a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml
+++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml
@@ -9,63 +9,7 @@
mc:Ignorable="d"
Title="Materials" Height="350" Width="680" MinHeight="350" MinWidth="680" WindowStartupLocation="CenterScreen">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -103,14 +47,14 @@
+
-
+
-
diff --git a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
index 46dc5cf..a00a383 100644
--- a/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Forces/ActionsViewModel.cs
@@ -22,7 +22,7 @@ namespace StructureHelper.Windows.ViewModels.Forces
{
if (parameter is not null)
{
- ActionType paramType = (ActionType)parameter;
+ var paramType = (ActionType)parameter;
if (paramType == ActionType.ForceCombination)
{
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
@@ -34,7 +34,6 @@ namespace StructureHelper.Windows.ViewModels.Forces
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
base.AddMethod(parameter);
}
-
}
public override void DeleteMethod(object parameter)
@@ -42,25 +41,13 @@ namespace StructureHelper.Windows.ViewModels.Forces
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
- var calcRepository = repository.CalculatorsList;
- foreach (var item in calcRepository)
- {
- if (item is IForceCalculator)
- {
- var forceCalculator = item as IForceCalculator;
- var containSelected = forceCalculator.ForceActions.Contains(SelectedItem);
- if (containSelected)
- {
- var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
- if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceActions.Remove(SelectedItem); }
- else return;
- }
- }
- }
+ DeleteAction();
base.DeleteMethod(parameter);
}
}
+
+
public override void EditMethod(object parameter)
{
System.Windows.Window wnd;
@@ -83,5 +70,24 @@ namespace StructureHelper.Windows.ViewModels.Forces
{
this.repository = repository;
}
+
+ private void DeleteAction()
+ {
+ var calcRepository = repository.CalculatorsList;
+ foreach (var item in calcRepository)
+ {
+ if (item is IForceCalculator)
+ {
+ var forceCalculator = item as IForceCalculator;
+ var containSelected = forceCalculator.ForceActions.Contains(SelectedItem);
+ if (containSelected)
+ {
+ var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
+ if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceActions.Remove(SelectedItem); }
+ else return;
+ }
+ }
+ }
+ }
}
}
diff --git a/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs
new file mode 100644
index 0000000..a8f0a6e
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/ConcreteViewModel.cs
@@ -0,0 +1,60 @@
+using LoaderCalculator.Data.Materials;
+using StructureHelper.Infrastructure;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperCommon.Models.Materials.Libraries;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal class ConcreteViewModel : LibMaterialViewModel
+ {
+ readonly IConcreteLibMaterial concreteMaterial;
+ public bool TensionForULS
+ {
+ get => concreteMaterial.TensionForULS;
+ set
+ {
+ concreteMaterial.TensionForULS = value;
+ OnPropertyChanged(nameof(TensionForULS));
+ }
+ }
+ public bool TensionForSLS
+ {
+ get => concreteMaterial.TensionForSLS;
+ set
+ {
+ concreteMaterial.TensionForSLS = value;
+ OnPropertyChanged(nameof(TensionForSLS));
+ }
+ }
+ public double Humidity
+ {
+ get => concreteMaterial.Humidity;
+ set
+ {
+ concreteMaterial.Humidity = value;
+ OnPropertyChanged(nameof(Humidity));
+ }
+ }
+
+ public override IEnumerable MaterialLibrary => LibMaterialPepository.GetConcreteRepository(ProgramSetting.CodeType);
+
+
+ public ConcreteViewModel(ILibMaterial material) : base(material)
+ {
+ if (material is not IConcreteLibMaterial)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $". Expected: {typeof(IConcreteLibMaterial)}, but was: {material.GetType()}");
+ }
+ this.concreteMaterial = material as IConcreteLibMaterial;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/ElasticViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/ElasticViewModel.cs
new file mode 100644
index 0000000..3aeb120
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/ElasticViewModel.cs
@@ -0,0 +1,48 @@
+using LoaderCalculator.Data.Materials;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal class ElasticViewModel : HelperMaterialViewModel
+ {
+ IElasticMaterial material;
+ public double Modulus
+ {
+ get => material.Modulus;
+ set
+ {
+ material.Modulus = value;
+ OnPropertyChanged(nameof(Modulus));
+ }
+ }
+ public double CompressiveStrength
+ {
+ get => material.CompressiveStrength;
+ set
+ {
+ material.CompressiveStrength = value;
+ OnPropertyChanged(nameof(CompressiveStrength));
+ }
+ }
+ public double TensileStrength
+ {
+ get => material.TensileStrength;
+ set
+ {
+ material.TensileStrength = value;
+ OnPropertyChanged(nameof(TensileStrength));
+ }
+ }
+
+ public ElasticViewModel(IElasticMaterial material)
+ {
+ this.material = material;
+ }
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs
new file mode 100644
index 0000000..4ee47aa
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialViewModel.cs
@@ -0,0 +1,94 @@
+using StructureHelper.Infrastructure;
+using StructureHelper.Models.Materials;
+using StructureHelper.Windows.AddMaterialWindow;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperCommon.Services.ColorServices;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal class HeadMaterialViewModel : ViewModelBase
+ {
+ IHeadMaterial headMaterial;
+ HelperMaterialViewModel helperMaterialViewModel;
+ private ICommand showSafetyFactors;
+ private ICommand editColorCommand;
+
+ public string Name
+ {
+ get => headMaterial.Name;
+ set
+ {
+ headMaterial.Name = value;
+ OnPropertyChanged(nameof(Name));
+ }
+ }
+
+ public Color Color
+ {
+ get => headMaterial.Color;
+ }
+
+ public HelperMaterialViewModel HelperMaterialViewModel => helperMaterialViewModel;
+
+ public ICommand ShowSafetyFactors
+ {
+ get
+ {
+ return showSafetyFactors ??= new RelayCommand(o =>
+ {
+ if (headMaterial is ILibMaterial)
+ {
+ var material = headMaterial as ILibMaterial;
+ var wnd = new SafetyFactorsView(material.SafetyFactors);
+ wnd.ShowDialog();
+ }
+ }, o => headMaterial is LibMaterial
+ );
+ }
+ }
+
+ public ICommand EditColorCommand => editColorCommand ??= new RelayCommand(o => EditColor());
+
+ private void EditColor()
+ {
+ Color color = headMaterial.Color;
+ ColorProcessor.EditColor(ref color);
+ headMaterial.Color = color;
+ OnPropertyChanged(nameof(Color));
+ }
+
+ public HeadMaterialViewModel(IHeadMaterial headMaterial)
+ {
+ this.headMaterial = headMaterial;
+ var helperMaterial = headMaterial.HelperMaterial;
+ if (helperMaterial is IConcreteLibMaterial)
+ {
+ var material = helperMaterial as IConcreteLibMaterial;
+ helperMaterialViewModel = new ConcreteViewModel(material);
+ }
+ else if (helperMaterial is IReinforcementLibMaterial)
+ {
+ var material = helperMaterial as IReinforcementLibMaterial;
+ helperMaterialViewModel = new ReinforcementViewModel(material);
+ }
+ else if (helperMaterial is IElasticMaterial)
+ {
+ var material = helperMaterial as IElasticMaterial;
+ helperMaterialViewModel = new ElasticViewModel(material);
+ }
+ else
+ {
+ throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(IHelperMaterial)}, but was: {helperMaterial.GetType()}");
+ }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/HeadMaterialsViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialsViewModel.cs
index 89e5a67..f333010 100644
--- a/StructureHelper/Windows/ViewModels/Materials/HeadMaterialsViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/HeadMaterialsViewModel.cs
@@ -54,19 +54,24 @@ namespace StructureHelper.Windows.ViewModels.Materials
}
public ICommand CopyHeadMaterialCommand { get; set; }
- public ICommand EditColorCommand { get; set; }
- public ICommand DeleteMaterialCommand { get; set; }
- public ICommand EditHeadMaterial;
+ public ICommand EditColorCommand => editColorCommand ??= new RelayCommand(o => EditColor(), o => SelectedMaterial is not null);
+ public ICommand EditCommand => editCommand ??= new RelayCommand(o => Edit(), o => SelectedMaterial is not null);
- private ICommand showSafetyfactors;
+ private void Edit()
+ {
+ var wnd = new HeadMaterialView(SelectedMaterial);
+ wnd.ShowDialog();
+ }
+
+ public ICommand DeleteMaterialCommand { get; set; }
+
+ private ICommand showSafetyFactors;
public ICommand ShowSafetyFactors
{
get
{
- return showSafetyfactors ??
- (
- showSafetyfactors = new RelayCommand(o =>
+ return showSafetyFactors ??= new RelayCommand(o =>
{
if (selectedMaterial.HelperMaterial is ILibMaterial)
{
@@ -76,7 +81,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(Items));
}
}, o=> SelectedLibMaterial != null
- ));
+ );
}
}
@@ -98,6 +103,8 @@ namespace StructureHelper.Windows.ViewModels.Materials
private ICommand? addElasticMaterialCommand;
private ICommand? showMaterialDiagram;
+ private ICommand? editColorCommand;
+ private ICommand editCommand;
public ObservableCollection HeadMaterials { get; private set; }
public IHeadMaterial SelectedMaterial
@@ -183,7 +190,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
AddNewConcreteMaterialCommand = new RelayCommand(o => AddConcreteMaterial());
AddNewReinforcementMaterialCommand = new RelayCommand(o => AddReinforcementMaterial());
CopyHeadMaterialCommand = new RelayCommand(o => CopyMaterial(), o => !(SelectedMaterial is null));
- EditColorCommand = new RelayCommand(o => EditColor(), o=> ! (SelectedMaterial is null));
DeleteMaterialCommand = new RelayCommand(o => DeleteMaterial(), o => !(SelectedMaterial is null));
}
diff --git a/StructureHelper/Windows/ViewModels/Materials/HelperMaterialViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/HelperMaterialViewModel.cs
new file mode 100644
index 0000000..1270346
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/HelperMaterialViewModel.cs
@@ -0,0 +1,14 @@
+using StructureHelper.Infrastructure;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal abstract class HelperMaterialViewModel : ViewModelBase
+ {
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/LibMaterialViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/LibMaterialViewModel.cs
new file mode 100644
index 0000000..0e32623
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/LibMaterialViewModel.cs
@@ -0,0 +1,50 @@
+using LoaderCalculator.Data.Materials;
+using StructureHelper.Infrastructure;
+using StructureHelper.Windows.AddMaterialWindow;
+using StructureHelperCommon.Infrastructures.Enums;
+using StructureHelperCommon.Models.Materials.Libraries;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal abstract class LibMaterialViewModel : HelperMaterialViewModel
+ {
+ ILibMaterial material;
+ ICommand showSafetyFactors;
+ SafetyFactorsViewModel safetyFactorsViewModel;
+
+ public ILibMaterialEntity MaterialEntity
+ {
+ get => material.MaterialEntity;
+ set
+ {
+ material.MaterialEntity = value;
+ OnPropertyChanged(nameof(MaterialEntity));
+ }
+ }
+ public abstract IEnumerable MaterialLibrary { get; }
+ public SafetyFactorsViewModel SafetyFactors => safetyFactorsViewModel;
+
+ public ICommand ShowSafetyFactors =>
+ showSafetyFactors ??= new RelayCommand(o =>
+ {
+ var wnd = new SafetyFactorsView(material.SafetyFactors);
+ wnd.ShowDialog();
+ safetyFactorsViewModel = new SafetyFactorsViewModel(material.SafetyFactors);
+ OnPropertyChanged(nameof(SafetyFactors));
+ });
+
+
+ public LibMaterialViewModel(ILibMaterial material)
+ {
+ this.material = material;
+ safetyFactorsViewModel = new SafetyFactorsViewModel(material.SafetyFactors);
+ }
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/MaterialDiagramViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/MaterialDiagramViewModel.cs
index a188bec..3e875ff 100644
--- a/StructureHelper/Windows/ViewModels/Materials/MaterialDiagramViewModel.cs
+++ b/StructureHelper/Windows/ViewModels/Materials/MaterialDiagramViewModel.cs
@@ -1,14 +1,18 @@
using LiveCharts;
using LiveCharts.Wpf;
+using StructureHelper.Infrastructure.UI.Converters.Units;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
+using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
using System.Windows.Media;
+using Brushes = System.Windows.Media.Brushes;
namespace StructureHelper.Windows.ViewModels.Materials
{
@@ -56,7 +60,9 @@ namespace StructureHelper.Windows.ViewModels.Materials
var title = titles[n];
for (double s = minValue; s < maxValue; s += step)
{
- double diagramValue = loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters,s);
+ double diagramValue = Math.Round(loaderMaterial.Diagram.Invoke(loaderMaterial.DiagramParameters,s)) * UnitConstants.Stress;
+ //var point = new PointF() { X = (float)s, Y = (float)diagramValue };
+ //chartValues.Add(point);
chartValues.Add(diagramValue);
labels.Add(Convert.ToString(Math.Round(s,4)));
}
diff --git a/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs
new file mode 100644
index 0000000..d1eb9bd
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/MaterialsViewModel.cs
@@ -0,0 +1,66 @@
+using StructureHelper.Infrastructure.Enums;
+using StructureHelper.Models.Materials;
+using StructureHelper.Windows.MainWindow.Materials;
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperCommon.Models.Forces;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal class MaterialsViewModel : CRUDViewModelBase
+ {
+ public override void AddMethod(object parameter)
+ {
+ CheckParameters(parameter);
+ var paramType = (MaterialType)parameter;
+ if (paramType == MaterialType.Concrete) { AddConcrete(); }
+ else if (paramType == MaterialType.Reinforcement) { AddReinforcement(); }
+ else if (paramType == MaterialType.Elastic) { AddElastic(); }
+ else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(paramType)}");
+ base.AddMethod(parameter);
+ }
+ public override void DeleteMethod(object parameter)
+ {
+#error
+ //to do delete method
+ base.DeleteMethod(parameter);
+ }
+ public override void EditMethod(object parameter)
+ {
+ var wnd = new HeadMaterialView(SelectedItem);
+ wnd.ShowDialog();
+ base.EditMethod(parameter);
+ }
+
+ private void AddElastic()
+ {
+ var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Elastic200, ProgramSetting.CodeType);
+ material.Name = "New Elastic Material";
+ NewItem = material;
+ }
+ private void AddReinforcement()
+ {
+ var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforecement400, ProgramSetting.CodeType);
+ material.Name = "New Reinforcement";
+ NewItem = material;
+ }
+ private void AddConcrete()
+ {
+ var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, ProgramSetting.CodeType);
+ material.Name = "New Concrete";
+ NewItem = material;
+ }
+ private void CheckParameters(object parameter)
+ {
+ if (parameter is null) { throw new StructureHelperException(ErrorStrings.ParameterIsNull); }
+ if (parameter is not MaterialType) { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)} . Actual type: {nameof(parameter)}"); }
+ }
+ }
+}
diff --git a/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs b/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs
new file mode 100644
index 0000000..aab2336
--- /dev/null
+++ b/StructureHelper/Windows/ViewModels/Materials/ReinforcementViewModel.cs
@@ -0,0 +1,25 @@
+using StructureHelperCommon.Infrastructures.Exceptions;
+using StructureHelperCommon.Infrastructures.Settings;
+using StructureHelperCommon.Infrastructures.Strings;
+using StructureHelperCommon.Models.Materials.Libraries;
+using StructureHelperLogics.Models.Materials;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StructureHelper.Windows.ViewModels.Materials
+{
+ internal class ReinforcementViewModel : LibMaterialViewModel
+ {
+ public override IEnumerable MaterialLibrary => LibMaterialPepository.GetReinforcementRepository(ProgramSetting.CodeType);
+ public ReinforcementViewModel(ILibMaterial material) : base(material)
+ {
+ if (material is not IReinforcementLibMaterial)
+ {
+ throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $". Expected: {typeof(IConcreteLibMaterial)}, but was: {material.GetType()}");
+ }
+ }
+ }
+}
diff --git a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs b/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
index 7ccbc75..fa1299b 100644
--- a/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
+++ b/StructureHelperCommon/Infrastructures/Strings/ErrorString.cs
@@ -17,5 +17,6 @@
public static string LongitudinalForceMustBeLessThanZero => "#0012: Longitudinal force must be less than zero";
public static string LongitudinalForceMustBeLessThanCriticalForce => "#0013: Absolute value of longitudinal force must be greater than critical force";
public static string SizeMustBeGreaterThanZero => "#0014: Size must be greater than zero";
+ public static string ParameterIsNull => "#0015: Parameter is null";
}
}
diff --git a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
index 922fcf6..079f292 100644
--- a/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/ConcreteLibMaterial.cs
@@ -20,6 +20,7 @@ namespace StructureHelperLogics.Models.Materials
public List SafetyFactors { get; }
public bool TensionForULS { get ; set; }
public bool TensionForSLS { get; set; }
+ public double Humidity { get; set; }
private IMaterialOptionLogic optionLogic;
private LoaderMaterialLogic.ITrueStrengthLogic strengthLogic;
@@ -31,6 +32,7 @@ namespace StructureHelperLogics.Models.Materials
optionLogic = new MaterialOptionLogic(new LoaderMaterialBuilders.ConcreteOptions());
TensionForULS = false;
TensionForSLS = true;
+ Humidity = 0.55d;
}
public object Clone()
diff --git a/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs b/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
index 0cac2da..94b7c77 100644
--- a/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
+++ b/StructureHelperLogics/Models/Materials/IConcreteLibMaterial.cs
@@ -11,5 +11,6 @@ namespace StructureHelperLogics.Models.Materials
{
bool TensionForULS { get; set; }
bool TensionForSLS { get; set; }
+ double Humidity { get; set; }
}
}