Window of calcultion's property is added

This commit is contained in:
Evgeny Redikultsev
2022-09-11 20:22:10 +05:00
parent 78ec7bdc6f
commit d9e3f9ba54
16 changed files with 521 additions and 4 deletions

View File

@@ -116,6 +116,9 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Windows\CalculationWindows\CalculationPropertyWindow\CalculationPropertyView.xaml.cs">
<DependentUpon>CalculationPropertyView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ColorPickerWindow\ColorPickerView.xaml.cs"> <Compile Include="Windows\ColorPickerWindow\ColorPickerView.xaml.cs">
<DependentUpon>ColorPickerView.xaml</DependentUpon> <DependentUpon>ColorPickerView.xaml</DependentUpon>
</Compile> </Compile>
@@ -143,6 +146,7 @@
<Compile Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml.cs"> <Compile Include="Infrastructure\UI\DataTemplates\RectangleTemplate.xaml.cs">
<DependentUpon>RectangleTemplate.xaml</DependentUpon> <DependentUpon>RectangleTemplate.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Windows\ViewModels\Calculations\CalculationProperies\CalculationPropertyViewModel.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\DoubleClickEventTrigger.cs" /> <Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\DoubleClickEventTrigger.cs" />
@@ -172,6 +176,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Windows\CalculationWindows\CalculationPropertyWindow\CalculationPropertyView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ColorPickerWindow\ColorPickerView.xaml"> <Page Include="Windows\ColorPickerWindow\ColorPickerView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>

View File

@@ -0,0 +1,27 @@
using LoaderCalculator.Data.Matrix;
using StructureHelperLogics.Infrastructures.CommonEnums;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public class CalculationProperty : ICalculationProperty
{
public List<IForceCombination> ForceCombinations { get; set; }
public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; }
public IIterationProperty IterationProperty { get; }
public CalculationProperty()
{
ForceCombinations = new List<IForceCombination>
{
new ForceCombination()
};
LimitState = LimitStates.Collapse;
CalcTerm = CalcTerms.ShortTerm;
IterationProperty = new IterationProperty() { Accuracy = 0.001d, MaxIterationCount = 100};
}
}
}

View File

@@ -0,0 +1,19 @@
using LoaderCalculator.Data.Matrix;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public class ForceCombination : IForceCombination
{
public IForceMatrix ForceMatrix { get; private set; }
public bool TakeInCalculate { get; set; }
public ForceCombination()
{
ForceMatrix = new ForceMatrix() { Mx = 0d, My = 0d, Nz = 0d};
TakeInCalculate = true;
}
}
}

View File

@@ -0,0 +1,16 @@
using LoaderCalculator.Data.Matrix;
using StructureHelperLogics.Infrastructures.CommonEnums;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public interface ICalculationProperty
{
List<IForceCombination> ForceCombinations { get; set; }
LimitStates LimitState { get; set; }
CalcTerms CalcTerm { get; set; }
IIterationProperty IterationProperty {get;}
}
}

View File

@@ -0,0 +1,13 @@
using LoaderCalculator.Data.Matrix;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public interface IForceCombination
{
IForceMatrix ForceMatrix { get; }
bool TakeInCalculate { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public interface IIterationProperty
{
double Accuracy { get; set; }
int MaxIterationCount { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationProperties
{
public class IterationProperty : IIterationProperty
{
public double Accuracy { get; set; }
public int MaxIterationCount { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using LoaderCalculator.Data.ResultData;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationsResults
{
/// <inheritdoc/>
class CalculationResult : ICalculationResult
{
/// <inheritdoc/>
public bool IsValid { get; set; }
/// <inheritdoc/>
public string Desctription { get; set; }
/// <inheritdoc/>
public ILoaderResults LoaderResults { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using LoaderCalculator.Data.ResultData;
using System;
using System.Collections.Generic;
using System.Text;
namespace StructureHelperLogics.Models.Calculations.CalculationsResults
{
/// <summary>
/// Represent result of calculation of ndm analisys
/// </summary>
public interface ICalculationResult
{
/// <summary>
/// True if result of calculation is valid
/// </summary>
bool IsValid { get; }
/// <summary>
/// Text of result of calculations
/// </summary>
string Desctription { get; }
/// <summary>
/// Keep result of calculations from ndm-library
/// </summary>
ILoaderResults LoaderResults { get; }
}
}

View File

@@ -7,6 +7,9 @@ using LoaderCalculator.Data.SourceData;
using StructureHelperCommon.Models.Entities; using StructureHelperCommon.Models.Entities;
using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Infrastructures.CommonEnums; using StructureHelperLogics.Infrastructures.CommonEnums;
using StructureHelperLogics.Models.Calculations.CalculationsResults;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using System;
namespace StructureHelperLogics.Services namespace StructureHelperLogics.Services
{ {
@@ -35,5 +38,42 @@ namespace StructureHelperLogics.Services
calculator.Run(loaderData, new CancellationToken()); calculator.Run(loaderData, new CancellationToken());
return calculator.Result.StrainMatrix; return calculator.Result.StrainMatrix;
} }
public List<ICalculationResult> GetCalculationResults(ICalculationProperty calculationProperty, IEnumerable<INdm> ndms)
{
List<ICalculationResult> results = new List<ICalculationResult>();
foreach (var forceCombinations in calculationProperty.ForceCombinations)
{
var forceMatrix = forceCombinations.ForceMatrix;
results.Add(GetCalculationResult(forceMatrix, ndms, calculationProperty.IterationProperty.Accuracy, calculationProperty.IterationProperty.MaxIterationCount));
}
return results;
}
public ICalculationResult GetCalculationResult(IForceMatrix forceMatrix, IEnumerable<INdm> ndmCollection, double accuracyRate, int maxIterationCount)
{
try
{
var loaderData = new LoaderOptions
{
Preconditions = new Preconditions
{
ConditionRate = accuracyRate,
MaxIterationCount = maxIterationCount,
StartForceMatrix = forceMatrix
},
NdmCollection = ndmCollection
};
var calculator = new Calculator();
calculator.Run(loaderData, new CancellationToken());
var result = calculator.Result;
if (result.AccuracyRate <= accuracyRate) { return new CalculationResult() { IsValid = true, Desctription = "Analisys is done succsefully", LoaderResults=result };}
else { return new CalculationResult() { IsValid = false, Desctription = "Required accuracy rate has not achived", LoaderResults = result }; }
}
catch (Exception ex)
{
return new CalculationResult() { IsValid = false, Desctription = $"Error is appeared due to analysis. Error: {ex}" };
}
}
} }
} }

View File

@@ -0,0 +1,88 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow.CalculationPropertyView"
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.CalculationWindows.CalculationPropertyWindow"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.CalculationProperies"
d:DataContext="{d:DesignInstance vm:CalculationPropertyViewModel}"
mc:Ignorable="d"
Title="Calculation Properties" Height="330" Width="400" MinHeight="330" MinWidth="400" WindowStartupLocation="CenterScreen" Closing="Window_Closing">
<Window.Resources>
<Style TargetType="TextBox" x:Key="ValidatedError">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="10"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Forces">
<StackPanel>
<GroupBox Header="Combinations of forces" Height="160">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="ForceGrid" AutoGenerateColumns="False" ItemsSource="{Binding Path=ForceCombinations}" SelectionChanged="ForceGrid_SelectionChanged"
SelectedItem="{Binding Path=SelectedCombination}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Active" Binding="{Binding Path=TakeInCalculate}"/>
<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding Path=ForceMatrix.Mx}"/>
<DataGridTextColumn Header="Moment My" Width="90" Binding="{Binding Path=ForceMatrix.My}"/>
<DataGridTextColumn Header="Force Nz" Width="90" Binding="{Binding Path=ForceMatrix.Nz}"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Column="1">
<Button Content="Add" Command="{Binding Path=AddForceCombinationCommand}"/>
<Button Content="Remove" Command="{Binding Path=RemoveForceCombinationCommand}"/>
</StackPanel>
</Grid>
</GroupBox>
<Grid Height="80">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<GroupBox Header="Limit state">
<StackPanel>
<RadioButton x:Name="LsCollapse" Content="Limit state of collapse" Margin="5" IsChecked="True" GroupName="LimitState" Checked="LsCollapse_Checked"/>
<RadioButton x:Name="LsServiceability" Content="Limit state of serviceability" Margin="5" GroupName="LimitState" Checked="LsServiceability_Checked"/>
</StackPanel>
</GroupBox>
<GroupBox Grid.Column="1" Header="Duration of acting of loads">
<StackPanel>
<RadioButton x:Name="ShortLoads" Content="Short term loads" Margin="5" IsChecked="True" GroupName="LoadDuration" Checked="ShortLoads_Checked"/>
<RadioButton x:Name="LongLoads" Content="Long term loads" Margin="5" GroupName="LoadDuration" Checked="LongLoads_Checked"/>
</StackPanel>
</GroupBox>
</Grid>
</StackPanel>
</TabItem>
<TabItem Header="Iterations">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="1" Margin="5" Text="{Binding Path=IterationAccuracy, ValidatesOnDataErrors=True}"/>
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="1" Grid.Row="1" Margin="5" Text="{Binding Path=MaxIterationCount, ValidatesOnDataErrors=True}"/>
</Grid>
</TabItem>
</TabControl>
</Grid>
</Window>

View File

@@ -0,0 +1,70 @@
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
using StructureHelperLogics.Infrastructures.CommonEnums;
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.CalculationWindows.CalculationPropertyWindow
{
/// <summary>
/// Логика взаимодействия для CalculationPropertyView.xaml
/// </summary>
public partial class CalculationPropertyView : Window
{
private CalculationPropertyViewModel viewModel;
public CalculationPropertyView(CalculationPropertyViewModel calculationProperty)
{
InitializeComponent();
viewModel = calculationProperty;
this.DataContext = viewModel;
if (viewModel.LimitState == LimitStates.Collapse) { LsCollapse.IsChecked = true; }
else { LsServiceability.IsChecked = true; }
if (viewModel.CalcTerm == CalcTerms.ShortTerm) { ShortLoads.IsChecked = true; }
else { LongLoads.IsChecked = true; }
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
viewModel.SaveProperties();
}
private void LsCollapse_Checked(object sender, RoutedEventArgs e)
{
var chBox = sender as RadioButton;
if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.Collapse; }
}
private void LsServiceability_Checked(object sender, RoutedEventArgs e)
{
var chBox = sender as RadioButton;
if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.ServiceAbility; }
}
private void ShortLoads_Checked(object sender, RoutedEventArgs e)
{
var chBox = sender as RadioButton;
if (chBox.IsChecked == true & viewModel != null) { viewModel.CalcTerm = CalcTerms.ShortTerm; }
}
private void LongLoads_Checked(object sender, RoutedEventArgs e)
{
var chBox = sender as RadioButton;
if (chBox.IsChecked == true & viewModel != null) { viewModel.CalcTerm = CalcTerms.LongTerm; }
}
private void ForceGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var dg = sender as DataGrid;
}
}
}

View File

@@ -7,6 +7,7 @@ using StructureHelper.Services;
using StructureHelper.UnitSystem; using StructureHelper.UnitSystem;
using StructureHelper.UnitSystem.Systems; using StructureHelper.UnitSystem.Systems;
using StructureHelperLogics.Infrastructures.CommonEnums; using StructureHelperLogics.Infrastructures.CommonEnums;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.NdmCalculations.Triangulations; using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services; using StructureHelperLogics.Services;
using System.Collections; using System.Collections;
@@ -21,12 +22,16 @@ namespace StructureHelper.Windows.MainWindow
private IPrimitiveRepository primitiveRepository; private IPrimitiveRepository primitiveRepository;
private CalculationService calculationService; private CalculationService calculationService;
private UnitSystemService unitSystemService; private UnitSystemService unitSystemService;
public ICalculationProperty CalculationProperty { get; private set; }
public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService) public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
{ {
this.primitiveRepository = primitiveRepository; this.primitiveRepository = primitiveRepository;
this.calculationService = calculationService; this.calculationService = calculationService;
this.unitSystemService = unitSystemService; this.unitSystemService = unitSystemService;
CalculationProperty = new CalculationProperty();
} }
public IStrainMatrix Calculate(double mx, double my, double nz) public IStrainMatrix Calculate(double mx, double my, double nz)

View File

@@ -23,6 +23,7 @@
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="40"/> <RowDefinition Height="40"/>
<RowDefinition Height="40"/> <RowDefinition Height="40"/>
@@ -30,7 +31,15 @@
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.ColumnSpan="5"> <Menu x:Name="menu">
<MenuItem Header="File">
</MenuItem>
<MenuItem Header="Edit">
<Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/>
</MenuItem>
</Menu>
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.ColumnSpan="5" Grid.Row="1">
<i:Interaction.Triggers> <i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown"> <i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding ClearSelection}" CommandParameter="{Binding}"/> <i:InvokeCommandAction Command="{Binding ClearSelection}" CommandParameter="{Binding}"/>

View File

@@ -16,6 +16,10 @@ using StructureHelper.Models.Materials;
using LoaderCalculator.Data.Matrix; using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms; using LoaderCalculator.Data.Ndms;
using StructureHelper.Services.ResultViewers; using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
using StructureHelperLogics.Services;
namespace StructureHelper.Windows.MainWindow namespace StructureHelper.Windows.MainWindow
{ {
@@ -30,6 +34,7 @@ namespace StructureHelper.Windows.MainWindow
public ObservableCollection<PrimitiveBase> Primitives { get; set; } public ObservableCollection<PrimitiveBase> Primitives { get; set; }
private double panelX, panelY, scrollPanelX, scrollPanelY; private double panelX, panelY, scrollPanelX, scrollPanelY;
private CalculationProperty calculationProperty;
public double PanelX public double PanelX
{ {
@@ -111,6 +116,7 @@ namespace StructureHelper.Windows.MainWindow
public ICommand Calculate { get; } public ICommand Calculate { get; }
public ICommand SetPopupCanBeClosedTrue { get; } public ICommand SetPopupCanBeClosedTrue { get; }
public ICommand SetPopupCanBeClosedFalse { get; } public ICommand SetPopupCanBeClosedFalse { get; }
public ICommand EditCalculationPropertyCommand { get; }
public string UnitsSystemName => unitSystemService.GetCurrentSystem().Name; public string UnitsSystemName => unitSystemService.GetCurrentSystem().Name;
private double delta = 0.5; private double delta = 0.5;
@@ -126,6 +132,9 @@ namespace StructureHelper.Windows.MainWindow
XY1 = CanvasHeight / 2; XY1 = CanvasHeight / 2;
YX1 = CanvasWidth / 2; YX1 = CanvasWidth / 2;
YY2 = CanvasHeight; YY2 = CanvasHeight;
calculationProperty = new CalculationProperty();
LeftButtonUp = new RelayCommand(o => LeftButtonUp = new RelayCommand(o =>
{ {
if (o is Rectangle rect) rect.BorderCaptured = false; if (o is Rectangle rect) rect.BorderCaptured = false;
@@ -231,6 +240,7 @@ namespace StructureHelper.Windows.MainWindow
Primitives.Add(primitive); Primitives.Add(primitive);
PrimitiveRepository.Add(primitive); PrimitiveRepository.Add(primitive);
} }
AddTestLoads();
}); });
Calculate = new RelayCommand(o => Calculate = new RelayCommand(o =>
@@ -244,6 +254,8 @@ namespace StructureHelper.Windows.MainWindow
CalculateResult(); CalculateResult();
}); });
EditCalculationPropertyCommand = new RelayCommand (o => EditCalculationProperty());
SetPopupCanBeClosedTrue = new RelayCommand(o => SetPopupCanBeClosedTrue = new RelayCommand(o =>
{ {
if (!(o is PrimitiveBase primitive)) return; if (!(o is PrimitiveBase primitive)) return;
@@ -259,10 +271,14 @@ namespace StructureHelper.Windows.MainWindow
private void CalculateResult() private void CalculateResult()
{ {
IForceMatrix forceMatrix = new ForceMatrix() { Mx = 10e3, My = 10e3, Nz = 0 };
IEnumerable<INdm> ndms = Model.GetNdms(); IEnumerable<INdm> ndms = Model.GetNdms();
var loaderResult = Model.CalculateResult(ndms, forceMatrix); CalculationService calculationService = new CalculationService();
ShowIsoFieldResult.ShowResult(loaderResult.StrainMatrix, ndms, ResultFuncFactory.GetResultFuncs()); var loaderResults = calculationService.GetCalculationResults(calculationProperty, ndms);
if (loaderResults[0].IsValid)
{
IStrainMatrix strainMatrix = loaderResults[0].LoaderResults.ForceStrainPair.StrainMatrix;
ShowIsoFieldResult.ShowResult(strainMatrix, ndms, ResultFuncFactory.GetResultFuncs());
}
} }
private IEnumerable<PrimitiveBase> GetTestCasePrimitives() private IEnumerable<PrimitiveBase> GetTestCasePrimitives()
@@ -279,5 +295,19 @@ namespace StructureHelper.Windows.MainWindow
yield return new Point(d2, -width / 2 + 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass }; yield return new Point(d2, -width / 2 + 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(d2, width / 2 - 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass }; yield return new Point(d2, width / 2 - 50, height / 2 - 50, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
} }
private void EditCalculationProperty()
{
CalculationPropertyViewModel viewModel = new CalculationPropertyViewModel(calculationProperty);
var view = new CalculationPropertyView(viewModel);
view.ShowDialog();
}
private void AddTestLoads()
{
calculationProperty.ForceCombinations.Clear();
calculationProperty.ForceCombinations.Add(new ForceCombination());
calculationProperty.ForceCombinations[0].ForceMatrix.Mx = 40e3d;
calculationProperty.ForceCombinations[0].ForceMatrix.My = 20e3d;
calculationProperty.ForceCombinations[0].ForceMatrix.Nz = 0d;
}
} }
} }

View File

@@ -0,0 +1,124 @@
using StructureHelper.Infrastructure;
using StructureHelperLogics.Infrastructures.CommonEnums;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
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.Input;
namespace StructureHelper.Windows.ViewModels.Calculations.CalculationProperies
{
public class CalculationPropertyViewModel : ViewModelBase, IDataErrorInfo
{
public ObservableCollection<IForceCombination> ForceCombinations { get; private set; }
public double IterationAccuracy
{
get
{
return calculationProperty.IterationProperty.Accuracy;
}
set
{
calculationProperty.IterationProperty.Accuracy = value;
OnPropertyChanged("Accuracy");
}
}
public int MaxIterationCount
{
get
{
return calculationProperty.IterationProperty.MaxIterationCount;
}
set
{
calculationProperty.IterationProperty.MaxIterationCount = value;
OnPropertyChanged("MaxIterationCount");
}
}
public IForceCombination SelectedCombination { get; set; }
public LimitStates LimitState
{
get
{
return calculationProperty.LimitState;
}
set
{
calculationProperty.LimitState = value;
OnPropertyChanged(nameof(LimitState));
}
}
public CalcTerms CalcTerm
{
get
{
return calculationProperty.CalcTerm;
}
set
{
calculationProperty.CalcTerm = value;
OnPropertyChanged(nameof(CalcTerm));
}
}
public string Error => throw new NotImplementedException();
public string this[string columnName]
{
get
{
string error = string.Empty;
if (columnName == nameof(IterationAccuracy))
{
if (IterationAccuracy < 1e-10) { error = "Assigned accuracy of iterations is not valid"; }
}
else if (columnName == nameof(MaxIterationCount))
{
if (MaxIterationCount < 2) { error = "Number of iterations should be greater than 1"; }
}
return error;
}
}
public ICommand AddForceCombinationCommand { get; private set; }
public ICommand RemoveForceCombinationCommand { get; private set; }
private readonly ICalculationProperty calculationProperty;
public CalculationPropertyViewModel(ICalculationProperty calculationProperty)
{
this.calculationProperty = calculationProperty;
ForceCombinations = new ObservableCollection<IForceCombination>();
foreach (var force in calculationProperty.ForceCombinations)
{
ForceCombinations.Add(force);
}
AddForceCombinationCommand = new RelayCommand(o => AddForceCombination());
RemoveForceCombinationCommand = new RelayCommand(o => RemoveForceCombination(), o => SelectedCombination != null);
}
public void SaveProperties()
{
calculationProperty.ForceCombinations.Clear();
foreach (var force in ForceCombinations)
{
calculationProperty.ForceCombinations.Add(force);
}
}
private void AddForceCombination()
{
ForceCombinations.Add(new ForceCombination());
}
private void RemoveForceCombination()
{
ForceCombinations.Remove(SelectedCombination);
}
}
}