Change ObsCollection to List in Common, write FunctionMaterialCreationVM, remove old UI, binding enums and functions to new UI.

This commit is contained in:
Иван Ивашкин
2025-04-26 23:07:18 +05:00
parent 776fc4c494
commit decbc10f51
19 changed files with 237 additions and 334 deletions

View File

@@ -118,7 +118,7 @@ namespace StructureHelper.Windows.MainGraph
} }
public GraphViewModel() public GraphViewModel()
{ {
Functions = ProgramSetting.Functions; Functions = new ObservableCollection<IOneVariableFunction>(ProgramSetting.Functions);
} }
private void AddTable() private void AddTable()
{ {
@@ -226,7 +226,7 @@ namespace StructureHelper.Windows.MainGraph
} }
public void Save() public void Save()
{ {
ProgramSetting.Functions = Functions; ProgramSetting.Functions = new List<IOneVariableFunction>(Functions);
} }
} }
} }

View File

@@ -16,7 +16,7 @@ namespace StructureHelper.Windows.TreeGraph
return new TableFunction() return new TableFunction()
{ {
Name = "func0", Name = "func0",
Functions = new ObservableCollection<IOneVariableFunction>() Functions = new List<IOneVariableFunction>()
{ {
new FormulaFunction() new FormulaFunction()
{ {
@@ -29,7 +29,7 @@ namespace StructureHelper.Windows.TreeGraph
new FormulaFunction() new FormulaFunction()
{ {
Name = "func1.3", Name = "func1.3",
Functions = new ObservableCollection<IOneVariableFunction>() Functions = new List<IOneVariableFunction>()
{ {
new FormulaFunction() new FormulaFunction()
{ {

View File

@@ -26,7 +26,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public List<GraphPoint> Table { get; set; } public List<GraphPoint> Table { get; set; }
public double MinArg { get; set; } public double MinArg { get; set; }
public double MaxArg { get; set; } public double MaxArg { get; set; }
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>(); public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
public Guid Id => throw new NotImplementedException(); public Guid Id => throw new NotImplementedException();

View File

@@ -28,7 +28,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
public double MaxArg { get; set; } public double MaxArg { get; set; }
public Color Color { get; set; } public Color Color { get; set; }
public string Trace { get; set; } public string Trace { get; set; }
public ObservableCollection<IOneVariableFunction> Functions { get; set; } public List<IOneVariableFunction> Functions { get; set; }
public bool Check(); public bool Check();
public double GetByX(double xValue); public double GetByX(double xValue);

View File

@@ -94,7 +94,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
SubVersionNumber = 0 SubVersionNumber = 0
}; };
} }
public static ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction> public static List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>
{ {
new TableFunction() new TableFunction()
{ {

View File

@@ -57,7 +57,7 @@ namespace StructureHelperCommon.Models.Functions
} }
} }
public Guid Id => throw new NotImplementedException(); public Guid Id => throw new NotImplementedException();
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>(); public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
public double MinArg { get; set; } public double MinArg { get; set; }
public double MaxArg { get; set; } public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }

View File

@@ -31,7 +31,7 @@ namespace StructureHelperCommon.Models.Functions
public string Description { get; set; } public string Description { get; set; }
public List<GraphPoint> Table { get; set; } public List<GraphPoint> Table { get; set; }
public Guid Id => throw new NotImplementedException(); public Guid Id => throw new NotImplementedException();
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>(); public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
public double MinArg { get; set; } public double MinArg { get; set; }
public double MaxArg { get; set; } public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; } public IShiftTraceLogger? TraceLogger { get; set; }

View File

@@ -10,6 +10,7 @@ namespace StructureHelperCommon.Models.Materials
{ {
public class MaterialSettings public class MaterialSettings
{ {
public int Number { get; set; }
public bool IsActive { get; set; } public bool IsActive { get; set; }
public LimitStates LimitState { get; set; } public LimitStates LimitState { get; set; }
public CalcTerms CalcTerm { get; set; } public CalcTerms CalcTerm { get; set; }

View File

@@ -5,16 +5,10 @@
<Compile Update="Windows\FunctionMaterialCreationView.xaml.cs"> <Compile Update="Windows\FunctionMaterialCreationView.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Update="Windows\FunctionSelectionView.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Update="Windows\FunctionMaterialCreationView.xaml"> <Page Update="Windows\FunctionMaterialCreationView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Update="Windows\FunctionSelectionView.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings; using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions; using StructureHelperCommon.Models.Functions;
using StructureHelperCommon.Models.Materials; using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Sections.Logics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@@ -11,34 +12,93 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
namespace StructureHelperCommon.Windows namespace StructureHelperCommon.Windows
{ {
public class FunctionMaterialCreationVM public class FunctionMaterialCreationVM
{ {
public string CREATE_MATERIAL { get; } = "Create Function Material"; private ObservableCollection<MaterialSettings> materialSettingsList = new()
public string MODULUS_OF_ELASTICITY { get; } = "Modulus of elasticity = "; {
new MaterialSettings()
{
Number = 1,
IsActive = true,
LimitState = Infrastructures.Enums.LimitStates.ULS,
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
},
new MaterialSettings()
{
Number = 2,
IsActive = true,
LimitState = Infrastructures.Enums.LimitStates.ULS,
CalcTerm = Infrastructures.Enums.CalcTerms.LongTerm,
},
new MaterialSettings()
{
Number = 3,
IsActive = true,
LimitState = Infrastructures.Enums.LimitStates.SLS,
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
},
new MaterialSettings()
{
Number = 4,
IsActive = true,
LimitState = Infrastructures.Enums.LimitStates.SLS,
CalcTerm = Infrastructures.Enums.CalcTerms.LongTerm,
},
private const string ERROR_TEXT_1 = "Not all material states have functions "; };
public string CREATE_MATERIAL { get; } = "Create Function Material";
public string MODULUS_OF_ELASTYCITY { get; } = "Modulus =";
public string ADD { get; } = "Add";
public string DELETE { get; } = "Delete";
private const string ERROR_TEXT_1 = "There are no active calculation states. Please activate at least one table row.";
private const string ERROR_TEXT_2_1 = "Not all active material states have functions:";
private const string ERROR_TEXT_2_2 = "please fill in functions in these rows.";
private const string ERROR_TEXT_3_1 = "The material cannot be created because some calculation states are duplicated:";
private const string ERROR_TEXT_3_2 = "please remove or disable some duplicated rows, each state must be unique.";
private RelayCommand createFunctionMaterialCommand; private RelayCommand createFunctionMaterialCommand;
private RelayCommand addCommand;
private RelayCommand deleteCommand;
public ICommand CreateFunctionMaterialCommand public ICommand CreateFunctionMaterialCommand
{ {
get => createFunctionMaterialCommand ??= new RelayCommand(o => CreateFunctionMaterial(o)); get => createFunctionMaterialCommand ??= new RelayCommand(o => CreateFunctionMaterial(o));
} }
public ICommand AddCommand
{
get => addCommand ??= new RelayCommand(o => Add());
}
public ICommand DeleteCommand
{
get => deleteCommand ??= new RelayCommand(o => Delete(o));
}
public double Modulus { get; set; } = 2e11d; public double Modulus { get; set; } = 2e11d;
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>(); public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
public ObservableCollection<MaterialSettings> MaterialSettingsList { get; set; } = new() { new MaterialSettings() }; public ObservableCollection<MaterialSettings> MaterialSettingsList
{
get
{
return materialSettingsList;
}
set
{
materialSettingsList = value;
}
}
public FunctionMaterialCreationVM() public FunctionMaterialCreationVM()
{ {
var stressStrainFunctions = new ObservableCollection<IOneVariableFunction> var stressStrainFunctions = new List<IOneVariableFunction>
( (
ProgramSetting.Functions ProgramSetting.Functions
.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain) .Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
); );
GetFunctionsFromTree(stressStrainFunctions); GetFunctionsFromTree(stressStrainFunctions);
} }
private void GetFunctionsFromTree(ObservableCollection<IOneVariableFunction> stressStrainFunctions) private void GetFunctionsFromTree(List<IOneVariableFunction> stressStrainFunctions)
{ {
foreach (IOneVariableFunction func in stressStrainFunctions) foreach (IOneVariableFunction func in stressStrainFunctions)
{ {
@@ -49,27 +109,94 @@ namespace StructureHelperCommon.Windows
} }
} }
} }
private void Add()
{
var ms = new MaterialSettings()
{
Number = MaterialSettingsList.Count + 1,
IsActive = true,
LimitState = Infrastructures.Enums.LimitStates.ULS,
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
};
MaterialSettingsList.Add(ms);
}
private void Delete(object parameter)
{
var dataGrid = parameter as DataGrid;
var items = dataGrid.SelectedItems;
var removeList = new List<MaterialSettings>();
if (items.Count > 0)
{
if (items.Count == MaterialSettingsList.Count)
{
var firstElement = MaterialSettingsList.First();
MaterialSettingsList.Clear();
MaterialSettingsList.Add(firstElement);
}
foreach (MaterialSettings item in items)
{
removeList.Add(item);
}
foreach (MaterialSettings item in removeList)
{
MaterialSettingsList.Remove(item);
}
}
else
{
if (MaterialSettingsList.Count > 1)
{
MaterialSettingsList.RemoveAt(MaterialSettingsList.Count - 1);
}
}
for (int i = 0; i < MaterialSettingsList.Count; i++)
{
MaterialSettingsList[i].Number = i + 1;
}
dataGrid.Items.Refresh();
}
private void CreateFunctionMaterial(object parameter) private void CreateFunctionMaterial(object parameter)
{ {
// var window = parameter as Window; var window = parameter as Window;
// if (Func_ST_ULS == null || var activeMaterialSettingsList = MaterialSettingsList.Where(x => x.IsActive == true).ToList();
// Func_ST_SLS == null || if (activeMaterialSettingsList.Count() < 1)
// Func_ST_Special == null || {
// Func_LT_ULS == null || MessageBox.Show($"{ERROR_TEXT_1}");
// Func_LT_SLS == null || return;
// Func_LT_Special == null) }
// { var emptyFunctions = activeMaterialSettingsList.Where(x => x.Function == null).ToList();
// MessageBox.Show($"{ERROR_TEXT_1}"); if (emptyFunctions.Count > 0)
// return; {
// } var errorMessage = String.Empty;
// FunctionStorage.Func_ST_ULS = Func_ST_ULS; foreach (MaterialSettings ms in emptyFunctions)
// FunctionStorage.Func_ST_SLS = Func_ST_SLS; {
// FunctionStorage.Func_ST_Special = Func_ST_Special; errorMessage += $"{ms.Number}, ";
// FunctionStorage.Func_LT_ULS = Func_LT_ULS; }
// FunctionStorage.Func_LT_SLS = Func_LT_SLS; MessageBox.Show($"{ERROR_TEXT_2_1}\n{errorMessage}\n{ERROR_TEXT_2_2}");
// FunctionStorage.Func_LT_Special = Func_LT_Special; return;
// window.DialogResult = true; }
// window.Close(); var duplicates = activeMaterialSettingsList
.GroupBy(x => new { x.LimitState, x.CalcTerm })
.Where(g => g.Count() > 1)
.ToList();
if (duplicates.Count > 0)
{
var errorMessage = String.Empty;
for (int i = 0; i < duplicates.Count; i++)
{
var group = duplicates[i];
var errorNumbers = String.Empty;
foreach (MaterialSettings ms in group)
{
errorNumbers += $"{ms.Number}, ";
}
errorMessage += $"{errorNumbers}\n";
}
MessageBox.Show($"{ERROR_TEXT_3_1}\n{errorMessage}\n{ERROR_TEXT_3_2}");
return;
}
window.DialogResult = true;
window.Close();
} }
} }

View File

@@ -6,14 +6,29 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelperCommon.Windows" xmlns:local="clr-namespace:StructureHelperCommon.Windows"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums"
mc:Ignorable="d" mc:Ignorable="d"
Title="FunctionMaterial" Height="250" Width="860" Title="FunctionMaterial" Height="250" Width="860"
d:DataContext="{d:DesignInstance local:FunctionMaterialCreationVM}" d:DataContext="{d:DesignInstance local:FunctionMaterialCreationVM}"
Background="LightYellow"> Background="LightYellow">
<Window.Resources> <Window.Resources>
<ObjectDataProvider x:Key="LimitStates" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="ens:LimitStates"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="CalcTerms" MethodName="GetValues"
ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="ens:CalcTerms"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</Window.Resources> </Window.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="200"/> <ColumnDefinition Width="200"/>
<ColumnDefinition Width="100"/> <ColumnDefinition Width="100"/>
@@ -25,73 +40,72 @@
</Grid.RowDefinitions> </Grid.RowDefinitions>
<DataGrid <DataGrid
Name="DataGrid" Name="DataGrid"
Grid.ColumnSpan="4" Grid.ColumnSpan="6"
AutoGenerateColumns="False" AutoGenerateColumns="False"
CanUserDeleteRows="True" CanUserAddRows="False"
CanUserAddRows="True"
Margin="10" Margin="10"
ItemsSource="{Binding MaterialSettingsList}"> ItemsSource="{Binding MaterialSettingsList}">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn Width="50" <DataGridTextColumn Width="50"
Header="Active"> Header="№"
<DataGridTemplateColumn.CellTemplate> IsReadOnly="True"
<DataTemplate> Binding="{Binding Number, Mode=TwoWay}">
<CheckBox </DataGridTextColumn>
VerticalAlignment="Center" <DataGridCheckBoxColumn Width="50"
HorizontalAlignment="Center" Header="Active"
IsChecked="{Binding IsActive}"> Binding="{Binding IsActive}">
</CheckBox> </DataGridCheckBoxColumn>
</DataTemplate> <DataGridComboBoxColumn Width="150"
</DataGridTemplateColumn.CellTemplate> Header="Limit state"
</DataGridTemplateColumn> ItemsSource="{Binding Source={StaticResource LimitStates}}"
<DataGridTemplateColumn Width="150" SelectedItemBinding="{Binding LimitState}">
Header="Limit state"> </DataGridComboBoxColumn>
<DataGridTemplateColumn.CellTemplate> <DataGridComboBoxColumn Width="150"
<DataTemplate> Header="Calculation term"
<ComboBox SelectedItem ="{Binding LimitState}"> ItemsSource="{Binding Source={StaticResource CalcTerms}}"
</ComboBox> SelectedItemBinding="{Binding CalcTerm}">
</DataTemplate> </DataGridComboBoxColumn>
</DataGridTemplateColumn.CellTemplate> <DataGridComboBoxColumn x:Name="FunctionCB"
</DataGridTemplateColumn> Width="*"
<DataGridTemplateColumn Width="150" Header="Function"
Header="Calculation term"> SelectedItemBinding="{Binding Function}">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate> </DataGridComboBoxColumn>
<ComboBox SelectedItem ="{Binding CalcTerm}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Width="*"
Header="Function">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Functions}"
SelectedItem="{Binding Function}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<TextBlock Grid.Column="1" <TextBlock Grid.Column="3"
Grid.Row="3" Grid.Row="2"
Text="{Binding MODULUS_OF_ELASTICITY}" Text="{Binding MODULUS_OF_ELASTYCITY}"
VerticalAlignment="Center" VerticalAlignment="Center"
HorizontalAlignment="Right"> HorizontalAlignment="Right">
</TextBlock> </TextBlock>
<TextBox Grid.Column="2" <TextBox Grid.Column="4"
Grid.Row="2" Grid.Row="2"
Height="20" Height="20"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{Binding Modulus}" Text="{Binding Modulus}"
> >
</TextBox> </TextBox>
<Button Grid.Column="3" <Button Grid.Column="5"
Grid.Row="3" Grid.Row="3"
Margin="10" Margin="10"
Content="{Binding CREATE_MATERIAL}" Content="{Binding CREATE_MATERIAL}"
Command="{Binding CreateFunctionMaterialCommand}" Command="{Binding CreateFunctionMaterialCommand}"
CommandParameter="{Binding ElementName=FunctionSelectionView_win}" Click="Button_Click"/> CommandParameter="{Binding ElementName=FunctionMaterialCreationView_win}" Click="Button_Click"/>
<Button Grid.Column="0"
Grid.Row="3"
Margin="10"
Content="{Binding ADD}"
Background="LightGreen"
Command="{Binding AddCommand}">
</Button>
<Button Grid.Column="1"
Grid.Row="3"
Margin="10"
Content="{Binding DELETE}"
Background="LightPink"
Command="{Binding DeleteCommand}"
CommandParameter="{Binding ElementName=DataGrid}">
</Button>
</Grid> </Grid>
</Window> </Window>

View File

@@ -25,6 +25,8 @@ namespace StructureHelperCommon.Windows
this.ViewModel = viewModel; this.ViewModel = viewModel;
DataContext = this.ViewModel; DataContext = this.ViewModel;
InitializeComponent(); InitializeComponent();
FunctionCB.ItemsSource = viewModel.Functions;
FunctionCB.DisplayMemberPath = "FullName";
} }
public FunctionMaterialCreationView() : this(new FunctionMaterialCreationVM()) public FunctionMaterialCreationView() : this(new FunctionMaterialCreationVM())
{ {

View File

@@ -1,84 +0,0 @@
using LiveCharts.Wpf;
using StructureHelperCommon.Infrastructures.Commands;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions;
using StructureHelperCommon.Models.Materials;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
namespace StructureHelperCommon.Windows
{
public class FunctionSelectionVM
{
private RelayCommand createFunctionMaterialCommand;
public ICommand CreateFunctionMaterialCommand
{
get => createFunctionMaterialCommand ??= new RelayCommand(o => CreateFunctionMaterial(o));
}
public string SHORT_TERM { get; } = "Short Term";
public string LONG_TERM { get; } = "Long Term";
public string ULS { get; } = "Ultimate Limit State (ULS)";
public string SLS { get; } = "Serviceability Limit State (SLS)";
public string SPECIAL { get; } = "Special Limit State";
public string CREATE_MATERIAL { get; } = "Create Function Material";
private const string ERROR_TEXT_1 = "Not all material states have functions ";
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
public IOneVariableFunction Func_ST_ULS { get; set; }
public IOneVariableFunction Func_ST_SLS { get; set; }
public IOneVariableFunction Func_ST_Special { get; set; }
public IOneVariableFunction Func_LT_ULS { get; set; }
public IOneVariableFunction Func_LT_SLS { get; set; }
public IOneVariableFunction Func_LT_Special { get; set; }
public FunctionStorage FunctionStorage { get; set; } = new();
public ObservableCollection<MaterialSettings> MaterialSettings { get; set; } = new();
public FunctionSelectionVM()
{
var stressStrainFunctions = new ObservableCollection<IOneVariableFunction>
(
ProgramSetting.Functions
.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
);
GetFunctionsFromTree(stressStrainFunctions);
}
private void GetFunctionsFromTree(ObservableCollection<IOneVariableFunction> stressStrainFunctions)
{
foreach (IOneVariableFunction func in stressStrainFunctions)
{
Functions.Add(func);
if (func.Functions.Count > 0)
{
GetFunctionsFromTree(func.Functions);
}
}
}
private void CreateFunctionMaterial(object parameter)
{
var window = parameter as Window;
if (Func_ST_ULS == null ||
Func_ST_SLS == null ||
Func_ST_Special == null ||
Func_LT_ULS == null ||
Func_LT_SLS == null ||
Func_LT_Special == null)
{
MessageBox.Show($"{ERROR_TEXT_1}");
return;
}
FunctionStorage.Func_ST_ULS = Func_ST_ULS;
FunctionStorage.Func_ST_SLS = Func_ST_SLS;
FunctionStorage.Func_ST_Special = Func_ST_Special;
FunctionStorage.Func_LT_ULS = Func_LT_ULS;
FunctionStorage.Func_LT_SLS = Func_LT_SLS;
FunctionStorage.Func_LT_Special = Func_LT_Special;
window.DialogResult = true;
window.Close();
}
}
}

View File

@@ -1,95 +0,0 @@
<Window x:Class="StructureHelperCommon.Windows.FunctionSelectionView"
x:Name="FunctionSelectionView_win"
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:StructureHelperCommon.Windows"
mc:Ignorable="d"
Title="FunctionMaterial" Height="250" Width="860">
<!--Window.DataContext>
<local:FunctionSelectionVM/>
</Window.DataContext-->
<Window.Resources>
<Style x:Key="BoarderPropertyStyle" TargetType="Border">
<Setter Property="Background" Value="LightYellow"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style x:Key="BoarderValueStyle" TargetType="Border">
<Setter Property="Background" Value="AliceBlue"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style x:Key="TextBlockStyle" TargetType="TextBlock">
<Setter Property="Background" Value="LightYellow"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="FuncComboBox" TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Functions}"/>
<Setter Property="DisplayMemberPath" Value="FullName"/>
<Setter Property="Margin" Value="10"/>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="220"/>
<ColumnDefinition Width="220"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Border Grid.Column="0" Grid.Row="0"/>
<Border Grid.Column="0" Grid.Row="1" Style="{StaticResource BoarderPropertyStyle}"/>
<Border Grid.Column="0" Grid.Row="2" Style="{StaticResource BoarderPropertyStyle}"/>
<Border Grid.Column="1" Grid.Row="0" Style="{StaticResource BoarderPropertyStyle}"/>
<Border Grid.Column="1" Grid.Row="1" Style="{StaticResource BoarderValueStyle}"/>
<Border Grid.Column="1" Grid.Row="2" Style="{StaticResource BoarderValueStyle}"/>
<Border Grid.Column="2" Grid.Row="0" Style="{StaticResource BoarderPropertyStyle}"/>
<Border Grid.Column="2" Grid.Row="1" Style="{StaticResource BoarderValueStyle}"/>
<Border Grid.Column="2" Grid.Row="2" Style="{StaticResource BoarderValueStyle}"/>
<Border Grid.Column="3" Grid.Row="0" Style="{StaticResource BoarderPropertyStyle}"/>
<Border Grid.Column="3" Grid.Row="1" Style="{StaticResource BoarderValueStyle}"/>
<Border Grid.Column="3" Grid.Row="2" Style="{StaticResource BoarderValueStyle}"/>
<TextBlock Grid.Column="0" Grid.Row="1" Text="{Binding SHORT_TERM}" Style="{StaticResource TextBlockStyle}"/>
<TextBlock Grid.Column="0" Grid.Row="2" Text="{Binding LONG_TERM}" Style="{StaticResource TextBlockStyle}"/>
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding ULS}" Style="{StaticResource TextBlockStyle}"/>
<TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding SLS}" Style="{StaticResource TextBlockStyle}"/>
<TextBlock Grid.Column="3" Grid.Row="0" Text="{Binding SPECIAL}" Style="{StaticResource TextBlockStyle}"/>
<ComboBox Style="{StaticResource FuncComboBox}"
Grid.Column="1" Grid.Row="1"
SelectedItem="{Binding Func_ST_ULS}"/>
<ComboBox Style="{StaticResource FuncComboBox}"
SelectedItem="{Binding Func_LT_ULS}"
Grid.Column="1" Grid.Row="2"/>
<ComboBox Style="{StaticResource FuncComboBox}"
SelectedItem="{Binding Func_ST_SLS}"
Grid.Column="2" Grid.Row="1"/>
<ComboBox Style="{StaticResource FuncComboBox}"
SelectedItem="{Binding Func_LT_SLS}"
Grid.Column="2" Grid.Row="2"/>
<ComboBox Style="{StaticResource FuncComboBox}"
SelectedItem="{Binding Func_ST_Special}"
Grid.Column="3" Grid.Row="1"/>
<ComboBox Style="{StaticResource FuncComboBox}"
SelectedItem="{Binding Func_LT_Special}"
Grid.Column="3" Grid.Row="2"/>
<Button Grid.Column="3"
Grid.Row="3"
Margin="10"
Content="{Binding CREATE_MATERIAL}"
Command="{Binding CreateFunctionMaterialCommand}"
CommandParameter="{Binding ElementName=FunctionSelectionView_win}"/>
</Grid>
</Window>

View File

@@ -1,33 +0,0 @@
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 StructureHelperCommon.Windows
{
/// <summary>
/// Interaction logic for FunctionSelection.xaml
/// </summary>
public partial class FunctionSelectionView : Window
{
public FunctionSelectionVM ViewModel { get; set; }
public FunctionSelectionView(FunctionSelectionVM viewModel)
{
this.ViewModel = viewModel;
DataContext = this.ViewModel;
InitializeComponent();
}
public FunctionSelectionView() : this(new FunctionSelectionVM())
{
}
}
}

View File

@@ -116,7 +116,6 @@ namespace StructureHelperLogics.Models.Materials
Modulus = functionMaterialCreationView.ViewModel.Modulus, Modulus = functionMaterialCreationView.ViewModel.Modulus,
CompressiveStrength = 4e8d, CompressiveStrength = 4e8d,
TensileStrength = 4e8d, TensileStrength = 4e8d,
//FunctionStorage = functionMaterialCreationView.ViewModel.FunctionStorage,
MaterialSettings = functionMaterialCreationView.ViewModel.MaterialSettingsList.ToList(), MaterialSettings = functionMaterialCreationView.ViewModel.MaterialSettingsList.ToList(),
}; };
if (functionMaterialCreationView.DialogResult == true) if (functionMaterialCreationView.DialogResult == true)

View File

@@ -22,7 +22,6 @@ namespace StructureHelperLogics.Models.Materials
public double TensileStrength { get; set; } public double TensileStrength { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new(); public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
public IOneVariableFunction Function { get; set; } public IOneVariableFunction Function { get; set; }
public FunctionStorage FunctionStorage { get; set; }
public List<MaterialSettings> MaterialSettings { get; set; } public List<MaterialSettings> MaterialSettings { get; set; }
public Guid Id { get; } public Guid Id { get; }

View File

@@ -1,5 +1,6 @@
using StructureHelperCommon.Infrastructures.Interfaces; using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Functions; using StructureHelperCommon.Models.Functions;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries; using StructureHelperCommon.Models.Materials.Libraries;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -15,7 +16,7 @@ namespace StructureHelperLogics.Models.Materials
double CompressiveStrength { get; set; } double CompressiveStrength { get; set; }
double TensileStrength { get; set; } double TensileStrength { get; set; }
List<IMaterialSafetyFactor> SafetyFactors { get; } List<IMaterialSafetyFactor> SafetyFactors { get; }
public FunctionStorage FunctionStorage { get; set; } public List<MaterialSettings> MaterialSettings { get; set; }
public IOneVariableFunction Function { get; set; } public IOneVariableFunction Function { get; set; }

View File

@@ -12,36 +12,14 @@ namespace StructureHelperLogics.Models.Materials.Logics
{ {
IMaterial material = new Material(); IMaterial material = new Material();
material.InitModulus = functionMaterial.Modulus; material.InitModulus = functionMaterial.Modulus;
if (calcTerm == CalcTerms.ShortTerm) functionMaterial.Function = functionMaterial.MaterialSettings
{ .Where(
if (limitState == LimitStates.ULS) x => x.LimitState.Equals(limitState)
{ &&
functionMaterial.Function = functionMaterial.FunctionStorage.Func_ST_ULS; x.CalcTerm.Equals(calcTerm)
} )
else if (limitState == LimitStates.SLS) .Select(x => x.Function)
{ .First();
functionMaterial.Function = functionMaterial.FunctionStorage.Func_ST_SLS;
}
else if (limitState == LimitStates.Special)
{
functionMaterial.Function = functionMaterial.FunctionStorage.Func_ST_Special;
}
}
else if (calcTerm == CalcTerms.LongTerm)
{
if (limitState == LimitStates.ULS)
{
functionMaterial.Function = functionMaterial.FunctionStorage.Func_LT_ULS;
}
else if (limitState == LimitStates.SLS)
{
functionMaterial.Function = functionMaterial.FunctionStorage.Func_LT_SLS;
}
else if (limitState == LimitStates.Special)
{
functionMaterial.Function = functionMaterial.FunctionStorage.Func_LT_Special;
}
}
this.functionMaterial = functionMaterial; this.functionMaterial = functionMaterial;
material.Diagram = GetStressByStrain; material.Diagram = GetStressByStrain;
return material; return material;