Change ObsCollection to List in Common, write FunctionMaterialCreationVM, remove old UI, binding enums and functions to new UI.
This commit is contained in:
@@ -118,7 +118,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
}
|
||||
public GraphViewModel()
|
||||
{
|
||||
Functions = ProgramSetting.Functions;
|
||||
Functions = new ObservableCollection<IOneVariableFunction>(ProgramSetting.Functions);
|
||||
}
|
||||
private void AddTable()
|
||||
{
|
||||
@@ -226,7 +226,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
ProgramSetting.Functions = Functions;
|
||||
ProgramSetting.Functions = new List<IOneVariableFunction>(Functions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
return new TableFunction()
|
||||
{
|
||||
Name = "func0",
|
||||
Functions = new ObservableCollection<IOneVariableFunction>()
|
||||
Functions = new List<IOneVariableFunction>()
|
||||
{
|
||||
new FormulaFunction()
|
||||
{
|
||||
@@ -29,7 +29,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func1.3",
|
||||
Functions = new ObservableCollection<IOneVariableFunction>()
|
||||
Functions = new List<IOneVariableFunction>()
|
||||
{
|
||||
new FormulaFunction()
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
public double MinArg { 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();
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public double MaxArg { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string Trace { get; set; }
|
||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||
public List<IOneVariableFunction> Functions { get; set; }
|
||||
|
||||
public bool Check();
|
||||
public double GetByX(double xValue);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
SubVersionNumber = 0
|
||||
};
|
||||
}
|
||||
public static ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>
|
||||
public static List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>
|
||||
{
|
||||
new TableFunction()
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
}
|
||||
}
|
||||
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 MaxArg { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public string Description { get; set; }
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
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 MaxArg { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace StructureHelperCommon.Models.Materials
|
||||
{
|
||||
public class MaterialSettings
|
||||
{
|
||||
public int Number { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
|
||||
@@ -5,16 +5,10 @@
|
||||
<Compile Update="Windows\FunctionMaterialCreationView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\FunctionSelectionView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Windows\FunctionMaterialCreationView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\FunctionSelectionView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -4,6 +4,7 @@ using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -11,34 +12,93 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelperCommon.Windows
|
||||
{
|
||||
public class FunctionMaterialCreationVM
|
||||
{
|
||||
public string CREATE_MATERIAL { get; } = "Create Function Material";
|
||||
public string MODULUS_OF_ELASTICITY { get; } = "Modulus of elasticity = ";
|
||||
private ObservableCollection<MaterialSettings> materialSettingsList = new()
|
||||
{
|
||||
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 addCommand;
|
||||
private RelayCommand deleteCommand;
|
||||
public ICommand CreateFunctionMaterialCommand
|
||||
{
|
||||
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 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()
|
||||
{
|
||||
var stressStrainFunctions = new ObservableCollection<IOneVariableFunction>
|
||||
var stressStrainFunctions = new List<IOneVariableFunction>
|
||||
(
|
||||
ProgramSetting.Functions
|
||||
.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
|
||||
);
|
||||
GetFunctionsFromTree(stressStrainFunctions);
|
||||
}
|
||||
private void GetFunctionsFromTree(ObservableCollection<IOneVariableFunction> stressStrainFunctions)
|
||||
private void GetFunctionsFromTree(List<IOneVariableFunction> 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)
|
||||
{
|
||||
// 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();
|
||||
var window = parameter as Window;
|
||||
var activeMaterialSettingsList = MaterialSettingsList.Where(x => x.IsActive == true).ToList();
|
||||
if (activeMaterialSettingsList.Count() < 1)
|
||||
{
|
||||
MessageBox.Show($"{ERROR_TEXT_1}");
|
||||
return;
|
||||
}
|
||||
var emptyFunctions = activeMaterialSettingsList.Where(x => x.Function == null).ToList();
|
||||
if (emptyFunctions.Count > 0)
|
||||
{
|
||||
var errorMessage = String.Empty;
|
||||
foreach (MaterialSettings ms in emptyFunctions)
|
||||
{
|
||||
errorMessage += $"{ms.Number}, ";
|
||||
}
|
||||
MessageBox.Show($"{ERROR_TEXT_2_1}\n{errorMessage}\n{ERROR_TEXT_2_2}");
|
||||
return;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,14 +6,29 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:StructureHelperCommon.Windows"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums"
|
||||
mc:Ignorable="d"
|
||||
Title="FunctionMaterial" Height="250" Width="860"
|
||||
d:DataContext="{d:DesignInstance local:FunctionMaterialCreationVM}"
|
||||
Background="LightYellow">
|
||||
<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>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
@@ -25,73 +40,72 @@
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid
|
||||
Name="DataGrid"
|
||||
Grid.ColumnSpan="4"
|
||||
Grid.ColumnSpan="6"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserDeleteRows="True"
|
||||
CanUserAddRows="True"
|
||||
CanUserAddRows="False"
|
||||
Margin="10"
|
||||
ItemsSource="{Binding MaterialSettingsList}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="50"
|
||||
Header="Active">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
IsChecked="{Binding IsActive}">
|
||||
</CheckBox>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Width="150"
|
||||
Header="Limit state">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<ComboBox SelectedItem ="{Binding LimitState}">
|
||||
</ComboBox>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Width="150"
|
||||
Header="Calculation term">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<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>
|
||||
<DataGridTextColumn Width="50"
|
||||
Header="№"
|
||||
IsReadOnly="True"
|
||||
Binding="{Binding Number, Mode=TwoWay}">
|
||||
</DataGridTextColumn>
|
||||
<DataGridCheckBoxColumn Width="50"
|
||||
Header="Active"
|
||||
Binding="{Binding IsActive}">
|
||||
</DataGridCheckBoxColumn>
|
||||
<DataGridComboBoxColumn Width="150"
|
||||
Header="Limit state"
|
||||
ItemsSource="{Binding Source={StaticResource LimitStates}}"
|
||||
SelectedItemBinding="{Binding LimitState}">
|
||||
</DataGridComboBoxColumn>
|
||||
<DataGridComboBoxColumn Width="150"
|
||||
Header="Calculation term"
|
||||
ItemsSource="{Binding Source={StaticResource CalcTerms}}"
|
||||
SelectedItemBinding="{Binding CalcTerm}">
|
||||
</DataGridComboBoxColumn>
|
||||
<DataGridComboBoxColumn x:Name="FunctionCB"
|
||||
Width="*"
|
||||
Header="Function"
|
||||
SelectedItemBinding="{Binding Function}">
|
||||
|
||||
</DataGridComboBoxColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="3"
|
||||
Text="{Binding MODULUS_OF_ELASTICITY}"
|
||||
<TextBlock Grid.Column="3"
|
||||
Grid.Row="2"
|
||||
Text="{Binding MODULUS_OF_ELASTYCITY}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right">
|
||||
</TextBlock>
|
||||
<TextBox Grid.Column="2"
|
||||
<TextBox Grid.Column="4"
|
||||
Grid.Row="2"
|
||||
Height="20"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Modulus}"
|
||||
>
|
||||
</TextBox>
|
||||
<Button Grid.Column="3"
|
||||
<Button Grid.Column="5"
|
||||
Grid.Row="3"
|
||||
Margin="10"
|
||||
Content="{Binding CREATE_MATERIAL}"
|
||||
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>
|
||||
</Window>
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace StructureHelperCommon.Windows
|
||||
this.ViewModel = viewModel;
|
||||
DataContext = this.ViewModel;
|
||||
InitializeComponent();
|
||||
FunctionCB.ItemsSource = viewModel.Functions;
|
||||
FunctionCB.DisplayMemberPath = "FullName";
|
||||
}
|
||||
public FunctionMaterialCreationView() : this(new FunctionMaterialCreationVM())
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
@@ -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())
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
Modulus = functionMaterialCreationView.ViewModel.Modulus,
|
||||
CompressiveStrength = 4e8d,
|
||||
TensileStrength = 4e8d,
|
||||
//FunctionStorage = functionMaterialCreationView.ViewModel.FunctionStorage,
|
||||
MaterialSettings = functionMaterialCreationView.ViewModel.MaterialSettingsList.ToList(),
|
||||
};
|
||||
if (functionMaterialCreationView.DialogResult == true)
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public double TensileStrength { get; set; }
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public IOneVariableFunction Function { get; set; }
|
||||
public FunctionStorage FunctionStorage { get; set; }
|
||||
public List<MaterialSettings> MaterialSettings { get; set; }
|
||||
|
||||
public Guid Id { get; }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,7 +16,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
double CompressiveStrength { get; set; }
|
||||
double TensileStrength { get; set; }
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; }
|
||||
public FunctionStorage FunctionStorage { get; set; }
|
||||
public List<MaterialSettings> MaterialSettings { get; set; }
|
||||
public IOneVariableFunction Function { get; set; }
|
||||
|
||||
|
||||
|
||||
@@ -12,36 +12,14 @@ namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
IMaterial material = new Material();
|
||||
material.InitModulus = functionMaterial.Modulus;
|
||||
if (calcTerm == CalcTerms.ShortTerm)
|
||||
{
|
||||
if (limitState == LimitStates.ULS)
|
||||
{
|
||||
functionMaterial.Function = functionMaterial.FunctionStorage.Func_ST_ULS;
|
||||
}
|
||||
else if (limitState == LimitStates.SLS)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
functionMaterial.Function = functionMaterial.MaterialSettings
|
||||
.Where(
|
||||
x => x.LimitState.Equals(limitState)
|
||||
&&
|
||||
x.CalcTerm.Equals(calcTerm)
|
||||
)
|
||||
.Select(x => x.Function)
|
||||
.First();
|
||||
this.functionMaterial = functionMaterial;
|
||||
material.Diagram = GetStressByStrain;
|
||||
return material;
|
||||
|
||||
Reference in New Issue
Block a user