diff --git a/StructureHelper/App.xaml.cs b/StructureHelper/App.xaml.cs index 86d7f43..80467cf 100644 --- a/StructureHelper/App.xaml.cs +++ b/StructureHelper/App.xaml.cs @@ -22,15 +22,17 @@ namespace StructureHelper builder.RegisterType().As().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); builder.RegisterType().AsSelf().SingleInstance(); - builder.RegisterType().AsSelf().SingleInstance(); - builder.RegisterType().AsSelf().SingleInstance(); + //builder.RegisterType().AsSelf().SingleInstance(); + //builder.RegisterType().AsSelf().SingleInstance(); + //builder.RegisterType().AsSelf(); - builder.RegisterType().AsSelf(); + builder.RegisterType().AsSelf().SingleInstance(); + builder.RegisterType().AsSelf(); Container = builder.Build(); Scope = Container.Resolve(); - var window = Scope.Resolve(); + var window = Scope.Resolve(); window.Show(); } diff --git a/StructureHelper/Documentation/Manuals/Руководство пользователя.docx b/StructureHelper/Documentation/Manuals/Руководство пользователя.docx index d66c967..dd88887 100644 Binary files a/StructureHelper/Documentation/Manuals/Руководство пользователя.docx and b/StructureHelper/Documentation/Manuals/Руководство пользователя.docx differ diff --git a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml index 4887639..4a05ca2 100644 --- a/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml +++ b/StructureHelper/Infrastructure/UI/Resources/ButtonStyles.xaml @@ -278,8 +278,8 @@ - - + + @@ -287,8 +287,8 @@ - - + + @@ -296,8 +296,8 @@ - - + + diff --git a/StructureHelper/StructureHelper.csproj.user b/StructureHelper/StructureHelper.csproj.user index a9d2d08..4818581 100644 --- a/StructureHelper/StructureHelper.csproj.user +++ b/StructureHelper/StructureHelper.csproj.user @@ -63,6 +63,9 @@ Code + + Code + Code @@ -158,6 +161,9 @@ Designer + + Designer + Designer diff --git a/StructureHelper/Windows/MainWindow/Analyses/AnalysesLogic.cs b/StructureHelper/Windows/MainWindow/Analyses/AnalysesLogic.cs new file mode 100644 index 0000000..39ecff6 --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/AnalysesLogic.cs @@ -0,0 +1,128 @@ +using StructureHelper.Infrastructure; +using StructureHelper.Windows.MainWindow.Analyses; +using StructureHelperLogic.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace StructureHelper.Windows.MainWindow +{ + public class AnalysesLogic : ViewModelBase + { + private RelayCommand? addAnalyisCommand; + private RelayCommand? runCommand; + private RelayCommand? editCommand; + private RelayCommand? deleteCommand; + + public IVisualAnalysis? SelectedAnalysis { get; set; } + + public List AnalysesList { get; } + public ObservableCollection FilteredAnalyses { get; } + public RelayCommand AddAnalysisCommand + { + get + { + return addAnalyisCommand ??= new RelayCommand(obj => + { + AddCrossSectionNdmAnalysis(); + Refresh(); + }); + } + } + public RelayCommand RunCommand + { + get + { + return runCommand ??= new RelayCommand(obj => + { + RunAnalysis(); + Refresh(); + }, + b => SelectedAnalysis is not null); + } + } + public RelayCommand EditCommand + { + get + { + return editCommand ??= new RelayCommand(obj => + { + EditAnalysis(); + Refresh(); + }, + b => SelectedAnalysis is not null); + } + } + public RelayCommand DeleteCommand + { + get + { + return deleteCommand ??= new RelayCommand(obj => + { + DeleteAnalysis(); + Refresh(); + }, + b => SelectedAnalysis is not null); + } + } + + + public AnalysesLogic() + { + AnalysesList = new(); + FilteredAnalyses = new(); + } + public void Refresh() + { + FilteredAnalyses.Clear(); + var analysesList = AnalysesList.ToList(); + foreach (var analysis in analysesList) + { + FilteredAnalyses.Add(analysis); + } + } + private void EditAnalysis() + { + if (SelectedAnalysis is not null) + { + var name = SelectedAnalysis.Analysis.Name; + var tags = SelectedAnalysis.Analysis.Tags; + var wnd = new AnalysisView(SelectedAnalysis); + wnd.ShowDialog(); + if (wnd.DialogResult != true) + { + SelectedAnalysis.Analysis.Name = name; + SelectedAnalysis.Analysis.Tags = tags; + } + } + } + private void DeleteAnalysis() + { + if (SelectedAnalysis is not null) + { + var dialogResult = MessageBox.Show("Delete analysis?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (dialogResult == DialogResult.Yes) + { + AnalysesList.Remove(SelectedAnalysis); + } + } + } + private void RunAnalysis() + { + SelectedAnalysis?.Run(); + } + private void AddCrossSectionNdmAnalysis() + { + var analysis = new CrossSectionNdmAnalysis(); + analysis.Name = "New NDM Analysis"; + analysis.Tags = "#New group"; + var visualAnalysis = new VisualAnalysis(analysis); + AnalysesList.Add(visualAnalysis); + } + } +} diff --git a/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml b/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml new file mode 100644 index 0000000..458a916 --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml.cs b/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml.cs new file mode 100644 index 0000000..0e0123c --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/AnalysisView.xaml.cs @@ -0,0 +1,41 @@ +using StructureHelperCommon.Models.Analyses; +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.Analyses +{ + /// + /// Interaction logic for AnalysisView.xaml + /// + public partial class AnalysisView : Window + { + private readonly AnalysisViewModel viewModel; + + public AnalysisView(AnalysisViewModel viewModel) + { + this.viewModel = viewModel; + this.viewModel.ParentWindow = this; + this.DataContext = this.viewModel; + InitializeComponent(); + } + public AnalysisView(IAnalysis analysis) : this(new AnalysisViewModel(analysis)) + { + } + + public AnalysisView(IVisualAnalysis visualAnalysis) : this(visualAnalysis.Analysis) + { + + } + } +} diff --git a/StructureHelper/Windows/MainWindow/Analyses/AnalysisViewModel.cs b/StructureHelper/Windows/MainWindow/Analyses/AnalysisViewModel.cs new file mode 100644 index 0000000..a2de802 --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/AnalysisViewModel.cs @@ -0,0 +1,32 @@ +using StructureHelper.Windows.ViewModels; +using StructureHelperCommon.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.MainWindow.Analyses +{ + public class AnalysisViewModel : OkCancelViewModelBase + { + private readonly IAnalysis analysis; + + public string Name + { + get => analysis.Name; + set => analysis.Name = value; + } + + public string Tags + { + get => analysis.Tags; + set => analysis.Tags = value; + } + + public AnalysisViewModel(IAnalysis analysis) + { + this.analysis = analysis; + } + } +} diff --git a/StructureHelper/Windows/MainWindow/Analyses/IVisualAnalysis.cs b/StructureHelper/Windows/MainWindow/Analyses/IVisualAnalysis.cs new file mode 100644 index 0000000..ccb522b --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/IVisualAnalysis.cs @@ -0,0 +1,15 @@ +using StructureHelperCommon.Models.Analyses; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.MainWindow.Analyses +{ + public interface IVisualAnalysis + { + IAnalysis Analysis {get;set;} + void Run(); + } +} diff --git a/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs b/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs new file mode 100644 index 0000000..f3d3d70 --- /dev/null +++ b/StructureHelper/Windows/MainWindow/Analyses/VisualAnalysis.cs @@ -0,0 +1,44 @@ +using StructureHelperCommon.Infrastructures.Exceptions; +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelper.Windows.MainWindow.Analyses +{ + public class VisualAnalysis : IVisualAnalysis + { + public IAnalysis Analysis { get; set; } + + public VisualAnalysis(IAnalysis analysis) + { + Analysis = analysis; + } + + public void Run() + { + var version = Analysis.VersionProcessor.GetCurrentVersion(); + if (version is null) + { + throw new StructureHelperException(ErrorStrings.NullReference); + } + if (version.Item is ICrossSection crossSection) + { + ProcessCrossSection(crossSection); + } + else + { + throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version)); + } + } + + private void ProcessCrossSection(ICrossSection crossSection) + { + var window = new CrossSectionView(crossSection); + window.ShowDialog(); + } + } +} diff --git a/StructureHelper/Windows/MainWindow/AnalysesLogic.cs b/StructureHelper/Windows/MainWindow/AnalysesLogic.cs deleted file mode 100644 index 4e51153..0000000 --- a/StructureHelper/Windows/MainWindow/AnalysesLogic.cs +++ /dev/null @@ -1,13 +0,0 @@ -using StructureHelper.Infrastructure; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace StructureHelper.Windows.MainWindow -{ - public class AnalisesLogic : ViewModelBase - { - } -} diff --git a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml index 8913400..2cda902 100644 --- a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml +++ b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow" mc:Ignorable="d" d:DataContext="{d:DesignInstance local:AnalysesManagerViewModel}" - Title="Analyses Manager" Height="450" Width="800" MinHeight="400" MinWidth="600"> + Title="Analyses Manager" Height="450" Width="800" MinHeight="400" MinWidth="600" WindowStartupLocation="CenterScreen"> @@ -32,7 +32,7 @@ - - - - - + + + + + + + + + + + + + + + diff --git a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml.cs b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml.cs index af11edd..2779f69 100644 --- a/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml.cs +++ b/StructureHelper/Windows/MainWindow/AnalysesManagerView.xaml.cs @@ -19,8 +19,11 @@ namespace StructureHelper.Windows.MainWindow /// public partial class AnalysesManagerView : Window { + private AnalysesManagerViewModel viewModel; public AnalysesManagerView() { + this.viewModel = new(); + this.DataContext = viewModel; InitializeComponent(); } } diff --git a/StructureHelper/Windows/MainWindow/AnalysesManagerViewModel.cs b/StructureHelper/Windows/MainWindow/AnalysesManagerViewModel.cs index bec1f79..76d649e 100644 --- a/StructureHelper/Windows/MainWindow/AnalysesManagerViewModel.cs +++ b/StructureHelper/Windows/MainWindow/AnalysesManagerViewModel.cs @@ -11,13 +11,13 @@ namespace StructureHelper.Windows.MainWindow { public FileLogic FileLogic { get; } public DiagramLogic DiagramLogic { get; } - public AnalisesLogic AnalisesLogic { get; } + public AnalysesLogic AnalysesLogic { get; } public AnalysesManagerViewModel() { FileLogic = new(); DiagramLogic = new(); - AnalisesLogic = new(); + AnalysesLogic = new(); } } } diff --git a/StructureHelper/Windows/MainWindow/CrossSectionModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionModel.cs deleted file mode 100644 index 874a705..0000000 --- a/StructureHelper/Windows/MainWindow/CrossSectionModel.cs +++ /dev/null @@ -1,73 +0,0 @@ -using LoaderCalculator; -using LoaderCalculator.Data.Materials.MaterialBuilders; -using LoaderCalculator.Data.Matrix; -using LoaderCalculator.Data.Ndms; -using LoaderCalculator.Data.ResultData; -using LoaderCalculator.Data.SourceData; -using StructureHelper.Models.Materials; -using StructureHelper.Services; -using StructureHelper.Services.Primitives; -using StructureHelper.UnitSystem; -using StructureHelper.UnitSystem.Systems; -using StructureHelperCommon.Infrastructures.Enums; -using StructureHelperCommon.Models; -using StructureHelperCommon.Services.Units; -using StructureHelperLogics.Models.Calculations.CalculationProperties; -using StructureHelperLogics.Models.CrossSections; -using StructureHelperLogics.Models.Materials; -using StructureHelperLogics.NdmCalculations.Triangulations; -using StructureHelperLogics.Services; -using StructureHelperLogics.Services.NdmCalculations; -using StructureHelperLogics.Services.NdmPrimitives; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Threading; - -namespace StructureHelper.Windows.MainWindow -{ - public class CrossSectionModel - { - private ITriangulatePrimitiveLogic triangulateLogic; - - public ICrossSection Section { get; private set; } - private IPrimitiveRepository primitiveRepository; - public IHeadMaterialRepository HeadMaterialRepository { get; } - public List HeadMaterials { get; } - private CalculationService calculationService; - private UnitSystemService unitSystemService; - - public IPrimitiveRepository PrimitiveRepository => primitiveRepository; - - public ICalculationProperty CalculationProperty { get; private set; } - - public CrossSectionModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService) - { - this.primitiveRepository = primitiveRepository; - this.calculationService = calculationService; - this.unitSystemService = unitSystemService; - - Section = new CrossSection(); - CalculationProperty = new CalculationProperty(); - HeadMaterials = new List(); - HeadMaterialRepository = new HeadMaterialRepository(this); - } - - public IEnumerable GetNdms(ICalculationProperty calculationProperty) - { - var ndmPrimitives = Section.SectionRepository.Primitives; - triangulateLogic = new TriangulatePrimitiveLogic() - { - Primitives = ndmPrimitives, - LimitState = calculationProperty.LimitState, - CalcTerm = calculationProperty.CalcTerm - }; - return triangulateLogic.GetNdms(); - ////Настройки триангуляции, пока опции могут быть только такие - //ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm }; - - ////Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию) - //return ndmPrimitives.SelectMany(x => x.GetNdms(options)); - } - } -} diff --git a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml.cs b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml.cs index e94de2f..0bd5b2a 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionView.xaml.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionView.xaml.cs @@ -3,22 +3,27 @@ using System.Windows.Controls; using StructureHelper.Infrastructure.UI.DataContexts; using StructureHelper.Services; using StructureHelper.Services.Primitives; +using StructureHelperLogics.Models.CrossSections; namespace StructureHelper.Windows.MainWindow { public partial class CrossSectionView : Window { private CrossSectionViewModel viewModel; - public IPrimitiveRepository PrimitiveRepository { get; } + //public IPrimitiveRepository PrimitiveRepository { get; } - public CrossSectionView(IPrimitiveRepository primitiveRepository, CrossSectionViewModel viewModel) + public CrossSectionView(CrossSectionViewModel viewModel) { - PrimitiveRepository = primitiveRepository; this.viewModel = viewModel; DataContext = this.viewModel; InitializeComponent(); } + public CrossSectionView(ICrossSection crossSection) : this(new CrossSectionViewModel(crossSection)) + { + + } + private void ContentPresenter_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { var contentPresenter = sender as ContentPresenter; diff --git a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs index 51a5d3b..e381169 100644 --- a/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs +++ b/StructureHelper/Windows/MainWindow/CrossSectionViewModel.cs @@ -27,8 +27,8 @@ namespace StructureHelper.Windows.MainWindow { public class CrossSectionViewModel : ViewModelBase { - private ICrossSection section; - private ICrossSectionRepository repository => section.SectionRepository; + public ICrossSection Section { get; set; } + private ICrossSectionRepository repository => Section.SectionRepository; private ITriangulatePrimitiveLogic triangulateLogic; @@ -43,15 +43,13 @@ namespace StructureHelper.Windows.MainWindow public PrimitiveViewModelLogic PrimitiveLogic { get; } public HelpLogic HelpLogic => new HelpLogic(); - private CrossSectionModel Model { get; } - public ObservableCollection HeadMaterials { get { var collection = new ObservableCollection(); - foreach (var obj in Model.Section.SectionRepository.HeadMaterials) + foreach (var obj in Section.SectionRepository.HeadMaterials) { collection.Add(obj); } @@ -125,15 +123,14 @@ namespace StructureHelper.Windows.MainWindow private RelayCommand showVisualProperty; private RelayCommand selectPrimitive; - public CrossSectionViewModel(CrossSectionModel model) + public CrossSectionViewModel(ICrossSection section) { + Section = section; VisualProperty = new CrossSectionVisualPropertyVM() { ScaleValue = 500d, ParentViewModel = this }; - Model = model; - section = model.Section; CombinationsLogic = new ActionsViewModel(repository); MaterialsLogic = new MaterialsViewModel(repository); MaterialsLogic.AfterItemsEdit += AfterMaterialEdit; @@ -143,6 +140,7 @@ namespace StructureHelper.Windows.MainWindow Width = VisualProperty.Width, Height = VisualProperty.Height }; + PrimitiveLogic.Refresh(); LeftButtonUp = new RelayCommand(o => { diff --git a/StructureHelperCommon/Models/Analyses/AnalysisUpdateStrategy.cs b/StructureHelperCommon/Models/Analyses/AnalysisUpdateStrategy.cs new file mode 100644 index 0000000..dd7ee82 --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/AnalysisUpdateStrategy.cs @@ -0,0 +1,21 @@ +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.Analyses +{ + public class AnalysisUpdateStrategy : IUpdateStrategy + { + public void Update(IAnalysis targetObject, IAnalysis sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject, "Analysis Properties"); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Name = sourceObject.Name; + targetObject.Tags = sourceObject.Tags; + } + } +} diff --git a/StructureHelperCommon/Models/Analyses/IAnalysis.cs b/StructureHelperCommon/Models/Analyses/IAnalysis.cs new file mode 100644 index 0000000..7161577 --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/IAnalysis.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Analyses +{ + public interface IAnalysis : ISaveable + { + string Name { get; set; } + string Tags { get; set; } + IVersionProcessor VersionProcessor { get;} + } +} diff --git a/StructureHelperCommon/Models/Analyses/IVersion.cs b/StructureHelperCommon/Models/Analyses/IVersion.cs new file mode 100644 index 0000000..d6328ce --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/IVersion.cs @@ -0,0 +1,15 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Analyses +{ + public interface IVersion + { + DateTime DateTime { get; } + ISaveable Item { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Analyses/IVersionProcessor.cs b/StructureHelperCommon/Models/Analyses/IVersionProcessor.cs new file mode 100644 index 0000000..8a19534 --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/IVersionProcessor.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Analyses +{ + public interface IVersionProcessor : ISaveable + { + void AddVersion(ISaveable newItem); + List Versions { get; } + IVersion GetCurrentVersion(); + } +} diff --git a/StructureHelperCommon/Models/Analyses/Version.cs b/StructureHelperCommon/Models/Analyses/Version.cs new file mode 100644 index 0000000..809c529 --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/Version.cs @@ -0,0 +1,16 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Analyses +{ + public class Version : IVersion + { + public DateTime DateTime { get; set; } + + public ISaveable Item { get; set; } + } +} diff --git a/StructureHelperCommon/Models/Analyses/VersionProcessor.cs b/StructureHelperCommon/Models/Analyses/VersionProcessor.cs new file mode 100644 index 0000000..251cbcb --- /dev/null +++ b/StructureHelperCommon/Models/Analyses/VersionProcessor.cs @@ -0,0 +1,48 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperCommon.Models.Analyses +{ + public class VersionProcessor : IVersionProcessor + { + public List Versions { get; } + + public Guid Id { get; } + + public VersionProcessor(Guid id) + { + + Id = id; + Versions = new(); + } + public VersionProcessor() : this (new Guid()) + { + + } + + private void AddVersion(IVersion version) + { + Versions.Add(version); + } + + public void AddVersion(ISaveable newItem) + { + var version = new Version() + { + DateTime = DateTime.Now, + Item = newItem + }; + AddVersion(version); + } + + + public IVersion GetCurrentVersion() + { + return Versions[^1]; + } + } +} diff --git a/StructureHelperCommon/Models/Forces/Logics/HasForceCombinationUpdateStrategy.cs b/StructureHelperCommon/Models/Forces/Logics/HasForceCombinationUpdateStrategy.cs new file mode 100644 index 0000000..0622722 --- /dev/null +++ b/StructureHelperCommon/Models/Forces/Logics/HasForceCombinationUpdateStrategy.cs @@ -0,0 +1,21 @@ +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.Forces.Logics +{ + public class HasForceCombinationUpdateStrategy : IUpdateStrategy + { + public void Update(IHasForceCombinations targetObject, IHasForceCombinations sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject, "Interface IHasForceCombination"); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.ForceActions.Clear(); + targetObject.ForceActions.AddRange(sourceObject.ForceActions); + } + } +} diff --git a/StructureHelperCommon/Services/CheckObject.cs b/StructureHelperCommon/Services/CheckObject.cs index d012741..db78295 100644 --- a/StructureHelperCommon/Services/CheckObject.cs +++ b/StructureHelperCommon/Services/CheckObject.cs @@ -24,14 +24,20 @@ namespace StructureHelperCommon.Services /// public static void CompareTypes(object targetObject, object sourceObject) { - IsNull(targetObject, "target object"); - IsNull(sourceObject, "source object"); + IsNull(targetObject, sourceObject); if (targetObject.GetType() != sourceObject.GetType()) { throw new StructureHelperException ($"{ErrorStrings.DataIsInCorrect}: target type is {targetObject.GetType()},\n does not coinside with source type {sourceObject.GetType()}"); } } + + public static void IsNull(object targetObject, object sourceObject, string senderName = "") + { + IsNull(targetObject,$"{senderName} target object"); + IsNull(sourceObject, $"{senderName} source object"); + } + public static void IsNull(object item, string message = "") { if (item is null) diff --git a/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs new file mode 100644 index 0000000..0d27cb7 --- /dev/null +++ b/StructureHelperLogics/Models/Analyses/CrossSectionNdmAnalysis.cs @@ -0,0 +1,35 @@ +using StructureHelperCommon.Models.Analyses; +using StructureHelperLogics.Models.CrossSections; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogic.Models.Analyses +{ + public class CrossSectionNdmAnalysis : IAnalysis + { + public Guid Id { get; private set; } + public string Name { get; set; } + public string Tags { get; set; } + public IVersionProcessor VersionProcessor { get; private set; } + + public CrossSectionNdmAnalysis(Guid Id, IVersionProcessor versionProcessor) + { + this.Id = Id; + VersionProcessor = versionProcessor; + } + + public CrossSectionNdmAnalysis() : this(new Guid(), new VersionProcessor()) + { + CrossSection crossSection = new CrossSection(); + VersionProcessor.AddVersion(crossSection); + } + + public object Clone() + { + throw new NotImplementedException(); + } + } +} diff --git a/StructureHelperLogics/Models/CrossSections/CrossSection.cs b/StructureHelperLogics/Models/CrossSections/CrossSection.cs index 5ecbe14..adcafa2 100644 --- a/StructureHelperLogics/Models/CrossSections/CrossSection.cs +++ b/StructureHelperLogics/Models/CrossSections/CrossSection.cs @@ -10,9 +10,16 @@ namespace StructureHelperLogics.Models.CrossSections { public ICrossSectionRepository SectionRepository { get; private set; } + public Guid Id { get; private set; } + public CrossSection() { SectionRepository = new CrossSectionRepository(); } + + public object Clone() + { + throw new NotImplementedException(); + } } } diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs new file mode 100644 index 0000000..d4dd133 --- /dev/null +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionRepositoryUpdateStrategy.cs @@ -0,0 +1,24 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; +using StructureHelperCommon.Services; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.CrossSections +{ + internal class CrossSectionRepositoryUpdateStrategy : IUpdateStrategy + { + + + public void Update(ICrossSectionRepository targetObject, ICrossSectionRepository sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + + } + } +} diff --git a/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs new file mode 100644 index 0000000..bfbd28f --- /dev/null +++ b/StructureHelperLogics/Models/CrossSections/CrossSectionUpdateStrategy.cs @@ -0,0 +1,28 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; +using StructureHelperLogics.NdmCalculations.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.Models.CrossSections +{ + public class CrossSectionUpdateStrategy : IUpdateStrategy + { + + public CrossSectionUpdateStrategy() + { + + } + + public void Update(ICrossSection targetObject, ICrossSection sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + + + } + } +} diff --git a/StructureHelperLogics/Models/CrossSections/ICrossSection.cs b/StructureHelperLogics/Models/CrossSections/ICrossSection.cs index 2b6a597..b06e613 100644 --- a/StructureHelperLogics/Models/CrossSections/ICrossSection.cs +++ b/StructureHelperLogics/Models/CrossSections/ICrossSection.cs @@ -1,4 +1,5 @@ -using System; +using StructureHelperCommon.Infrastructures.Interfaces; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.CrossSections { - public interface ICrossSection + public interface ICrossSection : ISaveable, ICloneable { ICrossSectionRepository SectionRepository { get; } } diff --git a/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs b/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs index 67db19d..bed4a93 100644 --- a/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs +++ b/StructureHelperLogics/Models/CrossSections/ICrossSectionRepository.cs @@ -1,4 +1,5 @@ using StructureHelper.Models.Materials; +using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Forces; using StructureHelperLogics.Models.Materials; @@ -13,7 +14,7 @@ using System.Threading.Tasks; namespace StructureHelperLogics.Models.CrossSections { - public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives + public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives, IHasForceCombinations { List ForceActions { get; } List CalculatorsList { get; } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs index ffbbd35..a20a775 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/ForceCalculatorInputDataUpdateStrategy.cs @@ -1,7 +1,10 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators; +using StructureHelperCommon.Models.Forces.Logics; using StructureHelperCommon.Models.Sections; using StructureHelperCommon.Services; +using StructureHelperLogics.NdmCalculations.Primitives; +using StructureHelperLogics.NdmCalculations.Primitives.Logics; using System; using System.Collections.Generic; using System.Linq; @@ -12,19 +15,34 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces { public class ForceCalculatorInputDataUpdateStrategy : IUpdateStrategy { + private IUpdateStrategy primitivesUpdateStrategy; + private IUpdateStrategy forceCombinationUpdateStrategy; private IUpdateStrategy accuracyUpdateStrategy; private IUpdateStrategy compressedMemberUpdateStrategy; - public ForceCalculatorInputDataUpdateStrategy(IUpdateStrategy accuracyUpdateStrategy, IUpdateStrategy compressedMemberUpdateStrategy) + public ForceCalculatorInputDataUpdateStrategy(IUpdateStrategy primitivesUpdateStrategy, + IUpdateStrategy forceCombinationUpdateStrategy, + IUpdateStrategy accuracyUpdateStrategy, + IUpdateStrategy compressedMemberUpdateStrategy) { + this.primitivesUpdateStrategy = primitivesUpdateStrategy; + this.forceCombinationUpdateStrategy = forceCombinationUpdateStrategy; this.accuracyUpdateStrategy = accuracyUpdateStrategy; this.compressedMemberUpdateStrategy = compressedMemberUpdateStrategy; } - public ForceCalculatorInputDataUpdateStrategy() : this(new AccuracyUpdateStrategy(), new CompressedMemberUpdateStrategy()) { } + public ForceCalculatorInputDataUpdateStrategy() : + this( + new HasPrimitivesUpdateStrategy(), + new HasForceCombinationUpdateStrategy(), + new AccuracyUpdateStrategy(), + new CompressedMemberUpdateStrategy() + ) + { + } public void Update(ForceInputData targetObject, ForceInputData sourceObject) { + CheckObject.IsNull(targetObject, sourceObject, "Force calculator input data"); if (ReferenceEquals(targetObject, sourceObject)) { return; } - CheckObject.CompareTypes(targetObject, sourceObject); targetObject.Accuracy ??= new Accuracy(); accuracyUpdateStrategy.Update(targetObject.Accuracy, sourceObject.Accuracy); targetObject.CompressedMember ??= new CompressedMember(); @@ -33,10 +51,8 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces targetObject.LimitStatesList.AddRange(sourceObject.LimitStatesList); targetObject.CalcTermsList.Clear(); targetObject.CalcTermsList.AddRange(sourceObject.CalcTermsList); - targetObject.Primitives.Clear(); - targetObject.Primitives.AddRange(sourceObject.Primitives); - targetObject.ForceActions.Clear(); - targetObject.ForceActions.AddRange(sourceObject.ForceActions); + primitivesUpdateStrategy.Update(targetObject, sourceObject); + forceCombinationUpdateStrategy.Update(targetObject, sourceObject); } } } diff --git a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs index 3176ad0..126bad8 100644 --- a/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs +++ b/StructureHelperLogics/NdmCalculations/Analyses/ByForces/Logics/ForceCalculatorUpdateStrategy.cs @@ -1,6 +1,7 @@ using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Models.Calculators; using StructureHelperCommon.Models.Sections; +using StructureHelperCommon.Services; namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics { @@ -14,6 +15,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics public ForceCalculatorUpdateStrategy() : this(new ForceCalculatorInputDataUpdateStrategy()) { } public void Update(ForceCalculator targetObject, ForceCalculator sourceObject) { + CheckObject.IsNull(targetObject, sourceObject); if (ReferenceEquals(targetObject, sourceObject)) { return; } targetObject.Name = sourceObject.Name; targetObject.InputData ??= new ForceInputData(); diff --git a/StructureHelperLogics/NdmCalculations/Cracking/ILengthBetweenCracksLogic.cs b/StructureHelperLogics/NdmCalculations/Cracking/ILengthBetweenCracksLogic.cs index b3eec4a..0891ebe 100644 --- a/StructureHelperLogics/NdmCalculations/Cracking/ILengthBetweenCracksLogic.cs +++ b/StructureHelperLogics/NdmCalculations/Cracking/ILengthBetweenCracksLogic.cs @@ -14,7 +14,6 @@ namespace StructureHelperLogics.NdmCalculations.Cracking /// public interface ILengthBetweenCracksLogic : ILogic { -#error //to do change to primitive collection since it is required to gain difference rebar strain and concrete strain /// /// Full collection of ndm parts of cross-section diff --git a/StructureHelperLogics/NdmCalculations/Primitives/Logics/HasPrimitivesUpdateStrategy.cs b/StructureHelperLogics/NdmCalculations/Primitives/Logics/HasPrimitivesUpdateStrategy.cs new file mode 100644 index 0000000..6904802 --- /dev/null +++ b/StructureHelperLogics/NdmCalculations/Primitives/Logics/HasPrimitivesUpdateStrategy.cs @@ -0,0 +1,21 @@ +using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Services; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StructureHelperLogics.NdmCalculations.Primitives.Logics +{ + public class HasPrimitivesUpdateStrategy : IUpdateStrategy + { + public void Update(IHasPrimitives targetObject, IHasPrimitives sourceObject) + { + CheckObject.IsNull(targetObject, sourceObject); + if (ReferenceEquals(targetObject, sourceObject)) { return; } + targetObject.Primitives.Clear(); + targetObject.Primitives.AddRange(sourceObject.Primitives); + } + } +}