From 3e0e51d0c9a76b9ce9b061aa5e09405ed5931a25 Mon Sep 17 00:00:00 2001 From: Evgeny Redikultsev Date: Sun, 9 Jul 2023 19:46:36 +0500 Subject: [PATCH] UpdateStrategy for Actions was added --- .../Services/Settings/GlobalRepository.cs | 11 +++ .../Forces/ForceCombinationByFactorView.xaml | 4 +- .../ForceCombinationByFactorView.xaml.cs | 1 + .../Windows/Forces/ForceCombinationView.xaml | 4 +- .../Forces/ForceCombinationView.xaml.cs | 6 +- .../Windows/MainWindow/MainViewModel.cs | 4 ++ .../Materials/HeadMaterialsView.xaml | 15 +--- .../Materials/HeadMaterialsView.xaml.cs | 32 --------- .../ViewModels/Forces/ActionsViewModel.cs | 18 ++++- .../ViewModels/Forces/ForceActionVMBase.cs | 2 +- .../Exceptions/ErrorCommonProcessor.cs | 17 +++++ .../Interfaces/IUpdateStrategy.cs | 9 +++ .../Models/Forces/DesignForcePair.cs | 13 +++- .../Models/Forces/ForceCombinationByFactor.cs | 15 ++-- .../Models/Forces/ForceCombinationList.cs | 22 +++--- .../Models/Forces/ForceTuple.cs | 9 ++- .../Models/Forces/IAction.cs | 5 +- .../Models/Forces/IForceAction.cs | 15 +++- .../Forces/Logics/ActionUpdateStrategy.cs | 29 ++++++++ .../Logics/FactorCombinationUpdateStrategy.cs | 22 ++++++ .../Logics/ForceActionUpdateStrategy.cs | 48 +++++++++++++ .../ForceCombinationListUpdateStrategy.cs | 24 +++++++ .../Forces/Logics/ForcePairUpdateStrategy.cs | 24 +++++++ .../Forces/Logics/ForceTupleUpdateStrategy.cs | 27 ++++++++ .../Models/Shapes/IPoint2D.cs | 9 +-- .../Shapes/Logics/PointUpdateStrategy.cs | 20 ++++++ .../Models/Shapes/Point2D.cs | 21 +++++- StructureHelperCommon/Services/CheckObject.cs | 38 +++++++++++ .../Services/Forces/ForceActionService.cs | 8 --- .../Logics/MaterialUpdateStrategy.cs | 68 ++++++------------- 30 files changed, 402 insertions(+), 138 deletions(-) create mode 100644 StructureHelperCommon/Infrastructures/Exceptions/ErrorCommonProcessor.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/ActionUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/FactorCombinationUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/ForceActionUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/ForceCombinationListUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/ForcePairUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Forces/Logics/ForceTupleUpdateStrategy.cs create mode 100644 StructureHelperCommon/Models/Shapes/Logics/PointUpdateStrategy.cs create mode 100644 StructureHelperCommon/Services/CheckObject.cs diff --git a/StructureHelper/Services/Settings/GlobalRepository.cs b/StructureHelper/Services/Settings/GlobalRepository.cs index b0ac354..6f4cbdb 100644 --- a/StructureHelper/Services/Settings/GlobalRepository.cs +++ b/StructureHelper/Services/Settings/GlobalRepository.cs @@ -1,5 +1,6 @@ using StructureHelper.Models.Materials; using StructureHelperCommon.Infrastructures.Interfaces; +using StructureHelperCommon.Models.Forces; using StructureHelperCommon.Models.Repositories; using StructureHelperLogics.Models.Materials; using System; @@ -13,6 +14,8 @@ namespace StructureHelper.Services.Settings internal static class GlobalRepository { private static IDataRepository materials; + private static IDataRepository actions; + public static IDataRepository Materials { get @@ -21,5 +24,13 @@ namespace StructureHelper.Services.Settings return materials; } } + public static IDataRepository Actions + { + get + { + actions ??= new ListRepository(new ActionUpdateStrategy()); + return actions; + } + } } } diff --git a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml index df27e40..f6cdd63 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml @@ -7,11 +7,12 @@ xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces" d:DataContext="{d:DesignInstance vm:ForceCombinationByFactorVM}" mc:Ignorable="d" - Title="Force Combination By Factor" Height="250" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> + Title="Force Combination By Factor" Height="290" Width="350" MinHeight="290" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"> + @@ -49,5 +50,6 @@ + diff --git a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml.cs b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml.cs index 798ced7..0b1826b 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationByFactorView.xaml.cs @@ -27,6 +27,7 @@ namespace StructureHelper.Windows.Forces InitializeComponent(); viewModel = new ForceCombinationByFactorVM(forceCombination); DataContext = viewModel; + viewModel.ParentWindow = this; } } } diff --git a/StructureHelper/Windows/Forces/ForceCombinationView.xaml b/StructureHelper/Windows/Forces/ForceCombinationView.xaml index f914571..7dc2efd 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationView.xaml +++ b/StructureHelper/Windows/Forces/ForceCombinationView.xaml @@ -7,16 +7,18 @@ xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces" d:DataContext="{d:DesignInstance vm:ForceCombinationViewModel}" mc:Ignorable="d" - Title="Force Combination" Height="250" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen"> + Title="Force Combination" Height="350" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen"> + + diff --git a/StructureHelper/Windows/Forces/ForceCombinationView.xaml.cs b/StructureHelper/Windows/Forces/ForceCombinationView.xaml.cs index b0d0011..f4917d1 100644 --- a/StructureHelper/Windows/Forces/ForceCombinationView.xaml.cs +++ b/StructureHelper/Windows/Forces/ForceCombinationView.xaml.cs @@ -27,13 +27,11 @@ namespace StructureHelper.Windows.Forces viewModel = _viewModel; DataContext = viewModel; InitializeComponent(); + viewModel.ParentWindow = this; } - public ForceCombinationView(IForceCombinationList combinationList) + public ForceCombinationView(IForceCombinationList combinationList) : this(new ForceCombinationViewModel(combinationList)) { - viewModel = new ForceCombinationViewModel(combinationList); - DataContext = viewModel; - InitializeComponent(); } } } diff --git a/StructureHelper/Windows/MainWindow/MainViewModel.cs b/StructureHelper/Windows/MainWindow/MainViewModel.cs index 4138bf8..e3ad7bd 100644 --- a/StructureHelper/Windows/MainWindow/MainViewModel.cs +++ b/StructureHelper/Windows/MainWindow/MainViewModel.cs @@ -407,6 +407,10 @@ namespace StructureHelper.Windows.MainWindow { GlobalRepository.Materials.Create(item); } + foreach (var item in newRepository.ForceActions) + { + GlobalRepository.Actions.Create(item); + } return primitives; } return new List(); diff --git a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml index ca0c51f..7e57013 100644 --- a/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml +++ b/StructureHelper/Windows/MainWindow/Materials/HeadMaterialsView.xaml @@ -15,13 +15,12 @@ - - + @@ -42,19 +41,7 @@ -