LimitCarveCalculator Edit Window was changed

This commit is contained in:
Evgeny Redikultsev
2024-01-21 14:21:38 +05:00
parent 3a1cf5fa71
commit b9f13193af
27 changed files with 462 additions and 160 deletions

View File

@@ -33,7 +33,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public SelectItemsVM<PredicateEntry> PredicateItems { get; private set; }
public SelectItemsVM<LimitStateEntity> LimitStateItems { get; private set; }
public SelectItemsVM<CalcTermEntity> CalcTermITems { get; private set; }
public bool ShowPrimitivesTab { get; set; }
public int PointCount
{
@@ -77,8 +76,11 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public void RefreshInputData()
{
inputData.LimitStates.Clear();
inputData.LimitStates.AddRange(LimitStateItems.SelectedItems.Select(x => x.LimitState));
inputData.CalcTerms.Clear();
inputData.CalcTerms.AddRange(CalcTermITems.SelectedItems.Select(x => x.CalcTerm));
inputData.PredicateEntries.Clear();
inputData.PredicateEntries.AddRange(PredicateItems.SelectedItems);
inputData.PrimitiveSeries.Clear();
foreach (var item in PrimitiveSeries.Collection)
@@ -127,13 +129,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
private void GetCalcTerms()
{
CalcTermITems = new SelectItemsVM<CalcTermEntity>(ProgramSetting.CalcTermList.CalcTerms);
CalcTermITems.SelectedItems = ProgramSetting.CalcTermList.CalcTerms.Where(x => inputData.CalcTerms.Contains(x.CalcTerm));
var selectedItems = ProgramSetting.CalcTermList.CalcTerms.Where(x => inputData.CalcTerms.Contains(x.CalcTerm));
CalcTermITems.SelectedItems = selectedItems;
CalcTermITems.ShowButtons = true;
}
private void GetLimitStates()
{
LimitStateItems = new SelectItemsVM<LimitStateEntity>(ProgramSetting.LimitStatesList.LimitStates);
LimitStateItems.SelectedItems = ProgramSetting.LimitStatesList.LimitStates.Where(x => inputData.LimitStates.Contains(x.LimitState));
var selectedItems = ProgramSetting.LimitStatesList.LimitStates.Where(x => inputData.LimitStates.Contains(x.LimitState));
LimitStateItems.SelectedItems = selectedItems;
LimitStateItems.ShowButtons = true;
}
@@ -148,6 +152,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{ Name = "Cracking", PredicateType = PredicateTypes.Cracking },
}
);
PredicateItems.SelectedItems = inputData.PredicateEntries;
PredicateItems.ShowButtons = true;
}
}

View File

@@ -86,9 +86,9 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
{
var inputData = new LimitCurveInputData(ndmPrimitives);
var vm = new LimitCurveDataViewModel(inputData, ndmPrimitives);
vm.LimitStateItems.SetIsSelected();
vm.CalcTermITems.SetIsSelected();
vm.ShowPrimitivesTab = true;
//vm.LimitStateItems.SetIsSelected();
//vm.CalcTermITems.SetIsSelected();
//vm.PredicateItems.SetIsSelected();
var wnd = new LimitCurveDataView(vm);
wnd.ShowDialog();
if (wnd.DialogResult != true) return;
@@ -382,6 +382,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
forcesResults = forceCalculator.Result as IForcesResults;
ndmPrimitives = forceCalculator.Primitives;
}
private void ShowIsoField()
{
try

View File

@@ -1,4 +1,4 @@
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.InteractionDiagramCalculatorView"
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.LimitCurveCalculatorView"
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"
@@ -7,47 +7,25 @@
xmlns:fc="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews"
d:DataContext ="{d:DesignInstance local:LimitCurveCalculatorViewModel}"
mc:Ignorable="d"
Title="Limit Curve Calculator" Height="300" Width="400" MinHeight="300" MinWidth="400">
Title="Limit Curve Calculator" Height="390" Width="400" MinHeight="300" MinWidth="400" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Logic">
<!--<local:SorroundDataControl/>-->
</TabItem>
<TabItem Header="Primitives">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding PrimitivesViewModel}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Column="1" Margin="2">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
</StackPanel>
</Grid>
</TabItem>
<TabItem Header="Predicates">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
<TabItem Header="States">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
<TabItem Header="Terms">
<ContentControl ContentTemplate="{StaticResource ResourceKey=SelectItems}" Content="{Binding YItems}"/>
</TabItem>
</TabControl>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<fc:LimitCurveControl Grid.Row="1" Grid.ColumnSpan="2" x:Name="CurveData" LimitCurveViewModel="{Binding LimitCurveDataViewModel}"/>
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -17,11 +17,16 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// <summary>
/// Логика взаимодействия для InteractionDiagramCalculatorView.xaml
/// </summary>
public partial class InteractionDiagramCalculatorView : Window
public partial class LimitCurveCalculatorView : Window
{
public InteractionDiagramCalculatorView()
LimitCurveCalculatorViewModel viewModel;
public LimitCurveCalculatorView(LimitCurveCalculatorViewModel viewModel)
{
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
InitializeComponent();
this.DataContext = this.viewModel;
CurveData.LimitCurveViewModel = this.viewModel.LimitCurveDataViewModel;
}
}
}

View File

@@ -1,4 +1,8 @@
using StructureHelper.Windows.ViewModels;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces.LimitCurve;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -10,8 +14,29 @@ using System.Threading.Tasks;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
internal class LimitCurveCalculatorViewModel : OkCancelViewModelBase
public class LimitCurveCalculatorViewModel : OkCancelViewModelBase
{
LimitCurvesCalculator calculator;
public string Name
{
get => calculator.Name;
set
{
calculator.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public LimitCurveDataViewModel LimitCurveDataViewModel { get; }
public LimitCurveCalculatorViewModel(LimitCurvesCalculator calculator, IEnumerable<INdmPrimitive> allowedPrimitives)
{
this.calculator = calculator;
LimitCurveDataViewModel = new LimitCurveDataViewModel(calculator.InputData, allowedPrimitives);
}
public override void OkAction()
{
LimitCurveDataViewModel.RefreshInputData();
base.OkAction();
}
}
}

View File

@@ -7,8 +7,9 @@
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
xmlns:fr="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance fr:LimitCurveDataViewModel}"
d:DesignHeight="325" d:DesignWidth="400">
<Grid DataContext="{Binding LimitCurveViewModel}">
<Grid>
<TabControl>
<TabItem Header="Limits">
<Grid>
@@ -16,7 +17,7 @@
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<local:SurroundDataControl x:Name="Data" SurroundData="{Binding SurroundData}"/>
<local:SurroundDataControl x:Name="SurData"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
@@ -43,7 +44,9 @@
<DataTemplate>
<Expander>
<Expander.Header>
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/>
<Grid MinWidth="250">
<TextBox Margin="20,0,0,0" Text="{Binding Name}"/>
</Grid>
</Expander.Header>
<Grid Width="300" Height="200">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding Value}"/>

View File

@@ -1,20 +1,8 @@
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews.ForceResultLogic;
using StructureHelper.Windows.UserControls;
using StructureHelper.Windows.ViewModels.Materials;
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.Navigation;
using System.Windows.Shapes;
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews
{
@@ -24,17 +12,27 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
public partial class LimitCurveControl : UserControl
{
public static readonly DependencyProperty LimitCurveViewModelProperty =
DependencyProperty.Register("LimitCurveViewModel", typeof(LimitCurveDataViewModel), typeof(LimitCurveControl));
DependencyProperty.Register(
"LimitCurveViewModel",
typeof(LimitCurveDataViewModel),
typeof(LimitCurveControl));
public LimitCurveDataViewModel LimitCurveViewModel
{
get { return (LimitCurveDataViewModel)GetValue(LimitCurveViewModelProperty); }
set { SetValue(LimitCurveViewModelProperty, value); }
set
{
this.DataContext = value;
SurData.ViewModel = new (value.SurroundData);
//SurData.SurroundData = value.SurroundData;
SurData.DataContext = SurData.ViewModel;
SetValue(LimitCurveViewModelProperty, value);
}
}
public LimitCurveControl()
{
InitializeComponent();
DataContext = this;
//DataContext = this;
}
private void PointCountChanged(object sender, EventArgs e)

View File

@@ -8,7 +8,7 @@
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid>
<StackPanel DataContext="{Binding ViewModel}">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>

View File

@@ -23,51 +23,43 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
/// </summary>
public partial class SurroundDataControl : UserControl
{
// Using a DependencyProperty as the backing store for SurroundData.
// This enables animation, styling, binding, etc...
public static readonly DependencyProperty SurroundDataProperty =
DependencyProperty.Register(
"SurroundData",
typeof(SurroundData),
typeof(SurroundDataControl),
new PropertyMetadata(null, OnSurroundDataChanged));
//// Using a DependencyProperty as the backing store for SurroundData.
//// This enables animation, styling, binding, etc...
//public static readonly DependencyProperty SurroundDataProperty =
// DependencyProperty.Register(
// "SurroundData",
// typeof(SurroundData),
// typeof(SurroundDataControl),
// new PropertyMetadata(null, OnSurroundDataChanged));
private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
SurroundDataControl surroundDataControl = (SurroundDataControl)d;
SurroundData newValue = (SurroundData)e.NewValue;
//private static void OnSurroundDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
//{
// SurroundDataControl surroundDataControl = (SurroundDataControl)d;
// SurroundData newValue = (SurroundData)e.NewValue;
// Handle any additional logic when the SurroundData property changes
// // Handle any additional logic when the SurroundData property changes
// Example: Update ViewModel.SurroundData
surroundDataControl.ViewModel.SurroundData = newValue;
}
// // Example: Update ViewModel.SurroundData
// surroundDataControl.ViewModel.SurroundData = newValue;
//}
private SurroundData surroundData;
public SurroundDataViewModel ViewModel { get; private set; }
//private SurroundData surroundData;
public SurroundDataViewModel ViewModel { get; set; }
public SurroundData SurroundData
{
get => (SurroundData)GetValue(SurroundDataProperty);
set
{
SetValue(SurroundDataProperty, value);
}
}
//public SurroundData SurroundData
// {
// get => (SurroundData)GetValue(SurroundDataProperty);
// set
// {
// SetValue(SurroundDataProperty, value);
// }
// }
public SurroundDataControl()
{
if (SurroundData is null)
{
ViewModel = new SurroundDataViewModel(new());
}
else
{
ViewModel = new SurroundDataViewModel(SurroundData);
}
DataContext = this; // ViewModel;
InitializeComponent();
}
{
DataContext = ViewModel;
InitializeComponent();
}
private void XmaxChanged(object sender, EventArgs e)
{

View File

@@ -31,7 +31,7 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
}
}
private void RefreshAll()
public void RefreshAll()
{
OnPropertyChanged(nameof(Logic));
OnPropertyChanged(nameof(XMax));