diff --git a/DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs index 15f8ea4..15b6b82 100644 --- a/DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CalculatorToDTOConvertStrategy.cs @@ -66,7 +66,7 @@ namespace DataAccess.DTOs TraceLogger?.AddMessage($"Current version of StructureHelper does not suppurt saving interaction diagram calculator, {limitCalculator.Name} was ignored"); } string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source); - TraceLogger.AddMessage(errorString, TraceLogStatuses.Error); + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); throw new StructureHelperException(errorString); } diff --git a/DataAccess/DTOs/Converters/CrossSectionFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionFromDTOConvertStrategy.cs index d681740..1c9f0b1 100644 --- a/DataAccess/DTOs/Converters/CrossSectionFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionFromDTOConvertStrategy.cs @@ -1,6 +1,9 @@ -using StructureHelperCommon.Infrastructures.Interfaces; +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; using StructureHelperCommon.Models.Loggers; +using StructureHelperCommon.Models.WorkPlanes; using StructureHelperLogics.Models.CrossSections; using System; using System.Collections.Generic; @@ -12,23 +15,24 @@ namespace DataAccess.DTOs { public class CrossSectionFromDTOConvertStrategy : IConvertStrategy { - private readonly IConvertStrategy convertStrategy; + private IConvertStrategy repositoryConvertStrategy; + private IConvertStrategy workPlaneConvertStrategy; - public CrossSectionFromDTOConvertStrategy(IConvertStrategy convertStrategy) + public CrossSectionFromDTOConvertStrategy(IConvertStrategy repositoryConvertStrategy, + IConvertStrategy workPlaneConvertStrategy) { - this.convertStrategy = convertStrategy; + this.repositoryConvertStrategy = repositoryConvertStrategy; + this.workPlaneConvertStrategy = workPlaneConvertStrategy; } - public CrossSectionFromDTOConvertStrategy() : this (new CrossSectionRepositoryFromDTOConvertStrategy()) - { - - } + public CrossSectionFromDTOConvertStrategy() { } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } public ICrossSection Convert(ICrossSection source) { + InitializeStrategies(); try { Check(); @@ -42,20 +46,38 @@ namespace DataAccess.DTOs } } + private void InitializeStrategies() + { + repositoryConvertStrategy ??= new CrossSectionRepositoryFromDTOConvertStrategy(ReferenceDictionary, TraceLogger); + workPlaneConvertStrategy ??= new WorkPlanePropertyFromDTOConvertStrategy(ReferenceDictionary,TraceLogger); + } + private ICrossSection GetNewCrossSection(ICrossSection source) { TraceLogger?.AddMessage("Cross-Section converting is started", TraceLogStatuses.Service); CrossSection newItem = new(source.Id); - convertStrategy.ReferenceDictionary = ReferenceDictionary; - convertStrategy.TraceLogger = TraceLogger; newItem.SectionRepository = GetNewCrossSectionRepository(source.SectionRepository); TraceLogger?.AddMessage("Cross-Section converting has been finished successfully", TraceLogStatuses.Service); + if (source.WorkPlaneProperty is null) + { + TraceLogger?.AddMessage("Work plane properties is not found", TraceLogStatuses.Warning); + newItem.WorkPlaneProperty = new WorkPlaneProperty(Guid.NewGuid()); + TraceLogger?.AddMessage("New work plane properties were generated", TraceLogStatuses.Debug); + } + else if (source.WorkPlaneProperty is WorkPlanePropertyDTO dto) + { + newItem.WorkPlaneProperty = workPlaneConvertStrategy.Convert(dto); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(source.WorkPlaneProperty)); + } return newItem; } private ICrossSectionRepository GetNewCrossSectionRepository(ICrossSectionRepository source) { - ICrossSectionRepository newItem = convertStrategy.Convert(source); + ICrossSectionRepository newItem = repositoryConvertStrategy.Convert(source); TraceLogger?.AddMessage($"Object of type <<{newItem.GetType()}>> was obtained", TraceLogStatuses.Service); return newItem; } diff --git a/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisFromDTOConvertStrategy.cs index 757da66..7569767 100644 --- a/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionNdmAnalysisFromDTOConvertStrategy.cs @@ -34,7 +34,7 @@ namespace DataAccess.DTOs.Converters try { Check(); - ICrossSectionNdmAnalysis newItem = GetCrossSectinNDMAnalysis(source); + ICrossSectionNdmAnalysis newItem = GetCrossSectionNDMAnalysis(source); return newItem; } catch (Exception ex) @@ -46,7 +46,7 @@ namespace DataAccess.DTOs.Converters } - private ICrossSectionNdmAnalysis GetCrossSectinNDMAnalysis(ICrossSectionNdmAnalysis source) + private ICrossSectionNdmAnalysis GetCrossSectionNDMAnalysis(ICrossSectionNdmAnalysis source) { TraceLogger?.AddMessage("Cross-section sonverting is started"); CrossSectionNdmAnalysis newItem = new(source.Id); diff --git a/DataAccess/DTOs/Converters/CrossSectionRepositoryFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionRepositoryFromDTOConvertStrategy.cs index aa0a57f..61450ab 100644 --- a/DataAccess/DTOs/Converters/CrossSectionRepositoryFromDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionRepositoryFromDTOConvertStrategy.cs @@ -26,6 +26,10 @@ namespace DataAccess.DTOs private IHasPrimitivesProcessLogic primitivesProcessLogic = new HasPrimitivesProcessLogic(ConvertDirection.FromDTO); private IHasForceActionsProcessLogic actionsProcessLogic = new HasForceActionsProcessLogic(ConvertDirection.FromDTO); + public CrossSectionRepositoryFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) : base(referenceDictionary, traceLogger) + { + } + public override CrossSectionRepository GetNewItem(ICrossSectionRepository source) { TraceLogger?.AddMessage("Cross-Section repository" + convertStarted); diff --git a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs index ca4b489..de016d0 100644 --- a/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionRepositoryToDTOConvertStrategy.cs @@ -19,10 +19,10 @@ namespace DataAccess.DTOs this.materialConvertStrategy = materialConvertStrategy; } - public CrossSectionRepositoryToDTOConvertStrategy() : this( - new HeadMaterialToDTOConvertStrategy()) + public CrossSectionRepositoryToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) { - + ReferenceDictionary = referenceDictionary; + TraceLogger = traceLogger; } public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } @@ -31,6 +31,7 @@ namespace DataAccess.DTOs public CrossSectionRepositoryDTO Convert(ICrossSectionRepository source) { Check(); + InitializeStrategies(); try { CrossSectionRepositoryDTO newItem = GetNewRepository(source); @@ -44,6 +45,11 @@ namespace DataAccess.DTOs } } + private void InitializeStrategies() + { + materialConvertStrategy ??= new HeadMaterialToDTOConvertStrategy(); + } + private CrossSectionRepositoryDTO GetNewRepository(ICrossSectionRepository source) { CrossSectionRepositoryDTO newItem = new() diff --git a/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs index 738f189..934974f 100644 --- a/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/CrossSectionToDTOConvertStrategy.cs @@ -1,49 +1,32 @@ -using StructureHelperCommon.Infrastructures.Interfaces; +using DataAccess.DTOs.Converters; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models; +using StructureHelperCommon.Models.WorkPlanes; using StructureHelperLogics.Models.CrossSections; namespace DataAccess.DTOs { - public class CrossSectionToDTOConvertStrategy : IConvertStrategy + public class CrossSectionToDTOConvertStrategy : ConvertStrategy { private IUpdateStrategy updateStrategy; //don't use since CrossSection does not have any properties private IConvertStrategy convertRepositoryStrategy; private DictionaryConvertStrategy convertLogic; private ICheckConvertLogic checkLogic; - - public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } - public IShiftTraceLogger TraceLogger { get; set; } + private IConvertStrategy workPlanePropertyConvertStrategy; public CrossSectionToDTOConvertStrategy(IUpdateStrategy updateStrategy, IConvertStrategy convertRepositoryStrategy, - ICheckConvertLogic checkLogic) + ICheckConvertLogic checkLogic, + IConvertStrategy workPlanePropertyConvertStrategy) { this.updateStrategy = updateStrategy; this.convertRepositoryStrategy = convertRepositoryStrategy; this.checkLogic = checkLogic; + this.workPlanePropertyConvertStrategy = workPlanePropertyConvertStrategy; } - public CrossSectionToDTOConvertStrategy() : this( - new CrossSectionUpdateStrategy(), - new CrossSectionRepositoryToDTOConvertStrategy(), - new CheckConvertLogic()) - { - - } + public CrossSectionToDTOConvertStrategy() { } - public CrossSectionDTO Convert(ICrossSection source) - { - Check(); - CrossSectionDTO newItem = new() - { - Id = source.Id - }; - convertRepositoryStrategy.ReferenceDictionary = ReferenceDictionary; - convertRepositoryStrategy.TraceLogger = TraceLogger; - convertLogic = new DictionaryConvertStrategy(this, convertRepositoryStrategy); - newItem.SectionRepository = convertLogic.Convert(source.SectionRepository); - return newItem; - } private void Check() { @@ -51,5 +34,40 @@ namespace DataAccess.DTOs checkLogic.TraceLogger = TraceLogger; checkLogic.Check(); } + + public override CrossSectionDTO GetNewItem(ICrossSection source) + { + InitializeStrategies(); + try + { + GetNewItemBySource(source); + return NewItem; + } + catch (Exception ex) + { + TraceErrorByEntity(this, ex.Message); + throw; + } + } + + private void InitializeStrategies() + { + updateStrategy ??= new CrossSectionUpdateStrategy(); + convertRepositoryStrategy ??= new CrossSectionRepositoryToDTOConvertStrategy(ReferenceDictionary, TraceLogger); + checkLogic ??= new CheckConvertLogic(); + workPlanePropertyConvertStrategy ??= new WorkPlanePropertyToDTOConvertStrategy(ReferenceDictionary, TraceLogger); + } + + private void GetNewItemBySource(ICrossSection source) + { + Check(); + NewItem = new() + { + Id = source.Id + }; + convertLogic = new DictionaryConvertStrategy(this, convertRepositoryStrategy); + NewItem.SectionRepository = convertLogic.Convert(source.SectionRepository); + NewItem.WorkPlaneProperty = workPlanePropertyConvertStrategy.Convert(source.WorkPlaneProperty); + } } } diff --git a/DataAccess/DTOs/Converters/FactoredCombinationPropertyToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/FactoredCombinationPropertyToDTOConvertStrategy.cs index cab1cbc..63a4285 100644 --- a/DataAccess/DTOs/Converters/FactoredCombinationPropertyToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/FactoredCombinationPropertyToDTOConvertStrategy.cs @@ -25,10 +25,10 @@ namespace DataAccess.DTOs public override FactoredCombinationPropertyDTO GetNewItem(IFactoredCombinationProperty source) { InitializeStrategies(); - TraceLogger.AddMessage($"Force factored combination property Id={source.Id} converting has been started"); + TraceLogger?.AddMessage($"Force factored combination property Id={source.Id} converting has been started"); FactoredCombinationPropertyDTO newItem = new(source.Id); updateStrategy.Update(newItem, source); - TraceLogger.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished"); + TraceLogger?.AddMessage($"Force factored combination property Id={newItem.Id} converting has been finished"); return newItem; } diff --git a/DataAccess/DTOs/Converters/ForceActionToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/ForceActionToDTOConvertStrategy.cs index 5ce4168..240f63a 100644 --- a/DataAccess/DTOs/Converters/ForceActionToDTOConvertStrategy.cs +++ b/DataAccess/DTOs/Converters/ForceActionToDTOConvertStrategy.cs @@ -44,7 +44,7 @@ namespace DataAccess.DTOs else { string errorString = ErrorStrings.ObjectTypeIsUnknownObj(source); - TraceLogger.AddMessage(errorString, TraceLogStatuses.Error); + TraceLogger?.AddMessage(errorString, TraceLogStatuses.Error); throw new StructureHelperException(errorString); } } diff --git a/DataAccess/DTOs/Converters/WorkPlanePropertyFromDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/WorkPlanePropertyFromDTOConvertStrategy.cs new file mode 100644 index 0000000..d3c6ae0 --- /dev/null +++ b/DataAccess/DTOs/Converters/WorkPlanePropertyFromDTOConvertStrategy.cs @@ -0,0 +1,46 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.WorkPlanes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class WorkPlanePropertyFromDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + public WorkPlanePropertyFromDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, + IShiftTraceLogger traceLogger) + : base(referenceDictionary, traceLogger) + { } + + public override WorkPlaneProperty GetNewItem(WorkPlanePropertyDTO source) + { + InitializeStrategies(); + try + { + GetNewItemBySource(source); + return NewItem; + } + catch (Exception ex) + { + TraceErrorByEntity(this, ex.Message); + throw; + } + } + + private void GetNewItemBySource(IWorkPlaneProperty source) + { + NewItem = new(source.Id); + updateStrategy.Update(NewItem, source); + } + + private void InitializeStrategies() + { + updateStrategy ??= new WorkPlanePropertyUpdateStrategy(); + } + } +} diff --git a/DataAccess/DTOs/Converters/WorkPlanePropertyToDTOConvertStrategy.cs b/DataAccess/DTOs/Converters/WorkPlanePropertyToDTOConvertStrategy.cs new file mode 100644 index 0000000..4a04ef8 --- /dev/null +++ b/DataAccess/DTOs/Converters/WorkPlanePropertyToDTOConvertStrategy.cs @@ -0,0 +1,47 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models; +using StructureHelperCommon.Models.WorkPlanes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs.Converters +{ + public class WorkPlanePropertyToDTOConvertStrategy : ConvertStrategy + { + private IUpdateStrategy updateStrategy; + public WorkPlanePropertyToDTOConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, + IShiftTraceLogger traceLogger) + { + ReferenceDictionary = referenceDictionary; + TraceLogger = traceLogger; + } + public override WorkPlanePropertyDTO GetNewItem(IWorkPlaneProperty source) + { + InitializeStrategies(); + try + { + GetNewItemBySource(source); + return NewItem; + } + catch (Exception ex) + { + TraceErrorByEntity(this, ex.Message); + throw; + } + } + + private void GetNewItemBySource(IWorkPlaneProperty source) + { + NewItem = new(source.Id); + updateStrategy.Update(NewItem, source); + } + + private void InitializeStrategies() + { + updateStrategy ??= new WorkPlanePropertyUpdateStrategy(); + } + } +} diff --git a/DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs b/DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs index f14da37..55736f7 100644 --- a/DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs +++ b/DataAccess/DTOs/DTOEntities/CrossSectionDTO.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using StructureHelperCommon.Models.WorkPlanes; using StructureHelperLogics.Models.CrossSections; using System; using System.Collections.Generic; @@ -15,6 +16,8 @@ namespace DataAccess.DTOs [JsonProperty("SectionRepository")] public ICrossSectionRepository SectionRepository { get; set; } + public IWorkPlaneProperty WorkPlaneProperty { get; set; } + public object Clone() { throw new NotImplementedException(); diff --git a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs index 0121b0a..c1769c5 100644 --- a/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs +++ b/DataAccess/DTOs/DTOEntities/TypeBinderListFactory.cs @@ -89,6 +89,7 @@ namespace DataAccess.DTOs { (typeof(VisualAnalysisDTO), "VisualAnalysis") }, { (typeof(VisualPropertyDTO), "VisualProperty") }, { (typeof(UserCrackInputDataDTO), "UserCrackInputData") }, + { (typeof(WorkPlanePropertyDTO), "WorkPlanePropertyDTO") }, }; return newList; } diff --git a/DataAccess/DTOs/DTOEntities/WorkPlanePropertyDTO.cs b/DataAccess/DTOs/DTOEntities/WorkPlanePropertyDTO.cs new file mode 100644 index 0000000..4b0b876 --- /dev/null +++ b/DataAccess/DTOs/DTOEntities/WorkPlanePropertyDTO.cs @@ -0,0 +1,31 @@ +using Newtonsoft.Json; +using StructureHelperCommon.Models.WorkPlanes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DataAccess.DTOs +{ + public class WorkPlanePropertyDTO : IWorkPlaneProperty + { + [JsonProperty("Id")] + public Guid Id { get; } + [JsonProperty("GridSize")] + public double GridSize { get; set; } = 0.05; + [JsonProperty("Width")] + public double Width { get; set; } = 1.2; + [JsonProperty("Height")] + public double Height { get; set; } = 1.2; + [JsonProperty("AxisLineThickness")] + public double AxisLineThickness { get; set; } = 2; + [JsonProperty("GridLineThickness")] + public double GridLineThickness { get; set; } = 0.25; + + public WorkPlanePropertyDTO(Guid id) + { + Id = id; + } + } +} diff --git a/StructureHelper/App.xaml b/StructureHelper/App.xaml index 70db8cc..65d70da 100644 --- a/StructureHelper/App.xaml +++ b/StructureHelper/App.xaml @@ -20,6 +20,7 @@ + diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index 5b195b4..847c8a1 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -130,6 +130,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -544,14 +568,6 @@ - - - - - - - - @@ -579,14 +595,6 @@ - - - - - - - - @@ -641,7 +649,7 @@ - + diff --git a/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml b/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml new file mode 100644 index 0000000..d99f36a --- /dev/null +++ b/StructureHelper/Infrastructure/UI/Resources/ScrollableWorkPlane.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index fab8d79..a8822dd 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -102,6 +102,9 @@ Code + + Code + @@ -122,6 +125,9 @@ Designer + + Designer + Designer @@ -221,5 +227,8 @@ Designer + + Designer + \ No newline at end of file diff --git a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml index cd60d07..a2148a3 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml @@ -7,7 +7,7 @@ xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:ForceCombinationByFactorVM}" mc:Ignorable="d" - Title="Force Combination By Factor" Height="220" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> + Title="Force Combination By Factor" Height="250" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> diff --git a/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml b/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml index 8d83ad4..70fb2d1 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationFromFileView.xaml @@ -7,7 +7,7 @@ xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance local:ForceCombinationFromFileVM}" mc:Ignorable="d" - Title="Force Combination By Files" Height="280" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> + Title="Force Combination By Files" Height="330" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> @@ -20,8 +20,13 @@ - + + + + + + diff --git a/StructureHelper/Windows/Forces/ForceCombinationView.xaml b/StructureHelper/Windows/Forces/ForceCombinationView.xaml index 78202ae..f525217 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationView.xaml @@ -5,6 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:StructureHelper.Windows.Forces" xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" d:DataContext="{d:DesignInstance vm:ForceCombinationViewModel}" mc:Ignorable="d" Title="Force Combination" Height="350" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen"> @@ -12,13 +13,70 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml index b0d7f77..0386eab 100644 --- a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml +++ b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml @@ -84,7 +84,7 @@ - @@ -192,7 +192,7 @@ - + diff --git a/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs b/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs index 6c9e2f0..6fdeff6 100644 --- a/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs +++ b/StructureHelper/Windows/MainWindow/AxisCanvases/AxisCanvasVM.cs @@ -1,6 +1,7 @@ using StructureHelper.Infrastructure; using StructureHelper.Windows.ViewModels; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.WorkPlanes; using System; using System.Collections.Generic; using System.Linq; @@ -13,24 +14,25 @@ namespace StructureHelper.Windows.MainWindow { public class AxisCanvasVM : OkCancelViewModelBase, IRectangleShape { - private double axisLineThickness; - private double gridLineThickness; - private double gridSize; - private double width; - private double height; - private Color xAxisColor; - private Color yAxisColor; - private Color gridColor; + private IWorkPlaneProperty workPlaneProperty; + + public AxisCanvasVM(IWorkPlaneProperty workPlaneProperty) + { + this.workPlaneProperty = workPlaneProperty; + } + private Color xAxisColor = Colors.Red; + private Color yAxisColor = Colors.ForestGreen; + private Color gridColor = Colors.DarkGray; /// /// Thickness of x-, and y- axis line /// public double AxisLineThickness { - get => axisLineThickness; + get => workPlaneProperty.AxisLineThickness; set { - axisLineThickness = value; + workPlaneProperty.AxisLineThickness = value; OnPropertyChanged(nameof(AxisLineThickness)); } } @@ -39,10 +41,10 @@ namespace StructureHelper.Windows.MainWindow /// public double GridLineThickness { - get => gridLineThickness; + get => workPlaneProperty.GridLineThickness; set { - gridLineThickness = value; + workPlaneProperty.GridLineThickness = value; OnPropertyChanged(nameof(GridLineThickness)); } } @@ -51,9 +53,9 @@ namespace StructureHelper.Windows.MainWindow /// public double GridSize { - get => gridSize; set + get => workPlaneProperty.GridSize; set { - gridSize = value; + workPlaneProperty.GridSize = value; OnPropertyChanged(nameof(GridSize)); } } @@ -62,9 +64,9 @@ namespace StructureHelper.Windows.MainWindow /// public double Width { - get => width; set + get => workPlaneProperty.Width; set { - width = value; + workPlaneProperty.Width = value; OnPropertyChanged(nameof(Width)); } } @@ -73,9 +75,9 @@ namespace StructureHelper.Windows.MainWindow /// public double Height { - get => height; set + get => workPlaneProperty.Height; set { - height = value; + workPlaneProperty.Height = value; OnPropertyChanged(nameof(Height)); } } @@ -101,7 +103,8 @@ namespace StructureHelper.Windows.MainWindow public Color GridColor { - get => gridColor; set + get => gridColor; + set { gridColor = value; OnPropertyChanged(nameof(GridColor)); @@ -109,17 +112,5 @@ namespace StructureHelper.Windows.MainWindow } public Guid Id => throw new NotImplementedException(); - - public AxisCanvasVM() - { - AxisLineThickness = 2d; - GridLineThickness = 0.25d; - GridSize = 0.05d; - Width = 1.2d; - Height = 1.2d; - XAxisColor = Colors.Red; - YAxisColor = Colors.ForestGreen; - GridColor = Colors.DarkGray; - } } } diff --git a/StructureHelper/Windows/MainWindow/AxisCanvases/CrossSectionVisualPropertyVM.cs b/StructureHelper/Windows/MainWindow/AxisCanvases/CrossSectionVisualPropertyVM.cs index 591d342..2101678 100644 --- a/StructureHelper/Windows/MainWindow/AxisCanvases/CrossSectionVisualPropertyVM.cs +++ b/StructureHelper/Windows/MainWindow/AxisCanvases/CrossSectionVisualPropertyVM.cs @@ -3,6 +3,7 @@ using StructureHelper.Infrastructure; using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Windows.ViewModels.NdmCrossSections; using StructureHelperCommon.Models.Shapes; +using StructureHelperCommon.Models.WorkPlanes; using StructureHelperLogics.NdmCalculations.Primitives; using System; using System.Windows.Input; @@ -148,9 +149,9 @@ namespace StructureHelper.Windows.MainWindow public CrossSectionViewModel ParentViewModel { get; set; } - public CrossSectionVisualPropertyVM() + public CrossSectionVisualPropertyVM(IWorkPlaneProperty workPlaneProperty) { - AxisCanvasVM = new(); + AxisCanvasVM = new(workPlaneProperty); } } } diff --git a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml index 6dc7e81..9164902 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml +++ b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml @@ -11,6 +11,7 @@ xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow" xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" + xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls" xmlns:sys="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" d:DataContext="{d:DesignInstance local:CrossSectionViewModel}" @@ -43,39 +44,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -360,157 +328,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs index 57ece0c..d1afd2f 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs @@ -127,7 +127,7 @@ namespace StructureHelper.Windows.MainWindow public CrossSectionViewModel(ICrossSection section) { Section = section; - VisualProperty = new CrossSectionVisualPropertyVM() + VisualProperty = new CrossSectionVisualPropertyVM(Section.WorkPlaneProperty) { ScaleValue = 500d, ParentViewModel = this @@ -300,7 +300,7 @@ namespace StructureHelper.Windows.MainWindow // GlobalRepository.Actions.Create(item); //} return primitives; - + //WorkPlane } } } \ No newline at end of file diff --git a/StructureHelper/Windows/UserControls/ListOfFileControl.xaml b/StructureHelper/Windows/UserControls/ListOfFileControl.xaml index f5096e2..2416421 100644 --- a/StructureHelper/Windows/UserControls/ListOfFileControl.xaml +++ b/StructureHelper/Windows/UserControls/ListOfFileControl.xaml @@ -12,46 +12,46 @@ - - - - diff --git a/StructureHelper/Windows/UserControls/WorkPlane.xaml b/StructureHelper/Windows/UserControls/WorkPlane.xaml new file mode 100644 index 0000000..d812e21 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlane.xaml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs b/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs new file mode 100644 index 0000000..72c8df4 --- /dev/null +++ b/StructureHelper/Windows/UserControls/WorkPlane.xaml.cs @@ -0,0 +1,52 @@ +using StructureHelper.Infrastructure.UI.DataContexts; +using StructureHelper.Windows.MainWindow; +using StructureHelper.Windows.ViewModels.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.Navigation; +using System.Windows.Shapes; + +namespace StructureHelper.Windows.UserControls +{ + /// + /// Interaction logic for WorkPlane.xaml + /// + public partial class WorkPlane : UserControl + { + + + public CrossSectionViewModel ViewModel + { + get { return (CrossSectionViewModel)GetValue(ViewModelProperty); } + set { SetValue(ViewModelProperty, value); } + } + + // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ViewModelProperty = + DependencyProperty.Register(nameof(ViewModel), typeof(CrossSectionViewModel), typeof(WorkPlane), new PropertyMetadata(null)); + + + + public WorkPlane() + { + InitializeComponent(); + } + + private void ContentPresenter_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) + { + var contentPresenter = sender as ContentPresenter; + var item = contentPresenter?.Content as PrimitiveBase; + ViewModel.PrimitiveLogic.SelectedItem = item; + } + } +} diff --git a/StructureHelperCommon/Infrastructures/Interfaces/ConvertStrategy.cs b/StructureHelperCommon/Infrastructures/Interfaces/ConvertStrategy.cs index a91e391..3c408b8 100644 --- a/StructureHelperCommon/Infrastructures/Interfaces/ConvertStrategy.cs +++ b/StructureHelperCommon/Infrastructures/Interfaces/ConvertStrategy.cs @@ -13,6 +13,17 @@ namespace StructureHelperCommon.Infrastructures.Interfaces where T : ISaveable where V : ISaveable { + protected ConvertStrategy(Dictionary<(Guid id, Type type), ISaveable> referenceDictionary, IShiftTraceLogger traceLogger) + { + ReferenceDictionary = referenceDictionary; + TraceLogger = traceLogger; + } + + public ConvertStrategy() + { + + } + public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; } public IShiftTraceLogger TraceLogger { get; set; } diff --git a/StructureHelperCommon/Models/WorkPlanes/IWorkPlaneProperty.cs b/StructureHelperCommon/Models/WorkPlanes/IWorkPlaneProperty.cs new file mode 100644 index 0000000..e06e6f8 --- /dev/null +++ b/StructureHelperCommon/Models/WorkPlanes/IWorkPlaneProperty.cs @@ -0,0 +1,26 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Shapes; +using System; +using System.Windows.Media; + +namespace StructureHelperCommon.Models.WorkPlanes +{ + /// + /// Implements properties of work plane + /// + public interface IWorkPlaneProperty : ISaveable, IRectangleShape + { + /// + /// Size of grid of work plane + /// + double GridSize { get; set; } + /// + /// Thickness of axis line + /// + double AxisLineThickness { get; set; } + /// + /// Thickness of lines of main grid + /// + double GridLineThickness { get; set; } + } +} \ No newline at end of file diff --git a/StructureHelperCommon/Models/WorkPlanes/WorkPlaneProperty.cs b/StructureHelperCommon/Models/WorkPlanes/WorkPlaneProperty.cs new file mode 100644 index 0000000..2fa1405 --- /dev/null +++ b/StructureHelperCommon/Models/WorkPlanes/WorkPlaneProperty.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace StructureHelperCommon.Models.WorkPlanes +{ + public class WorkPlaneProperty : IWorkPlaneProperty + { + public Guid Id { get; } + public double GridSize { get; set; } = 0.05; + public double Height { get; set; } = 1.2; + public double Width { get; set; } = 1.2; + public double AxisLineThickness { get; set; } = 2; + public double GridLineThickness { get; set; } = 0.25; + + public WorkPlaneProperty(Guid id) + { + Id = id; + } + } +} diff --git a/StructureHelperCommon/Models/WorkPlanes/WorkPlanePropertyUpdateStrategy.cs b/StructureHelperCommon/Models/WorkPlanes/WorkPlanePropertyUpdateStrategy.cs new file mode 100644 index 0000000..81aa3b1 --- /dev/null +++ b/StructureHelperCommon/Models/WorkPlanes/WorkPlanePropertyUpdateStrategy.cs @@ -0,0 +1,25 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.WorkPlanes +{ + public class WorkPlanePropertyUpdateStrategy : IUpdateStrategy + { + public void Update(IWorkPlaneProperty targetObject, IWorkPlaneProperty sourceObject) + { + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.AxisLineThickness = sourceObject.AxisLineThickness; + targetObject.GridSize = sourceObject.GridSize; + targetObject.GridLineThickness = sourceObject.GridLineThickness; + targetObject.Height = sourceObject.Height; + targetObject.Width = sourceObject.Width; + } + } +} diff --git a/StructureHelperLogics/Models/CrossSections/CrossSection.cs b/StructureHelperLogics/Models/CrossSections/CrossSection.cs index 7374f5e..22c9d8f 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSection.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSection.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.WorkPlanes; using System; using System.Collections.Generic; using System.Linq; @@ -12,6 +13,7 @@ namespace StructureHelperLogics.Models.CrossSections public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository(); public Guid Id { get; private set; } + public IWorkPlaneProperty WorkPlaneProperty { get; set; } = new WorkPlaneProperty(Guid.NewGuid()); public CrossSection(Guid id) { diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionCloneStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionCloneStrategy.cs index 88d7b7a..c4cd2a3 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSectionCloneStrategy.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionCloneStrategy.cs @@ -1,35 +1,37 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Settings; +using StructureHelperCommon.Models.WorkPlanes; +using StructureHelperCommon.Services; namespace StructureHelperLogics.Models.CrossSections { public class CrossSectionCloneStrategy : ICloneStrategy { private ICloneStrategy repositoryCloneStrategy; + private IUpdateStrategy workPlaneUpdateStrategy; private CrossSection targetObject; - public CrossSectionCloneStrategy(ICloneStrategy repositoryCloneStrategy) + public CrossSectionCloneStrategy(ICloneStrategy repositoryCloneStrategy, + IUpdateStrategy workPlaneUpdateStrategy) { this.repositoryCloneStrategy = repositoryCloneStrategy; + this.workPlaneUpdateStrategy = workPlaneUpdateStrategy; } - public CrossSectionCloneStrategy(ICloningStrategy cloningStrategy) : this (new CrossSectionRepositoryCloneStrategy(cloningStrategy)) - { - - } - - public CrossSectionCloneStrategy() : this (new DeepCloningStrategy()) - { - - } + public CrossSectionCloneStrategy() { } public ICrossSection GetClone(ICrossSection sourceObject) { + repositoryCloneStrategy ??= new CrossSectionRepositoryCloneStrategy(new DeepCloningStrategy()); ICrossSectionRepository newRepository = repositoryCloneStrategy.GetClone(sourceObject.SectionRepository); targetObject = new() { SectionRepository = newRepository }; + CheckObject.IsNull(targetObject.WorkPlaneProperty); + CheckObject.IsNull(sourceObject.WorkPlaneProperty); + workPlaneUpdateStrategy ??= new WorkPlanePropertyUpdateStrategy(); + workPlaneUpdateStrategy.Update(targetObject.WorkPlaneProperty, sourceObject.WorkPlaneProperty); return targetObject; } } diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs index d4dd133..8384645 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs @@ -16,9 +16,9 @@ namespace StructureHelperLogics.Models.CrossSections public void Update(ICrossSectionRepository targetObject, ICrossSectionRepository sourceObject) { - CheckObject.IsNull(targetObject, sourceObject); - if (ReferenceEquals(targetObject, sourceObject)) { return; } - + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } } } } diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs index 66fedeb..39498d0 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.WorkPlanes; using StructureHelperCommon.Services; using StructureHelperLogics.NdmCalculations.Primitives; using StructureHelperLogics.NdmCalculations.Primitives.Logics; @@ -13,27 +14,47 @@ namespace StructureHelperLogics.Models.CrossSections public class CrossSectionUpdateStrategy : IUpdateStrategy { private IUpdateStrategy repositoryUpdateStrategy; + private IUpdateStrategy workPlaneUpdateStrategy; - public CrossSectionUpdateStrategy(IUpdateStrategy repositoryUpdateStrategy) + public CrossSectionUpdateStrategy(IUpdateStrategy repositoryUpdateStrategy, + IUpdateStrategy workPlaneUpdateStrategy) { this.repositoryUpdateStrategy = repositoryUpdateStrategy; + this.workPlaneUpdateStrategy = workPlaneUpdateStrategy; } - public CrossSectionUpdateStrategy() : this ( - new CrossSectionRepositoryUpdateStrategy() - ) - { - - } + public CrossSectionUpdateStrategy() { } public void Update(ICrossSection targetObject, ICrossSection sourceObject) { - CheckObject.IsNull(targetObject, sourceObject); + CheckObject.IsNull(targetObject); + CheckObject.IsNull(sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } + UpdateRepository(targetObject, sourceObject); + UpdateWorkPlane(targetObject, sourceObject); + } + + private void UpdateWorkPlane(ICrossSection targetObject, ICrossSection sourceObject) + { + if (sourceObject.WorkPlaneProperty is null) + { + targetObject.WorkPlaneProperty = new WorkPlaneProperty(Guid.NewGuid()); + return; + } + targetObject.WorkPlaneProperty ??= new WorkPlaneProperty(Guid.NewGuid()); + workPlaneUpdateStrategy ??= new WorkPlanePropertyUpdateStrategy(); + workPlaneUpdateStrategy.Update(targetObject.WorkPlaneProperty, sourceObject.WorkPlaneProperty); + } + + private void UpdateRepository(ICrossSection targetObject, ICrossSection sourceObject) + { + CheckObject.IsNull(targetObject.SectionRepository); + CheckObject.IsNull(sourceObject.SectionRepository); targetObject.SectionRepository.Calculators.Clear(); targetObject.SectionRepository.Primitives.Clear(); targetObject.SectionRepository.ForceActions.Clear(); targetObject.SectionRepository.HeadMaterials.Clear(); + repositoryUpdateStrategy ??= new CrossSectionRepositoryUpdateStrategy(); repositoryUpdateStrategy.Update(targetObject.SectionRepository, sourceObject.SectionRepository); } } diff --git a/StructureHelperLogics/Models/CrossSections/ICrossSection.cs b/StructureHelperLogics/Models/CrossSections/ICrossSection.cs index 7ff9c97..09594a4 100644 --- a/StructureHelperLogics/Models/CrossSections/ICrossSection.cs +++ b/StructureHelperLogics/Models/CrossSections/ICrossSection.cs @@ -1,4 +1,5 @@ using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.WorkPlanes; using System; using System.Collections.Generic; using System.Linq; @@ -10,5 +11,6 @@ namespace StructureHelperLogics.Models.CrossSections public interface ICrossSection : ISaveable, ICloneable { ICrossSectionRepository SectionRepository { get; set; } + IWorkPlaneProperty WorkPlaneProperty { get; set; } } }