diff --git a/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOConvertStrategy.cs index 02d29f4..19fc5f2 100644 --- a/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOConvertStrategy.cs @@ -9,33 +9,20 @@ namespace DataAccess.DTOs public class HelperMaterialFromDTOConvertStrategy : ConvertStrategy { const string MaterialIs = "Material type is: "; - private IConvertStrategy concreteConvertStrategy; - private IConvertStrategy reinforcementConvertStrategy; - private IConvertStrategy elasticConvertStrategy; - private IConvertStrategy frConvertStrategy; - private IUpdateStrategy safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic()); + private IHelperMaterialFromDTOStrategyContainer strategyContainer; - public HelperMaterialFromDTOConvertStrategy() : this( - new ConcreteLibMaterialFromDTOConvertStrategy(), - new ReinforcementLibMaterialFromDTOConvertStrategy(), - new ElasticMaterialFromDTOConvertStrategy(), - new FRMaterialFromDTOConvertStrategy() - ) + + private IHelperMaterialFromDTOStrategyContainer StrategyContainer => strategyContainer ??= new HelperMaterialFromDTOStrategyContainer(); + public HelperMaterialFromDTOConvertStrategy(IHelperMaterialFromDTOStrategyContainer strategyContainer) + { + this.strategyContainer = strategyContainer; + } + + public HelperMaterialFromDTOConvertStrategy() { } - public HelperMaterialFromDTOConvertStrategy( - IConvertStrategy concreteConvertStrategy, - IConvertStrategy reinforcementConvertStrategy, - IConvertStrategy elasticConvertStrategy, - IConvertStrategy frConvertStrategy) - { - this.concreteConvertStrategy = concreteConvertStrategy; - this.reinforcementConvertStrategy = reinforcementConvertStrategy; - this.elasticConvertStrategy = elasticConvertStrategy; - this.frConvertStrategy = frConvertStrategy; - } public override IHelperMaterial GetNewItem(IHelperMaterial source) { @@ -55,6 +42,10 @@ namespace DataAccess.DTOs { return GetElasticMaterial(elastic); } + else if (source is SteelLibMaterialDTO steel) + { + return GetSteelMaterial(steel); + } else { string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source) + ": helper material type"; @@ -63,43 +54,58 @@ namespace DataAccess.DTOs } } + private IHelperMaterial GetSteelMaterial(SteelLibMaterialDTO source) + { + var strategy = StrategyContainer.SteelConvertStrategy; + TraceLogger?.AddMessage(MaterialIs + "Elastic material", TraceLogStatuses.Service); + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var newItem = strategy.Convert(source); + strategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source); + return newItem; + } + private IHelperMaterial GetElasticMaterial(ElasticMaterialDTO source) { + var strategy = StrategyContainer.ElasticConvertStrategy; TraceLogger?.AddMessage(MaterialIs + "Elastic material", TraceLogStatuses.Service); - elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary; - elasticConvertStrategy.TraceLogger = TraceLogger; - var newItem = elasticConvertStrategy.Convert(source); - safetyFactorUpdateStrategy.Update(newItem, source); + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var newItem = strategy.Convert(source); + strategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source); return newItem; } private IHelperMaterial GetFRMaterial(FRMaterialDTO source) { + var strategy = StrategyContainer.FrConvertStrategy; TraceLogger?.AddMessage(MaterialIs + "Fiber reinforcement material", TraceLogStatuses.Service); - frConvertStrategy.ReferenceDictionary = ReferenceDictionary; - frConvertStrategy.TraceLogger = TraceLogger; - var newItem = frConvertStrategy.Convert(source); - safetyFactorUpdateStrategy.Update(newItem, source); + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var newItem = strategy.Convert(source); + StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source); return newItem; } private IHelperMaterial GetReinforcementMaterial(ReinforcementLibMaterialDTO source) { + var strategy = StrategyContainer.ReinforcementConvertStrategy; TraceLogger?.AddMessage(MaterialIs + "Reinforcement library material", TraceLogStatuses.Service); - reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary; - reinforcementConvertStrategy.TraceLogger = TraceLogger; - var newItem = reinforcementConvertStrategy.Convert(source); - safetyFactorUpdateStrategy.Update(newItem, source); + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var newItem = strategy.Convert(source); + StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source); return newItem; } private IHelperMaterial GetConcreteMaterial(ConcreteLibMaterialDTO source) { + var strategy = StrategyContainer.ConcreteConvertStrategy; TraceLogger?.AddMessage(MaterialIs + "Concrete library material", TraceLogStatuses.Service); - concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary; - concreteConvertStrategy.TraceLogger = TraceLogger; - var newItem = concreteConvertStrategy.Convert(source); - safetyFactorUpdateStrategy.Update(newItem, source); + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var newItem = strategy.Convert(source); + StrategyContainer.SafetyFactorUpdateStrategy.Update(newItem, source); return newItem; } } diff --git a/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOStrategyContainer.cs b/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOStrategyContainer.cs new file mode 100644 index 0000000..a62716d --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/HelperMaterialFromDTOStrategyContainer.cs @@ -0,0 +1,22 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class HelperMaterialFromDTOStrategyContainer : IHelperMaterialFromDTOStrategyContainer + { + private IConvertStrategy concreteConvertStrategy; + private IConvertStrategy reinforcementConvertStrategy; + private IConvertStrategy elasticConvertStrategy; + private IConvertStrategy frConvertStrategy; + private IUpdateStrategy safetyFactorUpdateStrategy; + private IConvertStrategy steelConvertStrategy; + public IConvertStrategy ConcreteConvertStrategy => concreteConvertStrategy ??= new ConcreteLibMaterialFromDTOConvertStrategy(); + public IConvertStrategy ElasticConvertStrategy => elasticConvertStrategy ??= new ElasticMaterialFromDTOConvertStrategy(); + public IConvertStrategy FrConvertStrategy => frConvertStrategy ??= new FRMaterialFromDTOConvertStrategy(); + public IConvertStrategy ReinforcementConvertStrategy => reinforcementConvertStrategy ??= new ReinforcementLibMaterialFromDTOConvertStrategy(); + public IUpdateStrategy SafetyFactorUpdateStrategy => safetyFactorUpdateStrategy ??= new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorsFromDTOLogic()); + public IConvertStrategy SteelConvertStrategy => steelConvertStrategy ??= new SteelLibMaterialFromDTOConvertStrategy(); + } +} diff --git a/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOConvertStrategy.cs index dbc7014..927df23 100644 --- a/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOConvertStrategy.cs @@ -7,35 +7,20 @@ using StructureHelperLogics.Models.Materials; namespace DataAccess.DTOs { - internal class HelperMaterialToDTOConvertStrategy : IConvertStrategy + public class HelperMaterialToDTOConvertStrategy : IConvertStrategy { - private LibMaterialToDTOConvertStrategy concreteConvertStrategy; - private LibMaterialToDTOConvertStrategy reinforcementConvertStrategy; - private IConvertStrategy elasticConvertStrategy; - private IConvertStrategy frMaterialConvertStrategy; - private IUpdateStrategy safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic()); + private IHelperMaterialToDTOStrategyContainer strategyContainer; + private IHelperMaterialToDTOStrategyContainer StrategyContainer => strategyContainer ??= new HelperMaterialToDTOStrategyContainer(); public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } - public HelperMaterialToDTOConvertStrategy( - LibMaterialToDTOConvertStrategy concreteConvertStrategy, - LibMaterialToDTOConvertStrategy reinforcementConvertStrategy, - IConvertStrategy elasticConvertStrategy, - IConvertStrategy frMaterialConvertStrategy) + public HelperMaterialToDTOConvertStrategy(IHelperMaterialToDTOStrategyContainer strategyContainer) { - this.concreteConvertStrategy = concreteConvertStrategy; - this.reinforcementConvertStrategy = reinforcementConvertStrategy; - this.elasticConvertStrategy = elasticConvertStrategy; - this.frMaterialConvertStrategy = frMaterialConvertStrategy; + this.strategyContainer = strategyContainer; } - public HelperMaterialToDTOConvertStrategy() : this ( - new ConcreteLibMaterialToDTOConvertStrategy(), - new ReinforcementLibMaterialToDTOConvertStrategy(), - new ElasticMaterialToDTOConvertStrategy(), - new FRMaterialToDTOConvertStrategy() - ) + public HelperMaterialToDTOConvertStrategy() { } @@ -46,7 +31,7 @@ namespace DataAccess.DTOs try { IHelperMaterial helperMaterial = GetMaterial(source); - safetyFactorUpdateStrategy.Update(helperMaterial, source); + StrategyContainer.SafetyFactorUpdateStrategy.Update(helperMaterial, source); return helperMaterial; } catch (Exception ex) @@ -75,14 +60,28 @@ namespace DataAccess.DTOs { return ProcessElastic(elasticMaterial); } + else if (source is ISteelLibMaterial steelLibMaterial) + { + return ProcessSteel(steelLibMaterial); + } else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source)); } } + private IHelperMaterial ProcessSteel(ISteelLibMaterial steelLibMaterial) + { + var strategy = StrategyContainer.SteelConvertStrategy; + strategy.ReferenceDictionary = ReferenceDictionary; + strategy.TraceLogger = TraceLogger; + var convertLogic = new DictionaryConvertStrategy(this, strategy); + return convertLogic.Convert(steelLibMaterial); + } + private IHelperMaterial ProcessFRMaterial(IFRMaterial frMaterial) { + var frMaterialConvertStrategy = StrategyContainer.FrMaterialConvertStrategy; frMaterialConvertStrategy.ReferenceDictionary = ReferenceDictionary; frMaterialConvertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy(this, frMaterialConvertStrategy); @@ -91,6 +90,7 @@ namespace DataAccess.DTOs private IHelperMaterial ProcessElastic(IElasticMaterial elasticMaterial) { + var elasticConvertStrategy = StrategyContainer.ElasticConvertStrategy; elasticConvertStrategy.ReferenceDictionary = ReferenceDictionary; elasticConvertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy(this, elasticConvertStrategy); @@ -99,6 +99,7 @@ namespace DataAccess.DTOs private IHelperMaterial ProcessReinforcement(IReinforcementLibMaterial reinforcementMaterial) { + var reinforcementConvertStrategy = StrategyContainer.ReinforcementConvertStrategy; reinforcementConvertStrategy.ReferenceDictionary = ReferenceDictionary; reinforcementConvertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy(this, reinforcementConvertStrategy); @@ -107,6 +108,7 @@ namespace DataAccess.DTOs private IHelperMaterial ProcessConcrete(IConcreteLibMaterial concreteLibMaterial) { + var concreteConvertStrategy = StrategyContainer.ConcreteConvertStrategy; concreteConvertStrategy.ReferenceDictionary = ReferenceDictionary; concreteConvertStrategy.TraceLogger = TraceLogger; var convertLogic = new DictionaryConvertStrategy(this, concreteConvertStrategy); diff --git a/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOStrategyContainer.cs b/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOStrategyContainer.cs new file mode 100644 index 0000000..b9650df --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/HelperMaterialToDTOStrategyContainer.cs @@ -0,0 +1,22 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class HelperMaterialToDTOStrategyContainer : IHelperMaterialToDTOStrategyContainer + { + private LibMaterialToDTOConvertStrategy concreteConvertStrategy; + private LibMaterialToDTOConvertStrategy reinforcementConvertStrategy; + private LibMaterialToDTOConvertStrategy steelConvertStrategy; + private IConvertStrategy elasticConvertStrategy; + private IConvertStrategy frMaterialConvertStrategy; + private IUpdateStrategy safetyFactorUpdateStrategy = new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic()); + public LibMaterialToDTOConvertStrategy ConcreteConvertStrategy => concreteConvertStrategy ??= new ConcreteLibMaterialToDTOConvertStrategy(); + public IConvertStrategy ElasticConvertStrategy => elasticConvertStrategy ??= new ElasticMaterialToDTOConvertStrategy(); + public IConvertStrategy FrMaterialConvertStrategy => frMaterialConvertStrategy ??= new FRMaterialToDTOConvertStrategy(); + public LibMaterialToDTOConvertStrategy ReinforcementConvertStrategy => reinforcementConvertStrategy ??= new ReinforcementLibMaterialToDTOConvertStrategy(); + public IUpdateStrategy SafetyFactorUpdateStrategy => safetyFactorUpdateStrategy ??= new HelperMaterialDTOSafetyFactorUpdateStrategy(new MaterialSafetyFactorToDTOLogic()); + public LibMaterialToDTOConvertStrategy SteelConvertStrategy => steelConvertStrategy ??= new SteelLibMaterialToDTOConvertStrategy(); + } +} diff --git a/DataAccess/DTOs/Converters/Materials/IHelperMaterialFromDTOStrategyContainer.cs b/DataAccess/DTOs/Converters/Materials/IHelperMaterialFromDTOStrategyContainer.cs new file mode 100644 index 0000000..fbdcfc5 --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/IHelperMaterialFromDTOStrategyContainer.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public interface IHelperMaterialFromDTOStrategyContainer + { + IConvertStrategy ConcreteConvertStrategy { get; } + IConvertStrategy ElasticConvertStrategy { get; } + IConvertStrategy FrConvertStrategy { get; } + IConvertStrategy ReinforcementConvertStrategy { get; } + IUpdateStrategy SafetyFactorUpdateStrategy { get; } + IConvertStrategy SteelConvertStrategy { get; } + } +} \ No newline at end of file diff --git a/DataAccess/DTOs/Converters/Materials/IHelperMaterialToDTOStrategyContainer.cs b/DataAccess/DTOs/Converters/Materials/IHelperMaterialToDTOStrategyContainer.cs new file mode 100644 index 0000000..3c89577 --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/IHelperMaterialToDTOStrategyContainer.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Materials; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public interface IHelperMaterialToDTOStrategyContainer + { + LibMaterialToDTOConvertStrategy ConcreteConvertStrategy { get; } + IConvertStrategy ElasticConvertStrategy { get; } + IConvertStrategy FrMaterialConvertStrategy { get; } + LibMaterialToDTOConvertStrategy ReinforcementConvertStrategy { get; } + IUpdateStrategy SafetyFactorUpdateStrategy { get; } + LibMaterialToDTOConvertStrategy SteelConvertStrategy { get; } + } +} \ No newline at end of file diff --git a/DataAccess/DTOs/Converters/Materials/ReinforcementLibMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Materials/ReinforcementLibMaterialToDTOConvertStrategy.cs index f92fcc3..34234db 100644 --- a/DataAccess/DTOs/Converters/Materials/ReinforcementLibMaterialToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/Materials/ReinforcementLibMaterialToDTOConvertStrategy.cs @@ -14,10 +14,7 @@ namespace DataAccess.DTOs public override ReinforcementLibMaterialDTO GetMaterialDTO(IReinforcementLibMaterial source) { - ReinforcementLibMaterialDTO newItem = new() - { - Id = source.Id - }; + ReinforcementLibMaterialDTO newItem = new(source.Id); return newItem; } } diff --git a/DataAccess/DTOs/Converters/Materials/SteelLibMaterialFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Materials/SteelLibMaterialFromDTOConvertStrategy.cs new file mode 100644 index 0000000..adb3103 --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/SteelLibMaterialFromDTOConvertStrategy.cs @@ -0,0 +1,18 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class SteelLibMaterialFromDTOConvertStrategy : ConvertStrategy + { + IUpdateStrategy updateStrategy; + IUpdateStrategy UpdateStrategy => updateStrategy ??= new SteelLibMaterialUpdateStrategy(); + public override SteelLibMaterial GetNewItem(SteelLibMaterialDTO source) + { + ChildClass = this; + NewItem = new(source.Id); + UpdateStrategy.Update(NewItem, source); + return NewItem; + } + } +} diff --git a/DataAccess/DTOs/Converters/Materials/SteelLibMaterialToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/Materials/SteelLibMaterialToDTOConvertStrategy.cs new file mode 100644 index 0000000..b90b62d --- /dev/null +++ b/DataAccess/DTOs/Converters/Materials/SteelLibMaterialToDTOConvertStrategy.cs @@ -0,0 +1,17 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class SteelLibMaterialToDTOConvertStrategy : LibMaterialToDTOConvertStrategy + { + private IUpdateStrategy updateStrategy; + public override IUpdateStrategy UpdateStrategy => updateStrategy ??= new SteelLibMaterialUpdateStrategy(); + + public override SteelLibMaterialDTO GetMaterialDTO(ISteelLibMaterial source) + { + SteelLibMaterialDTO material = new(source.Id); + return material; + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/Materials/ReinforcementLibMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/Materials/ReinforcementLibMaterialDTO.cs index c3a4043..eb7fdbe 100644 --- a/DataAccess/DTOs/DTOEntities/Materials/ReinforcementLibMaterialDTO.cs +++ b/DataAccess/DTOs/DTOEntities/Materials/ReinforcementLibMaterialDTO.cs @@ -5,11 +5,6 @@ using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Models.Materials; 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 DataAccess.DTOs { @@ -17,7 +12,9 @@ namespace DataAccess.DTOs { const MaterialTypes materialType = MaterialTypes.Reinforcement; [JsonProperty("Id")] - public Guid Id { get; set; } + public Guid Id { get; } + + [JsonProperty("MaterialEntityId")] public Guid MaterialEntityId { @@ -46,6 +43,10 @@ namespace DataAccess.DTOs [JsonIgnore] public List MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); + public ReinforcementLibMaterialDTO(Guid id) + { + Id = id; + } public object Clone() { diff --git a/DataAccess/DTOs/DTOEntities/Materials/SteelLibMaterialDTO.cs b/DataAccess/DTOs/DTOEntities/Materials/SteelLibMaterialDTO.cs new file mode 100644 index 0000000..e407760 --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/Materials/SteelLibMaterialDTO.cs @@ -0,0 +1,81 @@ +using LoaderCalculator.Data.Materials; +using Newtonsoft.Json; +using StructureHelperCommon.Infrastructures.Enums; +using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models.Materials; +using StructureHelperCommon.Models.Materials.Libraries; +using StructureHelperLogics.Models.Materials; + +namespace DataAccess.DTOs +{ + public class SteelLibMaterialDTO : ISteelLibMaterial + { + const MaterialTypes materialType = MaterialTypes.Steel; + [JsonProperty("Id")] + public Guid Id { get; } + [JsonProperty("UlsFactor")] + public double UlsFactor { get; set; } = 1.025; + [JsonProperty("SlsFactor")] + public double SlsFactor { get; set; } = 1.0; + [JsonProperty("WorkConditionFactor")] + public double WorkConditionFactor { get; set; } = 1.0; + [JsonProperty("ThicknessFactor")] + public double ThicknessFactor { get; set; } = 1.0; + [JsonProperty("MaxPlasticStrainRatio")] + public double MaxPlasticStrainRatio { get; set; } = 3.0; + [JsonIgnore] + public ILibMaterialEntity MaterialEntity { get; set; } + [JsonProperty("SafetyFactors")] + public List SafetyFactors { get; set; } = []; + [JsonProperty("MaterialEntityId")] + public Guid MaterialEntityId + { + get => MaterialEntity.Id; + set + { + MaterialEntity = ProgramSetting.MaterialRepository.Repository.Single(x => x.Id == value); + } + } + [JsonProperty("MaterialLogicId")] + public Guid MaterialLogicId + { + get => MaterialLogic.Id; + set + { + MaterialLogic = MaterialLogics.Single(x => x.Id == value); + } + } + [JsonIgnore] + public IMaterialLogic MaterialLogic { get; set; } + + [JsonIgnore] + public List MaterialLogics { get; } = ProgramSetting.MaterialLogics.Where(x => x.MaterialType == materialType).ToList(); + + + + public SteelLibMaterialDTO(Guid id) + { + Id = id; + } + + public object Clone() + { + throw new NotImplementedException(); + } + + public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + + public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + + public (double Compressive, double Tensile) GetStrength(LimitStates limitState, CalcTerms calcTerm) + { + throw new NotImplementedException(); + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs index a53cdd3..108080a 100644 --- a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs @@ -117,6 +117,7 @@ namespace DataAccess.DTOs { (typeof(List), "ListOfMaterialSafetyFactor") }, { (typeof(MaterialPartialFactorDTO), "MaterialPartialFactor") }, { (typeof(ReinforcementLibMaterialDTO), "ReinforcementLibMaterial") }, + { (typeof(SteelLibMaterialDTO), "SteelLibMaterial") }, }; return newList; } diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index 1b010c9..4f332b9 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -99,14 +99,12 @@ - - + - + - @@ -116,9 +114,7 @@ - + @@ -163,7 +159,7 @@ - + @@ -174,7 +170,7 @@ - + @@ -184,16 +180,18 @@ - - + + + - + + @@ -204,15 +202,7 @@ - - - - - - - - - + @@ -224,22 +214,7 @@ - - - - - - - - - + @@ -267,19 +242,7 @@ - - - - - - - - - - - - - + @@ -297,17 +260,7 @@ - - - - - - - - - - - + @@ -777,6 +730,7 @@ + @@ -911,16 +865,7 @@ - - - - - - - - - - + diff --git a/StructureHelper/Infrastructure/UI/Resources/CalculatorButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/CalculatorButtonStyles.xaml new file mode 100644 index 0000000..5fa2f5d --- /dev/null +++ b/StructureHelper/Infrastructure/UI/Resources/CalculatorButtonStyles.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StructureHelper/Infrastructure/UI/Resources/MaterialButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/MaterialButtonStyles.xaml new file mode 100644 index 0000000..779e269 --- /dev/null +++ b/StructureHelper/Infrastructure/UI/Resources/MaterialButtonStyles.xaml @@ -0,0 +1,151 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StructureHelper/Infrastructure/UI/Resources/Materials.xaml b/StructureHelper/Infrastructure/UI/Resources/Materials.xaml index 8577d54..d815c38 100644 --- a/StructureHelper/Infrastructure/UI/Resources/Materials.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/Materials.xaml @@ -1,6 +1,38 @@  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -53,39 +75,13 @@ - - - - - - - - - - - - - - - + + + + + + - - + - - - - - - - - - - - - + + - - - - + + - + + - diff --git a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs index b09b842..a59a461 100644 --- a/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs +++ b/StructureHelper/Windows/CalculationWindows/CalculatorsViews/ForceCalculatorViews/IsoField3DViewerView.xaml.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -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; +using System.Windows; namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews { diff --git a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml index d2abe13..6cde4a1 100644 --- a/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml +++ b/StructureHelper/Windows/MainWindow/CrossSections/CrossSectionView.xaml @@ -17,6 +17,12 @@ d:DataContext="{d:DesignInstance local:CrossSectionViewModel}" Title="Cross-Section NDM Analysis" Height="700" Width="1000" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen"> + + + + + + @@ -29,7 +35,7 @@ - + @@ -48,23 +54,75 @@ Content="File" ToolTip="Add Combination From File"/> - - - - - - + @@ -236,32 +294,44 @@ - + + + - + + + - + + + - + + + - + + + - + + + diff --git a/StructureHelper/Windows/MainWindow/Materials/ConcreteViewModel.cs b/StructureHelper/Windows/MainWindow/Materials/ConcreteViewModel.cs index 6dc8c3f..3b7885a 100644 --- a/StructureHelper/Windows/MainWindow/Materials/ConcreteViewModel.cs +++ b/StructureHelper/Windows/MainWindow/Materials/ConcreteViewModel.cs @@ -5,7 +5,7 @@ namespace StructureHelper.Windows.ViewModels.Materials { public class ConcreteViewModel : LibMaterialViewModel { - readonly IConcreteLibMaterial concreteMaterial; + private readonly IConcreteLibMaterial concreteMaterial; public bool TensionForULS { get => concreteMaterial.TensionForULS; diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialBaseViewModel.cs b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialBaseViewModel.cs new file mode 100644 index 0000000..ab7c2cc --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialBaseViewModel.cs @@ -0,0 +1,71 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Models.Materials; +using StructureHelper.Windows.AddMaterialWindow; +using StructureHelper.Windows.ViewModels; +using StructureHelper.Windows.ViewModels.Materials; +using StructureHelperCommon.Models.Materials; +using StructureHelperCommon.Services.ColorServices; +using StructureHelperLogics.Models.Materials; +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Input; +using System.Windows.Media; + +namespace StructureHelper.Windows.MainWindow.Materials +{ + public class HeadMaterialBaseViewModel : OkCancelViewModelBase + { + private readonly IHeadMaterial headMaterial; + private ICommand showSafetyFactors; + private ICommand editColorCommand; + + public HeadMaterialBaseViewModel(IHeadMaterial headMaterial) + { + this.headMaterial = headMaterial; + } + + public string Name + { + get => headMaterial.Name; + set + { + headMaterial.Name = value; + OnPropertyChanged(nameof(Name)); + } + } + + public Color Color + { + get => headMaterial.Color; + } + + public HelperMaterialViewModel HelperMaterialViewModel { get; set; } + + public ICommand ShowSafetyFactors + { + get + { + return showSafetyFactors ??= new RelayCommand(o => + { + if (headMaterial is ILibMaterial libMaterial) + { + var wnd = new SafetyFactorsView(libMaterial.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)); + } + } +} diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml index a7b7df8..dfa85c5 100644 --- a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml +++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialView.xaml @@ -19,38 +19,15 @@ - - - - - - - - - - - - - - - - - - - - -