Add version processor window

This commit is contained in:
Evgeny Redikultsev
2024-11-23 20:42:21 +05:00
parent 6ec68c6f49
commit 32243f5448
50 changed files with 1018 additions and 158 deletions

View File

@@ -11,7 +11,7 @@ namespace DataAccess.DTOs
public class CompressedMemberDTO : ICompressedMember public class CompressedMemberDTO : ICompressedMember
{ {
[JsonProperty("Id")] [JsonProperty("Id")]
public Guid Id { get; set; } public Guid Id { get; set; } = Guid.NewGuid();
[JsonProperty("Bucling")] [JsonProperty("Bucling")]
public bool Buckling { get; set; } public bool Buckling { get; set; }
[JsonProperty("GeometryLength")] [JsonProperty("GeometryLength")]

View File

@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Media;
namespace DataAccess.DTOs namespace DataAccess.DTOs
{ {
@@ -21,6 +22,10 @@ namespace DataAccess.DTOs
public string Tags { get; set; } public string Tags { get; set; }
[JsonProperty("VersionProcessor")] [JsonProperty("VersionProcessor")]
public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO(); public IVersionProcessor VersionProcessor { get; set; } = new VersionProcessorDTO();
[JsonProperty("Comment")]
public string Comment { get; set; } = string.Empty;
[JsonProperty("Color")]
public Color Color { get; set; } = new();
public object Clone() public object Clone()
{ {

View File

@@ -17,7 +17,7 @@ namespace DataAccess.DTOs
public class ForceCalculatorInputDataDTO : IForceCalculatorInputData public class ForceCalculatorInputDataDTO : IForceCalculatorInputData
{ {
[JsonProperty("Id")] [JsonProperty("Id")]
public Guid Id { get; set; } public Guid Id { get; set; } = Guid.NewGuid();
[JsonProperty("ForceActions")] [JsonProperty("ForceActions")]
public List<IForceAction> ForceActions { get; set; } = new(); public List<IForceAction> ForceActions { get; set; } = new();
[JsonProperty("Primitives")] [JsonProperty("Primitives")]

View File

@@ -408,7 +408,26 @@
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="RunAnalisis"> <DataTemplate x:Key="CopyAnalysis">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Ellipse Width="16" Height="16" Fill="LightGray" Stroke="Black" StrokeThickness="1" Margin="12,12,0,0"/>
<Ellipse Width="18" Height="18" Fill="White" Stroke="Black" StrokeThickness="1" Margin="3,3,0,0"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="AnalysisVersions">
<Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children>
<Ellipse Width="10" Height="10" Fill="LightGray" Stroke="Black" StrokeThickness="1" Margin="18,18,0,0"/>
<Ellipse Width="12" Height="12" Fill="LightGray" Stroke="Black" StrokeThickness="1" Margin="12,12,0,0"/>
<Ellipse Width="14" Height="14" Fill="White" Stroke="Black" StrokeThickness="1" Margin="5,5,0,0"/>
</Canvas.Children>
</Canvas>
</DataTemplate>
<DataTemplate x:Key="RunAnalysis">
<Canvas Style="{DynamicResource ButtonResultCanvas}"> <Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children> <Canvas.Children>
<Path Margin="4" Data="M 4 2 l 12 10 l -12 10 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/> <Path Margin="4" Data="M 4 2 l 12 10 l -12 10 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
@@ -416,7 +435,7 @@
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="EditAnalisis"> <DataTemplate x:Key="EditAnalysis">
<Canvas Style="{DynamicResource ButtonResultCanvas}"> <Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children> <Canvas.Children>
<Path Margin="4" Data="M 2 22 l 4 -6 l 15 -16 l 4 4 l -15 14 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/> <Path Margin="4" Data="M 2 22 l 4 -6 l 15 -16 l 4 4 l -15 14 z" Fill="DarkGray" Stroke="Black" StrokeThickness="1"/>
@@ -424,7 +443,7 @@
</Canvas> </Canvas>
</DataTemplate> </DataTemplate>
<DataTemplate x:Key="DeleteAnalisis"> <DataTemplate x:Key="DeleteAnalysis">
<Canvas Style="{DynamicResource ButtonResultCanvas}"> <Canvas Style="{DynamicResource ButtonResultCanvas}">
<Canvas.Children> <Canvas.Children>
<Line X1="4" Y1="4" X2="26" Y2="26" Stroke="Black" StrokeThickness="2"/> <Line X1="4" Y1="4" X2="26" Y2="26" Stroke="Black" StrokeThickness="2"/>

View File

@@ -1,11 +1,13 @@
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows;
using StructureHelper.Properties; using StructureHelper.Properties;
namespace StructureHelper.Infrastructure namespace StructureHelper.Infrastructure
{ {
public class ViewModelBase : INotifyPropertyChanged public class ViewModelBase : INotifyPropertyChanged
{ {
public Window OwnerWindow { get; set; }
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator] [NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged<T>(T value, T prop, [CallerMemberName] string propertyName = null) protected virtual void OnPropertyChanged<T>(T value, T prop, [CallerMemberName] string propertyName = null)

View File

@@ -66,6 +66,9 @@
<Compile Update="Windows\MainWindow\Analyses\AnalysisView.xaml.cs"> <Compile Update="Windows\MainWindow\Analyses\AnalysisView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\MainWindow\Analyses\VersionsView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs"> <Compile Update="Windows\MainWindow\Materials\HeadMaterialView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@@ -167,6 +170,9 @@
<Page Update="Windows\MainWindow\Analyses\AnalysisView.xaml"> <Page Update="Windows\MainWindow\Analyses\AnalysisView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\MainWindow\Analyses\VersionsView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml"> <Page Update="Windows\MainWindow\Materials\HeadMaterialView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@@ -34,14 +34,14 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private int stepCount; private int stepCount;
private static GeometryNames GeometryNames => ProgramSetting.GeometryNames; private static GeometryNames GeometryNames => ProgramSetting.GeometryNames;
public LimitCurveInputData InputData { get; set; } public LimitCurvesCalculatorInputData InputData { get; set; }
public int StepCount { get => stepCount; set => stepCount = value; } public int StepCount { get => stepCount; set => stepCount = value; }
public Action<int> SetProgress { get; set; } public Action<int> SetProgress { get; set; }
public bool Result { get; set; } public bool Result { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }
public InteractionDiagramLogic(LimitCurveInputData inputData) public InteractionDiagramLogic(LimitCurvesCalculatorInputData inputData)
{ {
InputData = inputData; InputData = inputData;
stepCount = InputData.PointCount; stepCount = InputData.PointCount;

View File

@@ -24,11 +24,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ {
public class LimitCurveDataViewModel : OkCancelViewModelBase, IDataErrorInfo public class LimitCurveDataViewModel : OkCancelViewModelBase, IDataErrorInfo
{ {
private LimitCurveInputData inputData; private LimitCurvesCalculatorInputData inputData;
//public SurroundDataViewModel SurroundDataViewModel { get; private set; } //public SurroundDataViewModel SurroundDataViewModel { get; private set; }
public SurroundData SurroundData { get => inputData.SurroundData; } public ISurroundData SurroundData { get => inputData.SurroundData; }
public SelectPrimitivesSourceTarget PrimitiveSeries { get; private set; } public SelectPrimitivesSourceTarget PrimitiveSeries { get; private set; }
public SelectItemsVM<PredicateEntry> PredicateItems { get; private set; } public SelectItemsVM<PredicateEntry> PredicateItems { get; private set; }
public SelectItemsVM<LimitStateEntity> LimitStateItems { get; private set; } public SelectItemsVM<LimitStateEntity> LimitStateItems { get; private set; }
@@ -52,7 +52,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public IEnumerable<INdmPrimitive> AllowedPrimitives { get; set; } public IEnumerable<INdmPrimitive> AllowedPrimitives { get; set; }
public LimitCurveDataViewModel(LimitCurveInputData inputData, IEnumerable<INdmPrimitive> allowedPrimitives) public LimitCurveDataViewModel(LimitCurvesCalculatorInputData inputData, IEnumerable<INdmPrimitive> allowedPrimitives)
{ {
this.inputData = inputData; this.inputData = inputData;
AllowedPrimitives = allowedPrimitives; AllowedPrimitives = allowedPrimitives;

View File

@@ -140,13 +140,13 @@
<StatusBar Grid.Row="1"> <StatusBar Grid.Row="1">
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Valid result: "/> <TextBlock Text="Valid result(s): "/>
<TextBlock Text="{Binding ValidResultCount}"/> <TextBlock Text="{Binding ValidResultCount}"/>
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Invalid result: "/> <TextBlock Text="Invalid result(s): "/>
<TextBlock Text="{Binding InvalidResultCount}"/> <TextBlock Text="{Binding InvalidResultCount}"/>
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>

View File

@@ -89,7 +89,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private void ShowInteractionDiagram() private void ShowInteractionDiagram()
{ {
var inputData = new LimitCurveInputData(ndmPrimitives); var inputData = new LimitCurvesCalculatorInputData(ndmPrimitives);
var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives); var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives);
//vm.LimitStateItems.SetIsSelected(); //vm.LimitStateItems.SetIsSelected();
//vm.CalcTermITems.SetIsSelected(); //vm.CalcTermITems.SetIsSelected();
@@ -106,7 +106,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
ShowInteractionDiagramByInputData(inputData); ShowInteractionDiagramByInputData(inputData);
} }
private void ShowInteractionDiagramByInputData(LimitCurveInputData inputData) private void ShowInteractionDiagramByInputData(LimitCurvesCalculatorInputData inputData)
{ {
interactionDiagramLogic = new(inputData); interactionDiagramLogic = new(inputData);
showProgressLogic = new(interactionDiagramLogic) showProgressLogic = new(interactionDiagramLogic)

View File

@@ -23,7 +23,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
const string MomentUnitString = "kNm"; const string MomentUnitString = "kNm";
static IConvertUnitLogic operationLogic = new ConvertUnitLogic(); static IConvertUnitLogic operationLogic = new ConvertUnitLogic();
static IGetUnitLogic unitLogic = new GetUnitLogic(); static IGetUnitLogic unitLogic = new GetUnitLogic();
public SurroundData SurroundData public ISurroundData SurroundData
{ {
get => surroundData; set get => surroundData; set
{ {
@@ -50,7 +50,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private static IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString); private static IUnit unitForce = unitLogic.GetUnit(UnitTypes.Force, ForceUnitString);
private static IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment, MomentUnitString); private static IUnit unitMoment = unitLogic.GetUnit(UnitTypes.Moment, MomentUnitString);
private SurroundData surroundData; private ISurroundData surroundData;
public IValueConverter ForceConverter { get => new Force(); } public IValueConverter ForceConverter { get => new Force(); }
public IValueConverter MomentConverter { get => new Moment();} public IValueConverter MomentConverter { get => new Moment();}
@@ -183,7 +183,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
} }
} }
public SurroundDataViewModel(SurroundData surroundData) public SurroundDataViewModel(ISurroundData surroundData)
{ {
this.SurroundData = surroundData; this.SurroundData = surroundData;
Logics = new(); Logics = new();

View File

@@ -22,6 +22,8 @@ namespace StructureHelper.Windows.MainWindow
private RelayCommand? runCommand; private RelayCommand? runCommand;
private RelayCommand? editCommand; private RelayCommand? editCommand;
private RelayCommand? deleteCommand; private RelayCommand? deleteCommand;
private RelayCommand? copyCommand;
private RelayCommand versionsCommand;
public IVisualAnalysis? SelectedAnalysis { get; set; } public IVisualAnalysis? SelectedAnalysis { get; set; }
@@ -74,6 +76,56 @@ namespace StructureHelper.Windows.MainWindow
} }
} }
public RelayCommand CopyCommand
{
get
{
return copyCommand ??= new RelayCommand(obj =>
{
CopyCurrentAnalysis();
},
b => SelectedAnalysis is not null);
}
}
public RelayCommand VersionsCommand
{
get
{
return versionsCommand ??= new RelayCommand(obj =>
{
ShowVersions();
},
b => SelectedAnalysis is not null);
}
}
private void ShowVersions()
{
if (SelectedAnalysis is null) { return; }
try
{
VersionsViewModel viewModel = new(SelectedAnalysis.Analysis.VersionProcessor);
var wnd = new VersionsView(viewModel);
wnd.ShowDialog();
}
catch (Exception ex)
{
// to do
}
}
private void CopyCurrentAnalysis()
{
if (SelectedAnalysis is not null)
{
var newAnalysis = SelectedAnalysis.Clone() as IVisualAnalysis;
newAnalysis.Analysis.Name += " - copy";
ProgramSetting.CurrentProject.VisualAnalyses.Add(newAnalysis);
Refresh();
SelectedAnalysis = newAnalysis;
}
}
public AnalysesLogic() public AnalysesLogic()
{ {

View File

@@ -0,0 +1,49 @@
<Window x:Class="StructureHelper.Windows.MainWindow.Analyses.VersionsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow.Analyses"
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
d:DataContext="{d:DesignInstance local:VersionsViewModel}"
mc:Ignorable="d"
Title="VersionsView" Height="250" Width="400" MinHeight="250" MinWidth="400" MaxHeight="800" MaxWidth="1000" WindowStartupLocation="CenterScreen">
<Grid>
<DockPanel>
<ToolBarTray DockPanel.Dock="Top">
<ToolBar>
<Button Style="{StaticResource ToolButton}"
Command="{Binding AddNewVersionCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Fix current version"
IconContent="{StaticResource CopyAnalysis}"
DescriptionText="Create new version of analysis from selected one"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource CopyAnalysis}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton}"
Command="{Binding ReturnToVersionCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Restore to selected version"
IconContent="{StaticResource DeleteAnalysis}"
DescriptionText="Removes all versions which are younger than selected one"/>
</Button.ToolTip>
<Viewbox>
<ContentControl ContentTemplate="{DynamicResource DeleteAnalysis}"/>
</Viewbox>
</Button>
</ToolBar>
</ToolBarTray>
<ListBox ItemsSource="{Binding DateVersions}" SelectedItem="{Binding SelectedVersion}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding DateTime}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DockPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,40 @@
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
{
/// <summary>
/// Interaction logic for VersionsView.xaml
/// </summary>
public partial class VersionsView : Window
{
VersionsViewModel viewModel;
public VersionsView(VersionsViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
DataContext = this.viewModel;
if (this.viewModel.OwnerWindow is not null)
{
Owner = this.viewModel.OwnerWindow;
}
}
public VersionsView(IVersionProcessor versionProcessor) : this (new VersionsViewModel(versionProcessor))
{
}
}
}

View File

@@ -0,0 +1,103 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperCommon.Models.Calculators;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
using System.Windows;
using StructureHelper.Windows.ViewModels.Errors;
namespace StructureHelper.Windows.MainWindow.Analyses
{
public class VersionsViewModel : ViewModelBase
{
private IVersionProcessor versionProcessor;
private RelayCommand addNewVersionCommand;
private RelayCommand returnToVersionCommand;
public VersionsViewModel(IVersionProcessor versionProcessor)
{
this.versionProcessor = versionProcessor;
Refresh();
}
public IDateVersion SelectedVersion { get; set; }
public ObservableCollection<IDateVersion> DateVersions { get; set; } = new();
public RelayCommand AddNewVersionCommand
{
get
{
return addNewVersionCommand ??= new RelayCommand(obj =>
{
AddNewVersion();
},
b => SelectedVersion is not null);
}
}
public RelayCommand ReturnToVersionCommand
{
get
{
return returnToVersionCommand ??= new RelayCommand(obj =>
{
ReturnToVersion();
},
b => SelectedVersion is not null);
}
}
private void ReturnToVersion()
{
if (SelectedVersion is null) return;
if (versionProcessor.Versions.Count <= 1)
{
MessageBox.Show("It is not possible to delete last version", "There is only 1 version", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
return;
}
MessageBoxResult result = MessageBox.Show("Please, confirm deleting", "Delete version(s)?", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
if (result != MessageBoxResult.OK) { return; }
SafetyProcessor.RunSafeProcess(RemovingOfVersion, "Error of deleting of version");
}
private void RemovingOfVersion()
{
while (SelectedVersion != versionProcessor.GetCurrentVersion())
{
versionProcessor
.Versions
.Remove(versionProcessor.GetCurrentVersion());
}
Refresh();
}
private void AddNewVersion()
{
if (SelectedVersion is null) { return; }
SafetyProcessor.RunSafeProcess(AddVersion, "Error of adding of new version");
}
private void AddVersion()
{
var selectedItem = SelectedVersion.AnalysisVersion as ICloneable;
versionProcessor.AddVersion(selectedItem.Clone() as ISaveable);
Refresh();
}
private void Refresh()
{
DateVersions.Clear();
versionProcessor.Versions.ForEach(x => DateVersions.Add(x));
SelectedVersion = DateVersions[^1];
}
}
}

View File

@@ -21,13 +21,23 @@
<ToolBarTray DockPanel.Dock="Top"> <ToolBarTray DockPanel.Dock="Top">
<ToolBar DataContext="{Binding FileLogic}" ToolTip="File"> <ToolBar DataContext="{Binding FileLogic}" ToolTip="File">
<Button Style="{StaticResource ToolButton}" <Button Style="{StaticResource ToolButton}"
Command="{Binding FileOpen}" ToolTip="Open file"> Command="{Binding FileOpen}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Open file"
IconContent="{StaticResource FileOpen}"
DescriptionText="Open exsisting project from file"/>
</Button.ToolTip>
<Viewbox> <Viewbox>
<ContentControl ContentTemplate="{DynamicResource FileOpen}"/> <ContentControl ContentTemplate="{DynamicResource FileOpen}"/>
</Viewbox> </Viewbox>
</Button> </Button>
<Button Style="{StaticResource ToolButton}" <Button Style="{StaticResource ToolButton}"
Command="{Binding FileSave}" ToolTip="Save file"> Command="{Binding FileSave}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Save file"
IconContent="{StaticResource FileSave}"
DescriptionText="Save project to file"/>
</Button.ToolTip>
<Viewbox> <Viewbox>
<ContentControl ContentTemplate="{DynamicResource FileSave}"/> <ContentControl ContentTemplate="{DynamicResource FileSave}"/>
</Viewbox> </Viewbox>
@@ -89,23 +99,41 @@
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<ToolBar HorizontalAlignment="Right"> <ToolBar>
<Button Style="{StaticResource ToolButton24}" Command="{Binding RunCommand}" ToolTip="Run Analysis"> <Button Style="{StaticResource ToolButton24}" Command="{Binding CopyCommand}" ToolTip="Copy Analysis">
<Viewbox Width="24" Height="24"> <Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource RunAnalisis}"/> <ContentControl ContentTemplate="{DynamicResource CopyAnalysis}"/>
</Viewbox>
</Button>
<Button Style="{StaticResource ToolButton24}" Command="{Binding VersionsCommand}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Show version"
IconContent="{StaticResource AnalysisVersions}"
DescriptionText="Shows window of versions of selected analysis"/>
</Button.ToolTip>
<Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource AnalysisVersions}"/>
</Viewbox> </Viewbox>
</Button> </Button>
<Button Style="{StaticResource ToolButton24}" Command="{Binding EditCommand}" ToolTip="Edit Analysis"> <Button Style="{StaticResource ToolButton24}" Command="{Binding EditCommand}" ToolTip="Edit Analysis">
<Viewbox Width="24" Height="24"> <Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource EditAnalisis}"/> <ContentControl ContentTemplate="{DynamicResource EditAnalysis}"/>
</Viewbox> </Viewbox>
</Button> </Button>
<Button Style="{StaticResource ToolButton24}" Command="{Binding DeleteCommand}" ToolTip="Delete Analysis"> <Button Style="{StaticResource ToolButton24}" Command="{Binding DeleteCommand}" ToolTip="Delete Analysis">
<Viewbox Width="24" Height="24"> <Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource DeleteAnalisis}"/> <ContentControl ContentTemplate="{DynamicResource DeleteAnalysis}"/>
</Viewbox> </Viewbox>
</Button> </Button>
</ToolBar> </ToolBar>
<ToolBar HorizontalAlignment="Right">
<Button Style="{StaticResource ToolButton24}" Command="{Binding RunCommand}" ToolTip="Run Analysis">
<Viewbox Width="24" Height="24">
<ContentControl ContentTemplate="{DynamicResource RunAnalysis}"/>
</Viewbox>
</Button>
</ToolBar>
<ListBox Grid.Row="1" ItemsSource="{Binding FilteredAnalyses}" SelectedItem="{Binding SelectedAnalysis}"> <ListBox Grid.Row="1" ItemsSource="{Binding FilteredAnalyses}" SelectedItem="{Binding SelectedAnalysis}">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>

View File

@@ -8,8 +8,16 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Errors namespace StructureHelper.Windows.ViewModels.Errors
{ {
/// <summary>
/// Provides safety runing of some action
/// </summary>
internal static class SafetyProcessor internal static class SafetyProcessor
{ {
/// <summary>
/// Invokes action and wrap it in safety try-catch block
/// </summary>
/// <param name="action">Action wich will be invoked</param>
/// <param name="shortText">Short text of error</param>
public static void RunSafeProcess(Action action, string shortText = "") public static void RunSafeProcess(Action action, string shortText = "")
{ {
try try

View File

@@ -71,7 +71,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
private void AddLimitCurveCalculator() private void AddLimitCurveCalculator()
{ {
var inputData = new LimitCurveInputData(repository.Primitives); var inputData = new LimitCurvesCalculatorInputData(repository.Primitives);
NewItem = new LimitCurvesCalculator() NewItem = new LimitCurvesCalculator()
{ {
Name = "New interaction diagram calculator", Name = "New interaction diagram calculator",

View File

@@ -0,0 +1,60 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public class DeepCloningStrategy : ICloningStrategy
{
private readonly Dictionary<object, object> _clonedObjects = new Dictionary<object, object>();
public T Clone<T>(T original, ICloneStrategy<T>? cloneStrategy = null) where T : class
{
if (original == null) return null;
// Check if the object is already cloned
if (_clonedObjects.TryGetValue(original, out var existingClone))
return (T)existingClone;
// Perform custom cloning logic based on the object's type
T clone;
if (cloneStrategy is not null)
{
clone = cloneStrategy.GetClone(original);
}
// Check if the object implements ICloneable (or IClone) and use that method
else if (original is ICloneable cloneable)
{
clone = cloneable.Clone() as T; // Use the ICloneable interface's Clone method
}
else
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ": object is not IClonable and cloning strategy is null");
}
_clonedObjects[original] = clone;
return clone;
}
//private T CreateClone<T>(T original) where T : class
//{
// // Example logic for creating a clone (modify as needed for your use case)
// var type = original.GetType();
// var clone = Activator.CreateInstance(type);
// foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
// {
// var value = field.GetValue(original);
// field.SetValue(clone, Clone(value));
// }
// return (T)clone;
//}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
/// <summary>
/// Creates deep clone of object
/// </summary>
/// <typeparam name="T"></typeparam>
public interface ICloneStrategy<T>
{
/// <summary>
/// Returns deep clone of object
/// </summary>
/// <param name="sourceObject"></param>
/// <returns></returns>
T GetClone(T sourceObject);
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface ICloningStrategy
{
T Clone<T>(T original, ICloneStrategy<T>? cloneStrategy = null) where T : class;
}
}

View File

@@ -16,6 +16,9 @@ namespace StructureHelperCommon.Models.Analyses
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.Name = sourceObject.Name; targetObject.Name = sourceObject.Name;
targetObject.Tags = sourceObject.Tags; targetObject.Tags = sourceObject.Tags;
targetObject.Comment = sourceObject.Comment;
targetObject.Color = sourceObject.Color;
} }
} }
} }

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperCommon.Models.Analyses namespace StructureHelperCommon.Models.Analyses
{ {
@@ -11,6 +12,8 @@ namespace StructureHelperCommon.Models.Analyses
{ {
string Name { get; set; } string Name { get; set; }
string Tags { get; set; } string Tags { get; set; }
string Comment { get; set; }
Color Color { get; set; }
IVersionProcessor VersionProcessor { get; set; } IVersionProcessor VersionProcessor { get; set; }
} }
} }

View File

@@ -1,6 +1,8 @@
using StructureHelperCommon.Models.Analyses; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Analyses;
using StructureHelperLogics.Models.Analyses; using StructureHelperLogics.Models.Analyses;
using StructureHelperLogics.Models.CrossSections; using StructureHelperLogics.Models.CrossSections;
using System.Windows.Media;
namespace StructureHelperLogic.Models.Analyses namespace StructureHelperLogic.Models.Analyses
{ {
@@ -11,6 +13,8 @@ namespace StructureHelperLogic.Models.Analyses
public string Name { get; set; } public string Name { get; set; }
public string Tags { get; set; } public string Tags { get; set; }
public IVersionProcessor VersionProcessor { get; set; } public IVersionProcessor VersionProcessor { get; set; }
public string Comment { get; set; } = string.Empty;
public Color Color { get; set; } = Color.FromRgb(128, 0, 0);
public CrossSectionNdmAnalysis(Guid id, IVersionProcessor versionProcessor) public CrossSectionNdmAnalysis(Guid id, IVersionProcessor versionProcessor)
{ {
@@ -33,6 +37,10 @@ namespace StructureHelperLogic.Models.Analyses
{ {
CrossSectionNdmAnalysis newAnalysis = new(); CrossSectionNdmAnalysis newAnalysis = new();
updateStrategy.Update(newAnalysis, this); updateStrategy.Update(newAnalysis, this);
var currentVersion = VersionProcessor.GetCurrentVersion().AnalysisVersion as ICloneable;
ISaveable newCrossSection = currentVersion.Clone() as ISaveable;
newAnalysis.VersionProcessor.Versions.Clear();
newAnalysis.VersionProcessor.AddVersion(newCrossSection);
return newAnalysis; return newAnalysis;
} }
} }

View File

@@ -1,4 +1,5 @@
using System; using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -8,6 +9,7 @@ namespace StructureHelperLogics.Models.CrossSections
{ {
public class CrossSection : ICrossSection public class CrossSection : ICrossSection
{ {
private ICloneStrategy<ICrossSection> cloneStrategy = new CrossSectionCloneStrategy();
public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository(); public ICrossSectionRepository SectionRepository { get; set; } = new CrossSectionRepository();
public Guid Id { get; private set; } public Guid Id { get; private set; }
@@ -24,7 +26,7 @@ namespace StructureHelperLogics.Models.CrossSections
public object Clone() public object Clone()
{ {
throw new NotImplementedException(); return cloneStrategy.GetClone(this);
} }
} }
} }

View File

@@ -0,0 +1,30 @@
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperLogics.Models.CrossSections
{
public class CrossSectionCloneStrategy : ICloneStrategy<ICrossSection>
{
private ICloneStrategy<ICrossSectionRepository> repositoryCloneStrategy;
private CrossSection targetObject;
public CrossSectionCloneStrategy(ICloneStrategy<ICrossSectionRepository> repositoryCloneStrategy)
{
this.repositoryCloneStrategy = repositoryCloneStrategy;
}
public CrossSectionCloneStrategy() : this (new CrossSectionRepositoryCloneStrategy())
{
}
public ICrossSection GetClone(ICrossSection sourceObject)
{
ICrossSectionRepository newRepository = repositoryCloneStrategy.GetClone(sourceObject.SectionRepository);
targetObject = new()
{
SectionRepository = newRepository
};
return targetObject;
}
}
}

View File

@@ -0,0 +1,142 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Cracking;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.Models.CrossSections
{
public class CrossSectionRepositoryCloneStrategy : ICloneStrategy<ICrossSectionRepository>
{
private ICloningStrategy cloningStrategy;
private CrossSectionRepository targetRepository;
private IUpdateStrategy<ILimitCurvesCalculatorInputData> limitCurvesInputDataUpdateStrategy;
public CrossSectionRepositoryCloneStrategy(
ICloningStrategy cloningStrategy,
IUpdateStrategy<ILimitCurvesCalculatorInputData> limitCurvesInputDataUpdateStrategy)
{
this.cloningStrategy = cloningStrategy;
this.limitCurvesInputDataUpdateStrategy = limitCurvesInputDataUpdateStrategy;
}
public CrossSectionRepositoryCloneStrategy() : this (
new DeepCloningStrategy(),
new LimitCurvesCalculatorInputDataUpdateStrategy())
{
}
public ICrossSectionRepository GetClone(ICrossSectionRepository sourceObject)
{
targetRepository = new();
ProcessForces(targetRepository, sourceObject);
ProcessMaterials(targetRepository, sourceObject);
ProcessPrimitives(targetRepository, sourceObject);
ProcessCalculators(targetRepository, sourceObject);
return targetRepository;
}
private void ProcessCalculators(IHasCalculators targetObject, IHasCalculators sourceObject)
{
targetObject.Calculators.Clear();
foreach (var calculator in sourceObject.Calculators)
{
var newCalculator = cloningStrategy.Clone(calculator);
if (calculator is IForceCalculator forceCalculator)
{
ProcessForceCalculator(newCalculator, forceCalculator);
}
else if (calculator is CrackCalculator crackCalculator)
{
ProcessCrackCalculator(newCalculator, crackCalculator);
}
else if (calculator is ILimitCurvesCalculator limitCalculator)
{
ProcessLimitCurvesCalculator(newCalculator, limitCalculator);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(calculator));
}
targetRepository.Calculators.Add(newCalculator);
}
}
private void ProcessLimitCurvesCalculator(ICalculator newCalculator, ILimitCurvesCalculator limitCalculator)
{
var sourceData = limitCalculator.InputData;
var targetData = ((ILimitCurvesCalculator)newCalculator).InputData;
limitCurvesInputDataUpdateStrategy.Update(targetData, sourceData);
foreach (var series in targetData.PrimitiveSeries)
{
List<INdmPrimitive> collection = UpdatePrimitivesCollection(series);
series.Collection.AddRange(collection);
}
}
private void ProcessCrackCalculator(ICalculator newCalculator, CrackCalculator crackCalculator)
{
var sourceData = crackCalculator.InputData;
var targetData = ((ICrackCalculator)newCalculator).InputData;
ProcessPrimitives(targetData, sourceData);
ProcessForces(targetData, sourceData);
}
private void ProcessForceCalculator(ICalculator newCalculator, IForceCalculator forceCalculator)
{
var sourceData = forceCalculator.InputData;
var targetData = ((IForceCalculator)newCalculator).InputData;
ProcessPrimitives(targetData, sourceData);
ProcessForces(targetData, sourceData);
}
private List<INdmPrimitive> UpdatePrimitivesCollection(NamedCollection<INdmPrimitive> series)
{
List<INdmPrimitive> collection = new();
foreach (var item in series.Collection)
{
var newItem = cloningStrategy.Clone(item);
collection.Add(newItem);
}
series.Collection.Clear();
return collection;
}
private void ProcessMaterials(IHasHeadMaterials targetObject, IHasHeadMaterials sourceObject)
{
targetObject.HeadMaterials.Clear();
foreach (var material in sourceObject.HeadMaterials)
{
var newMaterial = cloningStrategy.Clone(material);
targetRepository.HeadMaterials.Add(newMaterial);
}
}
private void ProcessForces(IHasForceActions targetObject, IHasForceActions sourceObject)
{
targetObject.ForceActions.Clear();
foreach (var force in sourceObject.ForceActions)
{
var newForce = cloningStrategy.Clone(force);
targetObject.ForceActions.Add(newForce);
}
}
private void ProcessPrimitives(IHasPrimitives targetObject, IHasPrimitives sourceObject)
{
targetObject.Primitives.Clear();
foreach (var primitive in sourceObject.Primitives)
{
var newPrimitive = cloningStrategy.Clone(primitive);
var material = cloningStrategy.Clone(primitive.NdmElement.HeadMaterial);
newPrimitive.NdmElement.HeadMaterial = material;
targetObject.Primitives.Add(newPrimitive);
}
}
}
}

View File

@@ -1,11 +1,6 @@
using StructureHelper.Models.Materials; using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services; using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials namespace StructureHelperLogics.Models.Materials
{ {

View File

@@ -6,21 +6,29 @@ namespace StructureHelperLogics.Models.Materials
{ {
public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial> public class HeadMaterialUpdateStrategy : IUpdateStrategy<IHeadMaterial>
{ {
private IUpdateStrategy<IHeadMaterial> updateStrategy = new HeadMaterialBaseUpdateStrategy(); private IUpdateStrategy<IHeadMaterial> baseUpdateStrategy;
private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy; private IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy;
public HeadMaterialUpdateStrategy(IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy) public HeadMaterialUpdateStrategy(
IUpdateStrategy<IHeadMaterial> baseUpdateStrategy,
IUpdateStrategy<IHelperMaterial> helperMaterialUpdateStrategy)
{ {
this.baseUpdateStrategy = baseUpdateStrategy;
this.helperMaterialUpdateStrategy = helperMaterialUpdateStrategy; this.helperMaterialUpdateStrategy = helperMaterialUpdateStrategy;
} }
public HeadMaterialUpdateStrategy() : this(new HelperMaterialUpdateStrategy()) { } public HeadMaterialUpdateStrategy() : this(
new HeadMaterialBaseUpdateStrategy(),
new HelperMaterialUpdateStrategy())
{
}
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject) public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
{ {
CheckObject.IsNull(sourceObject); CheckObject.IsNull(sourceObject);
CheckObject.IsNull(targetObject); CheckObject.IsNull(targetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
updateStrategy.Update(targetObject, sourceObject); baseUpdateStrategy.Update(targetObject, sourceObject);
targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial; targetObject.HelperMaterial = sourceObject.HelperMaterial.Clone() as IHelperMaterial;
helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial); helperMaterialUpdateStrategy.Update(targetObject.HelperMaterial, sourceObject.HelperMaterial);
} }

View File

@@ -63,13 +63,13 @@ namespace StructureHelperLogics.Models.Materials
private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject) private void UpdateLibMaterial(IHelperMaterial targetObject, IHelperMaterial sourceObject)
{ {
if (sourceObject is IConcreteLibMaterial) if (sourceObject is IConcreteLibMaterial concreteLibMaterial)
{ {
concreteStrategy.Update(targetObject as IConcreteLibMaterial, sourceObject as IConcreteLibMaterial); concreteStrategy.Update(targetObject as IConcreteLibMaterial, concreteLibMaterial);
} }
else if (sourceObject is IReinforcementLibMaterial) else if (sourceObject is IReinforcementLibMaterial reinforcementLibMaterial)
{ {
reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, sourceObject as IReinforcementLibMaterial); reinforcementStrategy.Update(targetObject as IReinforcementLibMaterial, reinforcementLibMaterial);
} }
else else
{ {

View File

@@ -8,6 +8,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
/// <summary>
/// Provides calculations of ndm primitives for force actions
/// </summary>
public interface IForceCalculator : ICalculator, IHasActionByResult public interface IForceCalculator : ICalculator, IHasActionByResult
{ {
IForceCalculatorInputData InputData { get; set; } IForceCalculatorInputData InputData { get; set; }

View File

@@ -5,7 +5,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public interface ILimitCurveCalculator : ICalculator, IHasActionByResult public interface ILimitCurveCalculator : ICalculator, IHasActionByResult
{ {
Action<IResult> ActionToOutputResults { get; set; } Action<IResult> ActionToOutputResults { get; set; }
SurroundData SurroundData { get; set; } ISurroundData SurroundData { get; set; }
int PointCount { get; set; } int PointCount { get; set; }
ISurroundProc SurroundProcLogic { get; set; } ISurroundProc SurroundProcLogic { get; set; }
} }

View File

@@ -0,0 +1,12 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Calculators;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface ILimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult
{
LimitCurvesCalculatorInputData InputData { get; set; }
string Name { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Parameters;
using StructureHelperLogics.NdmCalculations.Primitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface ILimitCurvesCalculatorInputData : IInputData, ICloneable
{
List<CalcTerms> CalcTerms { get; }
List<LimitStates> LimitStates { get; }
int PointCount { get; set; }
List<PredicateEntry> PredicateEntries { get; }
List<NamedCollection<INdmPrimitive>> PrimitiveSeries { get; }
ISurroundData SurroundData { get; set; }
}
}

View File

@@ -0,0 +1,14 @@
using StructureHelperCommon.Models.Shapes;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public interface ISurroundData : ICloneable
{
double ConstZ { get; set; }
ConstOneDirectionConverter ConvertLogicEntity { get; set; }
double XMax { get; set; }
double XMin { get; set; }
double YMax { get; set; }
double YMin { get; set; }
}
}

View File

@@ -9,7 +9,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
public interface ISurroundProc public interface ISurroundProc
{ {
SurroundData SurroundData { get; set; } ISurroundData SurroundData { get; set; }
int PointCount { get; set; } int PointCount { get; set; }
List<IPoint2D> GetPoints(); List<IPoint2D> GetPoints();
} }

View File

@@ -13,7 +13,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
private ILimitCurveLogic limitCurveLogic; private ILimitCurveLogic limitCurveLogic;
public string Name { get; set; } public string Name { get; set; }
public SurroundData SurroundData { get; set; } public ISurroundData SurroundData { get; set; }
public int PointCount { get; set; } public int PointCount { get; set; }
public ISurroundProc SurroundProcLogic { get; set; } public ISurroundProc SurroundProcLogic { get; set; }
@@ -27,7 +27,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic) public LimitCurveCalculator(ILimitCurveLogic limitCurveLogic)
{ {
this.limitCurveLogic = limitCurveLogic; this.limitCurveLogic = limitCurveLogic;
SurroundData = new(); SurroundData = new SurroundData();
SurroundProcLogic = new RectSurroundProc(); SurroundProcLogic = new RectSurroundProc();
} }

View File

@@ -1,73 +0,0 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurveInputData : IInputData, ICloneable
{
public List<LimitStates> LimitStates { get; private set; }
public List<CalcTerms> CalcTerms { get; private set; }
public List<NamedCollection<INdmPrimitive>> PrimitiveSeries {get; private set; }
public List<PredicateEntry> PredicateEntries { get; private set; }
public SurroundData SurroundData { get; set; }
public int PointCount { get; set; }
public LimitCurveInputData()
{
LimitStates = new();
CalcTerms = new();
PredicateEntries = new();
SurroundData = new();
PointCount = 80;
PrimitiveSeries = new List<NamedCollection<INdmPrimitive>>();
}
public LimitCurveInputData(IEnumerable<INdmPrimitive> primitives) : this()
{
PrimitiveSeries.Add
(new NamedCollection<INdmPrimitive>()
{
Name = "V1",
Collection = primitives.ToList()
}
);
}
public object Clone()
{
var newItem = new LimitCurveInputData()
{
LimitStates = LimitStates.ToList(),
CalcTerms = CalcTerms.ToList(),
PredicateEntries = PredicateEntries.ToList(),
SurroundData = SurroundData.Clone() as SurroundData,
PointCount = PointCount
};
foreach (var item in PrimitiveSeries)
{
var collection = item.Collection.ToList();
newItem.PrimitiveSeries.Add
(
new NamedCollection<INdmPrimitive>()
{
Name = item.Name,
Collection = collection
}
);
}
return newItem;
}
}
}

View File

@@ -11,7 +11,7 @@ using StructureHelperLogics.Services.NdmPrimitives;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
public class LimitCurvesCalculator : ISaveable, ICalculator, IHasActionByResult public class LimitCurvesCalculator : ILimitCurvesCalculator
{ {
private LimitCurvesResult result; private LimitCurvesResult result;
private int curvesIterationCount; private int curvesIterationCount;
@@ -21,7 +21,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
public Guid Id { get; } public Guid Id { get; }
public string Name { get; set; } public string Name { get; set; }
public LimitCurveInputData InputData { get; set; } public LimitCurvesCalculatorInputData InputData { get; set; }
public IResult Result => result; public IResult Result => result;
public Action<IResult> ActionToOutputResults { get; set; } public Action<IResult> ActionToOutputResults { get; set; }
@@ -89,7 +89,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
}; };
var ndms = triangulateLogic.GetNdms(); var ndms = triangulateLogic.GetNdms();
TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded successfully"); TraceLogger?.AddMessage($"Number of elementary parts N={ndms.Count()} were obtainded successfully");
TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x=>x.Area * x.StressScale)}", TraceLogStatuses.Debug); TraceLogger?.AddMessage($"Summary area of elementary parts Asum={ndms.Sum(x => x.Area * x.StressScale)}", TraceLogStatuses.Debug);
foreach (var predicateEntry in InputData.PredicateEntries) foreach (var predicateEntry in InputData.PredicateEntries)
{ {
string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}"; string calcName = $"{primitiveSeries.Name}_{predicateEntry.Name}_{limitState}_{calcTerm}";

View File

@@ -0,0 +1,51 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Calculators;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Parameters;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2023 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{
public class LimitCurvesCalculatorInputData : ILimitCurvesCalculatorInputData
{
private ICloneStrategy<ILimitCurvesCalculatorInputData> cloneStrategy = new LimitCurvesCalculatorInputDataCloneStrategy();
public List<LimitStates> LimitStates { get; private set; } = new();
public List<CalcTerms> CalcTerms { get; private set; } = new();
public List<NamedCollection<INdmPrimitive>> PrimitiveSeries { get; private set; } = new();
public List<PredicateEntry> PredicateEntries { get; private set; } = new();
public ISurroundData SurroundData { get; set; } = new SurroundData();
public int PointCount { get; set; } = 80;
public LimitCurvesCalculatorInputData()
{
}
public LimitCurvesCalculatorInputData(IEnumerable<INdmPrimitive> primitives)
{
PrimitiveSeries.Add
(new NamedCollection<INdmPrimitive>()
{
Name = "V1",
Collection = primitives.ToList()
}
);
}
public object Clone()
{
var newItem = cloneStrategy.GetClone(this);
return newItem;
}
}
}

View File

@@ -0,0 +1,32 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve
{
public class LimitCurvesCalculatorInputDataCloneStrategy : ICloneStrategy<ILimitCurvesCalculatorInputData>
{
private IUpdateStrategy<ILimitCurvesCalculatorInputData> updateStrategy;
public LimitCurvesCalculatorInputDataCloneStrategy(IUpdateStrategy<ILimitCurvesCalculatorInputData> updateStrategy)
{
this.updateStrategy = updateStrategy;
}
public LimitCurvesCalculatorInputDataCloneStrategy() : this (new LimitCurvesCalculatorInputDataUpdateStrategy())
{
}
public ILimitCurvesCalculatorInputData GetClone(ILimitCurvesCalculatorInputData sourceObject)
{
LimitCurvesCalculatorInputData newItem = new();
updateStrategy.Update(newItem, sourceObject);
return newItem;
}
}
}

View File

@@ -0,0 +1,42 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Parameters;
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.NdmCalculations.Analyses.ByForces.LimitCurve
{
public class LimitCurvesCalculatorInputDataUpdateStrategy : IUpdateStrategy<ILimitCurvesCalculatorInputData>
{
public void Update(ILimitCurvesCalculatorInputData targetObject, ILimitCurvesCalculatorInputData sourceObject)
{
CheckObject.IsNull(targetObject, sourceObject, "Limit curve calculator input data");
if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.LimitStates.Clear();
targetObject.CalcTerms.Clear();
targetObject.PredicateEntries.Clear();
targetObject.LimitStates.AddRange(sourceObject.LimitStates);
targetObject.CalcTerms.AddRange(sourceObject.CalcTerms);
targetObject.PredicateEntries.AddRange(sourceObject.PredicateEntries);
targetObject.SurroundData = sourceObject.SurroundData.Clone() as ISurroundData;
targetObject.PointCount = sourceObject.PointCount;
foreach (var item in sourceObject.PrimitiveSeries)
{
var collection = item.Collection.ToList();
targetObject.PrimitiveSeries.Add
(
new NamedCollection<INdmPrimitive>()
{
Name = item.Name,
Collection = collection
}
);
}
}
}
}

View File

@@ -12,7 +12,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
private List<IPoint2D> surroundList; private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; } public ISurroundData SurroundData { get; set; }
public int PointCount { get; set; } public int PointCount { get; set; }
public RectSurroundProc() public RectSurroundProc()

View File

@@ -11,12 +11,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
{ {
private List<IPoint2D> surroundList; private List<IPoint2D> surroundList;
public SurroundData SurroundData { get; set; } public ISurroundData SurroundData { get; set; }
public int PointCount { get; set; } public int PointCount { get; set; }
public RoundSurroundProc() public RoundSurroundProc()
{ {
SurroundData = new(); SurroundData = new SurroundData();
} }
public List<IPoint2D> GetPoints() public List<IPoint2D> GetPoints()
{ {

View File

@@ -14,7 +14,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
/// <summary> /// <summary>
/// Limits of coordinates for workplane /// Limits of coordinates for workplane
/// </summary> /// </summary>
public class SurroundData : ICloneable public class SurroundData : ISurroundData
{ {
public double XMax { get; set; } public double XMax { get; set; }
public double XMin { get; set; } public double XMin { get; set; }

View File

@@ -3,10 +3,10 @@ using StructureHelperCommon.Models.Parameters;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{ {
internal class LimitCurveInputDataUpdateStrategy : IUpdateStrategy<LimitCurveInputData> internal class LimitCurveInputDataUpdateStrategy : IUpdateStrategy<ILimitCurvesCalculatorInputData>
{ {
SurroundDataUpdateStrategy surroundDataUpdateStrategy => new(); IUpdateStrategy<ISurroundData> surroundDataUpdateStrategy = new SurroundDataUpdateStrategy();
public void Update(LimitCurveInputData targetObject, LimitCurveInputData sourceObject) public void Update(ILimitCurvesCalculatorInputData targetObject, ILimitCurvesCalculatorInputData sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.LimitStates.Clear(); targetObject.LimitStates.Clear();

View File

@@ -8,9 +8,9 @@ using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces.Logics
{ {
internal class SurroundDataUpdateStrategy : IUpdateStrategy<SurroundData> internal class SurroundDataUpdateStrategy : IUpdateStrategy<ISurroundData>
{ {
public void Update(SurroundData targetObject, SurroundData sourceObject) public void Update(ISurroundData targetObject, ISurroundData sourceObject)
{ {
if (ReferenceEquals(targetObject, sourceObject)) { return; } if (ReferenceEquals(targetObject, sourceObject)) { return; }
targetObject.XMax = sourceObject.XMax; targetObject.XMax = sourceObject.XMax;

View File

@@ -17,6 +17,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
{ {
const string prefixInitial = "Initial"; const string prefixInitial = "Initial";
const string prefixActual = "Actual"; const string prefixActual = "Actual";
private const string errorValue = "----";
IConvertUnitLogic operationLogic = new ConvertUnitLogic(); IConvertUnitLogic operationLogic = new ConvertUnitLogic();
IGetUnitLogic unitLogic = new GetUnitLogic(); IGetUnitLogic unitLogic = new GetUnitLogic();
@@ -186,60 +187,60 @@ namespace StructureHelperLogics.Services.NdmPrimitives
return parameters; return parameters;
} }
private List<IValueParameter<string>> GetDistance(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix, PosNegFlag flag, string excentricityName, Func<IEnumerable<INdm>, IStrainMatrix, PosNegFlag, (double dX, double dY, double dSum)> func) private List<IValueParameter<string>> GetDistance(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix, PosNegFlag flag, string eccentricityName, Func<IEnumerable<INdm>, IStrainMatrix, PosNegFlag, (double dX, double dY, double dSum)> func)
{ {
var parameters = new List<IValueParameter<string>>(); var parameters = new List<IValueParameter<string>>();
var unitType = UnitTypes.Length; var unitType = UnitTypes.Length;
var unit = unitLogic.GetUnit(unitType, "mm"); var unit = unitLogic.GetUnit(unitType, "mm");
var unitName = unit.Name; var unitName = unit.Name;
var unitMultiPlayer = unit.Multiplyer; var unitMultiPlayer = unit.Multiplyer;
var sumExcenticityX = new ValueParameter<string>() var sumEccenticityX = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} excentricity", Name = $"{eccentricityName} eccentricity",
ShortName = $"e{firstAxisName.ToLower()},sum", ShortName = $"e{firstAxisName.ToLower()},sum",
Text = unitName, Text = unitName,
Description = $"{excentricityName} force excentricity along {firstAxisName.ToUpper()}-axis" Description = $"{eccentricityName} force excentricity along {firstAxisName.ToUpper()}-axis"
}; };
var sumExcenticityY = new ValueParameter<string>() var sumExcenticityY = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} excentricity", Name = $"{eccentricityName} eccentricity",
ShortName = $"e{secondAxisName.ToLower()},sum", ShortName = $"e{secondAxisName.ToLower()},sum",
Text = unitName, Text = unitName,
Description = $"{excentricityName} force excentricity along {secondAxisName.ToUpper()}-axis" Description = $"{eccentricityName} force eccentricity along {secondAxisName.ToUpper()}-axis"
}; };
var sumExcenticity = new ValueParameter<string>() var sumExcenticity = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} excentricity", Name = $"{eccentricityName} eccentricity",
ShortName = $"e,sum", ShortName = $"e,sum",
Text = unitName, Text = unitName,
Description = $"{excentricityName} force excentricity" Description = $"{eccentricityName} force eccentricity"
}; };
try try
{ {
var sumExcentricityValue = func.Invoke(locNdms, locStrainMatrix, flag); var sumEccentricityValue = func.Invoke(locNdms, locStrainMatrix, flag);
sumExcenticityX.Value = (sumExcentricityValue.dX * unitMultiPlayer).ToString(); sumEccenticityX.Value = (sumEccentricityValue.dX * unitMultiPlayer).ToString();
sumExcenticityY.Value = (sumExcentricityValue.dY * unitMultiPlayer).ToString(); sumExcenticityY.Value = (sumEccentricityValue.dY * unitMultiPlayer).ToString();
sumExcenticity.Value = (sumExcentricityValue.dSum * unitMultiPlayer).ToString(); sumExcenticity.Value = (sumEccentricityValue.dSum * unitMultiPlayer).ToString();
} }
catch (Exception ex) catch (Exception ex)
{ {
sumExcenticityX.IsValid = false; sumEccenticityX.IsValid = false;
sumExcenticityX.Value = (double.NaN).ToString(); sumEccenticityX.Value = errorValue;
sumExcenticityX.Description += $": {ex}"; sumEccenticityX.Description += $": {ex}";
sumExcenticityY.IsValid = false; sumExcenticityY.IsValid = false;
sumExcenticityY.Value = (double.NaN).ToString(); sumExcenticityY.Value = errorValue;
sumExcenticityY.Description += $": {ex}"; sumExcenticityY.Description += $": {ex}";
sumExcenticity.IsValid = false; sumExcenticity.IsValid = false;
sumExcenticity.Value = (double.NaN).ToString(); sumExcenticity.Value = errorValue;
sumExcenticity.Description += $": {ex}"; sumExcenticity.Description += $": {ex}";
} }
parameters.Add(sumExcenticityX); parameters.Add(sumEccenticityX);
parameters.Add(sumExcenticityY); parameters.Add(sumExcenticityY);
parameters.Add(sumExcenticity); parameters.Add(sumExcenticity);
return parameters; return parameters;
@@ -254,7 +255,7 @@ namespace StructureHelperLogics.Services.NdmPrimitives
return parameters; return parameters;
} }
private IEnumerable<IValueParameter<string>> GetLiverArms(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix, string excentricityName, Func<IEnumerable<INdm>, IStrainMatrix, (double dX, double dY, double dSum)> func) private IEnumerable<IValueParameter<string>> GetLiverArms(IEnumerable<INdm> locNdms, IStrainMatrix? locStrainMatrix, string eccentricityName, Func<IEnumerable<INdm>, IStrainMatrix, (double dX, double dY, double dSum)> func)
{ {
const string liverArm = "liver arm"; const string liverArm = "liver arm";
var parameters = new List<IValueParameter<string>>(); var parameters = new List<IValueParameter<string>>();
@@ -265,26 +266,26 @@ namespace StructureHelperLogics.Services.NdmPrimitives
var sumLiverArmX = new ValueParameter<string>() var sumLiverArmX = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} {liverArm}", Name = $"{eccentricityName} {liverArm}",
ShortName = $"z,{firstAxisName.ToLower()}", ShortName = $"z,{firstAxisName.ToLower()}",
Text = unitName, Text = unitName,
Description = $"{excentricityName} {liverArm} along {firstAxisName.ToUpper()}-axis" Description = $"{eccentricityName} {liverArm} along {firstAxisName.ToUpper()}-axis"
}; };
var sumLiverArmY = new ValueParameter<string>() var sumLiverArmY = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} {liverArm}", Name = $"{eccentricityName} {liverArm}",
ShortName = $"z,{secondAxisName.ToLower()}", ShortName = $"z,{secondAxisName.ToLower()}",
Text = unitName, Text = unitName,
Description = $"{excentricityName} {liverArm} along {secondAxisName.ToUpper()}-axis" Description = $"{eccentricityName} {liverArm} along {secondAxisName.ToUpper()}-axis"
}; };
var sumLiverArm = new ValueParameter<string>() var sumLiverArm = new ValueParameter<string>()
{ {
IsValid = true, IsValid = true,
Name = $"{excentricityName} {liverArm}", Name = $"{eccentricityName} {liverArm}",
ShortName = $"z,sum", ShortName = $"z,sum",
Text = unitName, Text = unitName,
Description = $"{excentricityName} {liverArm}" Description = $"{eccentricityName} {liverArm}"
}; };
try try
{ {
@@ -296,15 +297,15 @@ namespace StructureHelperLogics.Services.NdmPrimitives
catch (Exception ex) catch (Exception ex)
{ {
sumLiverArmX.IsValid = false; sumLiverArmX.IsValid = false;
sumLiverArmX.Value = (double.NaN).ToString(); sumLiverArmX.Value = errorValue;
sumLiverArmX.Description += $": {ex}"; sumLiverArmX.Description += $": {ex}";
sumLiverArmY.IsValid = false; sumLiverArmY.IsValid = false;
sumLiverArmY.Value = (double.NaN).ToString(); sumLiverArmY.Value = errorValue;
sumLiverArmY.Description += $": {ex}"; sumLiverArmY.Description += $": {ex}";
sumLiverArm.IsValid = false; sumLiverArm.IsValid = false;
sumLiverArm.Value = (double.NaN).ToString(); sumLiverArm.Value = errorValue;
sumLiverArm.Description += $": {ex}"; sumLiverArm.Description += $": {ex}";
} }

View File

@@ -0,0 +1,163 @@
using LoaderCalculator.Data.Materials;
using NUnit.Framework;
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Windows.Media;
namespace StructureHelperTests.UnitTests.UpdateStrategiesTests
{
[TestFixture]
public class HeadMaterialUpdateStrategyTests
{
private HeadMaterialUpdateStrategy _strategy;
[SetUp]
public void SetUp()
{
_strategy = new HeadMaterialUpdateStrategy(
new MockBaseUpdateStrategy(),
new MockHelperMaterialUpdateStrategy()
);
}
[Test]
public void Update_ShouldThrowException_WhenTargetObjectIsNull()
{
var sourceObject = new MockHeadMaterial();
Assert.Throws<StructureHelperException>(() => _strategy.Update(null, sourceObject));
}
[Test]
public void Update_ShouldThrowException_WhenSourceObjectIsNull()
{
var targetObject = new MockHeadMaterial();
Assert.Throws<StructureHelperException>(() => _strategy.Update(targetObject, null));
}
[Test]
public void Update_ShouldNotThrow_WhenTargetAndSourceAreSameReference()
{
var targetAndSource = new MockHeadMaterial();
Assert.DoesNotThrow(() => _strategy.Update(targetAndSource, targetAndSource));
}
[Test]
public void Update_ShouldUpdateBaseProperties()
{
// Arrange
var targetObject = new MockHeadMaterial { Name = "Original", Color = Color.FromRgb(0,0,0) };
var sourceObject = new MockHeadMaterial { Name = "Updated", Color = Color.FromRgb(255, 0, 0), HelperMaterial = new MockHelperMaterial() };
// Act
_strategy.Update(targetObject, sourceObject);
// Assert
Assert.AreEqual("Updated", targetObject.Name, "Name should be updated");
Assert.AreEqual(Color.FromRgb(255, 0, 0), targetObject.Color, "Color should be updated");
}
[Test]
public void Update_ShouldCloneAndUpdateHelperMaterial()
{
// Arrange
MockHeadMaterial targetObject = new (){ HelperMaterial = new MockHelperMaterial { Property = "Original" } };
var sourceObject = new MockHeadMaterial { HelperMaterial = new MockHelperMaterial { Property = "Updated" } };
// Act
_strategy.Update(targetObject, sourceObject);
// Assert
Assert.AreEqual("Updated", (targetObject.HelperMaterial as MockHelperMaterial).Property, "HelperMaterial property should be updated");
Assert.AreNotSame(sourceObject.HelperMaterial, targetObject.HelperMaterial,
"HelperMaterial should be cloned, not directly assigned");
}
#region Mocks
private class MockHeadMaterial : IHeadMaterial
{
public string Name { get; set; }
public Color Color { get; set; }
public IHelperMaterial HelperMaterial { get; set; }
public Guid Id => throw new NotImplementedException();
public object Clone()
{
return new MockHeadMaterial
{
Name = this.Name,
Color = this.Color,
HelperMaterial = this.HelperMaterial?.Clone() as IHelperMaterial
};
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
}
private class MockHelperMaterial : IHelperMaterial
{
public string Property { get; set; }
public Guid Id => throw new NotImplementedException();
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
public object Clone()
{
return new MockHelperMaterial { Property = this.Property };
}
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
throw new NotImplementedException();
}
}
private class MockBaseUpdateStrategy : IUpdateStrategy<IHeadMaterial>
{
public void Update(IHeadMaterial targetObject, IHeadMaterial sourceObject)
{
if (targetObject == null || sourceObject == null) return;
targetObject.Name = sourceObject.Name;
targetObject.Color = sourceObject.Color;
}
}
private class MockHelperMaterialUpdateStrategy : IUpdateStrategy<IHelperMaterial>
{
public void Update(IHelperMaterial targetObject, IHelperMaterial sourceObject)
{
if (targetObject != null && sourceObject != null)
{
(targetObject as MockHelperMaterial).Property = (sourceObject as MockHelperMaterial).Property;
}
}
}
#endregion
}
}