Binding function by states and terms done

This commit is contained in:
Иван Ивашкин
2025-03-04 14:11:41 +05:00
parent 0a7a696b5f
commit 45dc56a63e
12 changed files with 165 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Commands;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Functions;
using System;
@@ -7,17 +8,54 @@ 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; } = ProgramSetting.Functions;
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();
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,4 +1,5 @@
<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"
@@ -67,20 +68,28 @@
<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"/>
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}"/>
Content="{Binding CREATE_MATERIAL}"
Command="{Binding CreateFunctionMaterialCommand}"
CommandParameter="{Binding ElementName=FunctionSelectionView_win}"/>
</Grid>
</Window>

View File

@@ -19,11 +19,11 @@ namespace StructureHelperCommon.Windows
/// </summary>
public partial class FunctionSelectionView : Window
{
private FunctionSelectionVM viewModel;
public FunctionSelectionVM ViewModel { get; set; }
public FunctionSelectionView(FunctionSelectionVM viewModel)
{
this.viewModel = viewModel;
DataContext = this.viewModel;
this.ViewModel = viewModel;
DataContext = this.ViewModel;
InitializeComponent();
}
public FunctionSelectionView() : this(new FunctionSelectionVM())