Add value diagram windows and view models
This commit is contained in:
@@ -46,7 +46,6 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
private ShowProgressLogic showProgressLogic;
|
||||
private InteractionDiagramLogic interactionDiagramLogic;
|
||||
private static readonly ShowCrackResultLogic showCrackResultLogic = new();
|
||||
//private static readonly ShowCrackWidthLogic showCrackWidthLogic = new();
|
||||
private IForceCalculatorResult resultModel;
|
||||
private IEnumerable<INdmPrimitive> ndmPrimitives;
|
||||
private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.UserControls.States;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculatorInputDataViewModel : ViewModelBase
|
||||
{
|
||||
private IValueDiagramCalculatorInputData inputData;
|
||||
private ICrossSectionRepository repository;
|
||||
|
||||
public bool CheckStrainLimit
|
||||
{
|
||||
get => inputData.CheckStrainLimit;
|
||||
set
|
||||
{
|
||||
inputData.CheckStrainLimit = value;
|
||||
OnPropertyChanged(nameof(CheckStrainLimit));
|
||||
}
|
||||
}
|
||||
public SourceTargetVM<IForceAction> CombinationViewModel { get; }
|
||||
public SourceTargetVM<PrimitiveBase> PrimitivesViewModel { get; }
|
||||
public StateCalcTermPairViewModel StateCalcTermPairViewModel { get; }
|
||||
public ValueDiagramsViewModel ValueDiagramsViewModel { get; }
|
||||
|
||||
public ValueDiagramCalculatorInputDataViewModel(ICrossSectionRepository repository, IValueDiagramCalculatorInputData inputData)
|
||||
{
|
||||
this.inputData = inputData;
|
||||
this.repository = repository;
|
||||
StateCalcTermPairViewModel = new(inputData.StateTermPair);
|
||||
ValueDiagramsViewModel = new(inputData.Digrams);
|
||||
CombinationViewModel = SourceTargetFactory.GetSourceTargetVM(repository.ForceActions, inputData.ForceActions);
|
||||
PrimitivesViewModel = SourceTargetFactory.GetSourceTargetVM(repository.Primitives, inputData.Primitives);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
var combinations = CombinationViewModel.GetTargetItems();
|
||||
inputData.ForceActions.Clear();
|
||||
foreach (var item in combinations)
|
||||
{
|
||||
inputData.ForceActions.Add(item);
|
||||
}
|
||||
inputData.Primitives.Clear();
|
||||
foreach (var item in PrimitivesViewModel.GetTargetItems())
|
||||
{
|
||||
inputData.Primitives.Add(item.GetNdmPrimitive());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams.ValueDiagramCalculatorView"
|
||||
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.CalculatorsViews.ValueDiagrams"
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
|
||||
d:DataContext="{d:DesignInstance local:ValueDiagramCalculatorViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Value Diagram Calculator" Height="250" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Closing="Window_Closing">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TabControl>
|
||||
<TabItem Header="Main">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Name"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Show trace data"/>
|
||||
<CheckBox Grid.Column="1" Grid.Row="1" Margin="0,3" IsChecked="{Binding ShowTraceData}"/>
|
||||
<TextBlock Grid.Row="2" Text="Limit state"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="2" ItemsSource="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitStatesCollection}" SelectedItem="{Binding InputDataViewModel.StateCalcTermPairViewModel.LimitState}"/>
|
||||
<TextBlock Grid.Row="3" Text="Calc term"/>
|
||||
<ComboBox Grid.Column="1" Grid.Row="3" ItemsSource="{Binding InputDataViewModel.StateCalcTermPairViewModel.CalcTermsCollection}" SelectedItem="{Binding InputDataViewModel.StateCalcTermPairViewModel.CalcTerm}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Forces">
|
||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.CombinationViewModel}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Primitives">
|
||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding InputDataViewModel.PrimitivesViewModel}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Value diagrams" DataContext="{Binding InputDataViewModel.ValueDiagramsViewModel}">
|
||||
<DockPanel>
|
||||
<ToolBarTray DockPanel.Dock="Top">
|
||||
<ToolBar Name="Add">
|
||||
<Button Style="{DynamicResource ToolButton24}" Command="{Binding Add}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Add vertex"
|
||||
IconContent="{StaticResource AddEntity}"
|
||||
DescriptionText="Adds new vertex in the and of polygon"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{StaticResource AddEntity}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ToolButton24}" Command="{Binding Copy}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Copy Analysis"
|
||||
IconContent="{StaticResource CopyAnalysis}"
|
||||
DescriptionText="Creates copy of selected analysis"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox Width="24" Height="24">
|
||||
<ContentControl ContentTemplate="{DynamicResource CopyAnalysis}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ToolButton24}" Command="{Binding Edit}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Edit Analysis"
|
||||
IconContent="{StaticResource EditAnalysis}"
|
||||
DescriptionText="Edit selected analysis"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox Width="24" Height="24">
|
||||
<ContentControl ContentTemplate="{DynamicResource EditAnalysis}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
<ToolBar Name="Delete">
|
||||
<Button Style="{DynamicResource ToolButton24}" Command="{Binding Delete}">
|
||||
<Button.ToolTip>
|
||||
<uc:ButtonToolTipEh HeaderText="Delete digram"
|
||||
IconContent="{StaticResource TableRowDelete}"
|
||||
DescriptionText="Removes selected vertex"/>
|
||||
</Button.ToolTip>
|
||||
<Viewbox Width="24" Height="24">
|
||||
<ContentControl ContentTemplate="{DynamicResource DeleteEntity}"/>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</ToolBarTray>
|
||||
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<CheckBox IsChecked="{Binding IsTaken}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ValueDiagramCalculatorView.xaml
|
||||
/// </summary>
|
||||
public partial class ValueDiagramCalculatorView : Window
|
||||
{
|
||||
private ValueDiagramCalculatorViewModel vm;
|
||||
|
||||
public ValueDiagramCalculatorView(ValueDiagramCalculatorViewModel vm)
|
||||
{
|
||||
this.vm = vm;
|
||||
vm.ParentWindow = this;
|
||||
this.DataContext = this.vm;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
vm.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramCalculatorViewModel : OkCancelViewModelBase
|
||||
{
|
||||
private IValueDiagramCalculator valueDiagramCalculator;
|
||||
|
||||
public bool ShowTraceData
|
||||
{
|
||||
get => valueDiagramCalculator.ShowTraceData;
|
||||
set
|
||||
{
|
||||
valueDiagramCalculator.ShowTraceData = value;
|
||||
OnPropertyChanged(nameof(ShowTraceData));
|
||||
}
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => valueDiagramCalculator.Name;
|
||||
set
|
||||
{
|
||||
valueDiagramCalculator.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
public ValueDiagramCalculatorInputDataViewModel InputDataViewModel { get; set; }
|
||||
|
||||
public ValueDiagramCalculatorViewModel(ICrossSectionRepository repository, IValueDiagramCalculator valueDiagramCalculator)
|
||||
{
|
||||
this.valueDiagramCalculator = valueDiagramCalculator;
|
||||
InputDataViewModel = new(repository, valueDiagramCalculator.InputData);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
InputDataViewModel.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams.ValueDiagramEntityView"
|
||||
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.CalculatorsViews.ValueDiagrams"
|
||||
xmlns:uc="clr-namespace:StructureHelper.Windows.UserControls"
|
||||
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
|
||||
d:DataContext="{d:DesignInstance local:ValueDiagramEntityViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Value Diagram" Height="250" Width="300" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="15"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Take"/>
|
||||
<CheckBox Grid.Column="1" Margin="0,3" IsChecked="{Binding IsTaken}"/>
|
||||
<TextBlock Grid.Row="1" Text="Name"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Margin="30,0,0,0" Text="X"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="0" Margin="30,0,0,0" Text="Y"/>
|
||||
<TextBlock Grid.Row="1" Text="Start point"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding ValueDiagram.Point2DRange.StartPoint.X, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBox Grid.Column="2" Grid.Row="1" Text="{Binding ValueDiagram.Point2DRange.StartPoint.Y, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="2" Text="End point"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding ValueDiagram.Point2DRange.EndPoint.X, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBox Grid.Column="2" Grid.Row="2" Text="{Binding ValueDiagram.Point2DRange.EndPoint.Y, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ValueDiagramEntityView.xaml
|
||||
/// </summary>
|
||||
public partial class ValueDiagramEntityView : Window
|
||||
{
|
||||
private readonly ValueDiagramEntityViewModel viewModel;
|
||||
|
||||
public ValueDiagramEntityView(ValueDiagramEntityViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.viewModel = viewModel;
|
||||
this.DataContext = this.viewModel;
|
||||
viewModel.ParentWindow = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramEntityViewModel : OkCancelViewModelBase
|
||||
{
|
||||
private IValueDiagramEntity valueDiagramEntity;
|
||||
|
||||
public bool IsTaken
|
||||
{
|
||||
get => valueDiagramEntity.IsTaken;
|
||||
set
|
||||
{
|
||||
valueDiagramEntity.IsTaken = value;
|
||||
OnPropertyChanged(nameof(IsTaken));
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => valueDiagramEntity.Name;
|
||||
set
|
||||
{
|
||||
valueDiagramEntity.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
public ValueDiagramViewModel ValueDiagram { get; set; }
|
||||
public ValueDiagramEntityViewModel(IValueDiagramEntity valueDiagramEntity)
|
||||
{
|
||||
this.valueDiagramEntity = valueDiagramEntity;
|
||||
ValueDiagram = new(valueDiagramEntity.ValueDigram);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.Shapes;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramViewModel : ViewModelBase
|
||||
{
|
||||
private IValueDiagram valueDiagram;
|
||||
|
||||
public int StepNumber
|
||||
{
|
||||
get => valueDiagram.StepNumber;
|
||||
set
|
||||
{
|
||||
valueDiagram.StepNumber = value;
|
||||
OnPropertyChanged(nameof(StepNumber));
|
||||
}
|
||||
}
|
||||
public Point2DRangeViewModel Point2DRange { get; set; }
|
||||
|
||||
public ValueDiagramViewModel(IValueDiagram valueDiagram)
|
||||
{
|
||||
this.valueDiagram = valueDiagram;
|
||||
Point2DRange = new(valueDiagram.Point2DRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.BeamShears;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ValueDiagrams;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ValueDiagrams
|
||||
{
|
||||
public class ValueDiagramsViewModel : SelectItemVM<IValueDiagramEntity>
|
||||
{
|
||||
private IUpdateStrategy<IValueDiagramEntity> updateStrategy;
|
||||
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new ValueDiagramEntity(Guid.NewGuid())
|
||||
{
|
||||
IsTaken = true,
|
||||
Name = "New Value Diagram"
|
||||
};
|
||||
NewItem.ValueDigram.StepNumber = 50;
|
||||
NewItem.ValueDigram.Point2DRange.StartPoint.Y = 0.25;
|
||||
NewItem.ValueDigram.Point2DRange.EndPoint.Y = - 0.25;
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
if (SelectedItem is null) { return; }
|
||||
IValueDiagramEntity cloneDiagram = (IValueDiagramEntity)SelectedItem.Clone();
|
||||
var vm = new ValueDiagramEntityViewModel(SelectedItem);
|
||||
var wnd = new ValueDiagramEntityView(vm);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult != true)
|
||||
{
|
||||
updateStrategy ??= new ValueDiagramEntityUpdateStrategy();
|
||||
updateStrategy.Update(SelectedItem, cloneDiagram);
|
||||
}
|
||||
base.EditMethod(parameter);
|
||||
}
|
||||
public override void DeleteMethod(object parameter)
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Delete diagram?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
base.DeleteMethod(parameter);
|
||||
}
|
||||
}
|
||||
public ValueDiagramsViewModel(List<IValueDiagramEntity> collection) : base(collection)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user