SourceToTargetViewModel was added
This commit is contained in:
@@ -187,6 +187,9 @@
|
||||
<Compile Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\ForceCalculatorView.xaml.cs">
|
||||
<DependentUpon>ForceCalculatorView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\CalculationWindows\CalculatorsViews\SourceToTargetControl.xaml.cs">
|
||||
<DependentUpon>SourceToTargetControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\ColorPickerWindow\ColorPickerView.xaml.cs">
|
||||
<DependentUpon>ColorPickerView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -231,9 +234,17 @@
|
||||
</Compile>
|
||||
<Compile Include="Windows\ViewModels\Calculations\CalculationProperies\CalculationPropertyViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Calculations\CalculationResult\CalculationResultViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\SourceToTargetViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Calculations\Calculators\ForceCalculatorViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Calculations\Calculators\ICombinationSourceToTargetViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Forces\ForceCombinationViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\ICRUDViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\ISourceToTargetViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Materials\HeadMaterialsViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\NdmCrossSections\CalculatorsViewModelLogic.cs" />
|
||||
<Compile Include="Windows\ViewModels\NdmCrossSections\ForceCombinationViewModelLogic.cs" />
|
||||
<Compile Include="Windows\ViewModels\NdmCrossSections\ICalculatorsViewModelLogic.cs" />
|
||||
<Compile Include="Windows\ViewModels\NdmCrossSections\IForceCombinationViewModelLogic.cs" />
|
||||
<Compile Include="Windows\ViewModels\PrimitiveProperties\PrimitivePropertiesViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\Primitives\RectangleControlViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\PrimitiveTemplates\RCs\RectangleBeamViewModel.cs" />
|
||||
@@ -296,6 +307,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\CalculationWindows\CalculatorsViews\SourceToTargetControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\ColorPickerWindow\ColorPickerView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -16,14 +16,14 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
public List<IForceCombinationList> ForceCombinationLists { get; private set; }
|
||||
public List<IHeadMaterial> HeadMaterials { get; private set; }
|
||||
public List<INdmPrimitive> Primitives { get; }
|
||||
public List<INdmCalculator> Calculators { get; private set; }
|
||||
public List<INdmCalculator> CalculatorsList { get; private set; }
|
||||
|
||||
public CrossSectionRepository()
|
||||
{
|
||||
ForceCombinationLists = new List<IForceCombinationList>();
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
Primitives = new List<INdmPrimitive>();
|
||||
Calculators = new List<INdmCalculator>();
|
||||
CalculatorsList = new List<INdmCalculator>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ namespace StructureHelperLogics.Models.CrossSections
|
||||
public interface ICrossSectionRepository : IHasHeadMaterials, IHasPrimitives
|
||||
{
|
||||
List<IForceCombinationList> ForceCombinationLists { get; }
|
||||
List<INdmCalculator> Calculators { get; }
|
||||
List<INdmCalculator> CalculatorsList { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
public class ForceCalculator : INdmCalculator
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public double IterationAccuracy { get; set; }
|
||||
public int MaxIterationCount { get; set; }
|
||||
public List<LimitStates> LimitStatesList { get; }
|
||||
public List<CalcTerms> CalcTermsList { get; }
|
||||
public List<IForceCombinationList> ForceCombinationLists { get; }
|
||||
public List<INdmPrimitive> NdmPrimitives { get; }
|
||||
public INdmResult Result { get; }
|
||||
@@ -25,6 +25,10 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
ForceCombinationLists = new List<IForceCombinationList>();
|
||||
NdmPrimitives = new List<INdmPrimitive>();
|
||||
IterationAccuracy = 0.001d;
|
||||
MaxIterationCount = 1000;
|
||||
LimitStatesList = new List<LimitStates>() { LimitStates.ULS, LimitStates.SLS };
|
||||
CalcTermsList = new List<CalcTerms>() { CalcTerms.ShortTerm, CalcTerms.LongTerm };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
|
||||
|
||||
public RectanglePrimitive()
|
||||
{
|
||||
Name = "New Rectangle";
|
||||
NdmMaxSize = 0.01d;
|
||||
NdmMinDivision = 10;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace StructureHelperTests.ViewModelTests
|
||||
{
|
||||
public class NdmPrimitiveTests
|
||||
{
|
||||
[TestCase]
|
||||
public void RectanglePrimitiveTest()
|
||||
[Test]
|
||||
public void Run_ShouldPass()
|
||||
{
|
||||
//Arrange
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018);
|
||||
|
||||
@@ -7,11 +7,31 @@
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators"
|
||||
d:DataContext="{d:DesignInstance vm:ForceCalculatorViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Analysis by forces" Height="300" Width="400" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen">
|
||||
Title="Analysis by forces" Height="300" Width="400" MinHeight="300" MinWidth="400" WindowStartupLocation="CenterScreen" Closing="Window_Closing">
|
||||
<Window.Resources>
|
||||
<Style x:Key="cbStyle" TargetType="CheckBox">
|
||||
<Setter Property="Margin" Value="0,5,0,5"/>
|
||||
</Style>
|
||||
<DataTemplate x:Key="SimpleItemTemplate">
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="SourceToTarget">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox ItemsSource="{Binding SourceItems}" SelectedItem="{Binding SelectedSourceItem}" ItemTemplate="{StaticResource ResourceKey=SimpleItemTemplate}"/>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Content="Add all" Command="{Binding AddAll}"/>
|
||||
<Button Content="Clear all" Command="{Binding ClearAll}"/>
|
||||
<Button Content=">>" Command="{Binding AddSelected}"/>
|
||||
<Button Content="<<" Command="{Binding RemoveSelected}"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Column="2" ItemsSource="{Binding TargetItems}" SelectedItem="{Binding SelectedTargetItem}" ItemTemplate="{StaticResource ResourceKey=SimpleItemTemplate}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -31,38 +51,20 @@
|
||||
</Grid>
|
||||
<GroupBox Header="Limit States">
|
||||
<StackPanel>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Ultimate Limit State" IsChecked="{Binding ULS}"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Serviceability Limit State" IsChecked="{Binding SLS}"/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Duration">
|
||||
<StackPanel>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Short Term" IsChecked="{Binding ShortTerm}"/>
|
||||
<CheckBox Style="{StaticResource cbStyle}" Content="Long Term" IsChecked="{Binding LongTerm}"/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="Forces">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox>
|
||||
|
||||
</ListBox>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Content="Add all"/>
|
||||
<Button Content="Clear all"/>
|
||||
<Button Content=">>"/>
|
||||
<Button Content="<<"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Column="2">
|
||||
|
||||
</ListBox>
|
||||
</Grid>
|
||||
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding CombinationViewModel}"/>
|
||||
</TabItem>
|
||||
<TabItem Header="Primitives">
|
||||
<Grid>
|
||||
@@ -94,13 +96,13 @@
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="170"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding Path=IterationAccuracy, ValidatesOnDataErrors=True}"/>
|
||||
<TextBlock Text="Required Accuracy" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Margin="5,5,5,5" Text="{Binding IterationAccuracy, Converter={StaticResource PlainDouble}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBlock Grid.Row="1" Text="Maximum Iteration Count" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.ColumnSpan="2"/>
|
||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding Path=MaxIterationCount, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Style="{StaticResource ValidatedError}" Grid.Column="2" Grid.Row="1" Margin="5,5,5,5" Text="{Binding MaxIterationCount, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
@@ -20,13 +20,18 @@ namespace StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalcu
|
||||
/// </summary>
|
||||
public partial class ForceCalculatorView : Window
|
||||
{
|
||||
ForceCalculatorViewModel forceCalculatorViewModel;
|
||||
ForceCalculatorViewModel viewModel;
|
||||
|
||||
public ForceCalculatorView(ForceCalculatorViewModel _forceCalculatorViewModel)
|
||||
{
|
||||
forceCalculatorViewModel = _forceCalculatorViewModel;
|
||||
DataContext = forceCalculatorViewModel;
|
||||
viewModel = _forceCalculatorViewModel;
|
||||
DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
viewModel.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<UserControl x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.SourceToTargetControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.CalculationWindows.CalculatorsViews"
|
||||
xmlns:vm ="clr-namespace:StructureHelper.Windows.ViewModels"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="200" d:DesignWidth="400">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="60"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox ItemsSource="{Binding AllowedPrimitives}"
|
||||
SelectedItem="{Binding SelectedAllowedPrimitive}"
|
||||
ItemTemplate="{StaticResource ColoredItemTemplate}">
|
||||
</ListBox>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Content="Add all" Command="{Binding AddAllPrimitivesCommand}"/>
|
||||
<Button Content="Clear all" Command="{Binding ClearAllPrimitivesCommand}"/>
|
||||
<Button Content=">>" Command="{Binding AddSelectedPrimitiveCommand}"/>
|
||||
<Button Content="<<" Command="{Binding RemoveSelectedPrimitiveCommand}"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Column="2" ItemsSource="{Binding Primitives}" SelectedItem="{Binding SelectedPrimitive}" ItemTemplate="{StaticResource ColoredItemTemplate}">
|
||||
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,34 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для SourceToTargetControl.xaml
|
||||
/// </summary>
|
||||
public partial class SourceToTargetControl : UserControl
|
||||
{
|
||||
//private ISourceToTargetViewModel<TItem> viewModel;
|
||||
|
||||
public SourceToTargetControl()
|
||||
//ISourceToTargetViewModel<TItem> viewModel)
|
||||
{
|
||||
//this.viewModel = viewModel;
|
||||
InitializeComponent();
|
||||
//DataContext = this.viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,17 +62,17 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<Expander Header="Actions" MinWidth="20">
|
||||
<Expander Header="Actions" MinWidth="20" DataContext="{Binding CombinationsLogic}">
|
||||
<Expander.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Add Force Combination" Command="{Binding AddForceCombinationCommand}"/>
|
||||
<Button Content="Add Force Combination" Command="{Binding Add}"/>
|
||||
</ContextMenu>
|
||||
</Expander.ContextMenu>
|
||||
<ListBox ItemsSource="{Binding ForceCombinationLists}" SelectedItem="{Binding SelectedForceCombinationList}">
|
||||
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Edit" Command="{Binding EditForceCombinationCommand}"/>
|
||||
<Button Content="Delete" Command="{Binding DeleteForceCombinationCommand}"/>
|
||||
<Button Content="Edit" Command="{Binding Edit}"/>
|
||||
<Button Content="Delete" Command="{Binding Delete}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListBox.ItemTemplate>
|
||||
@@ -111,17 +111,18 @@
|
||||
</ListBox.ContextMenu>
|
||||
</ListBox>
|
||||
</Expander>
|
||||
<Expander Header="Analyses" MinWidth="20">
|
||||
<Expander Header="Analyses" MinWidth="20" DataContext="{Binding CalculatorsLogic}">
|
||||
<Expander.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Add Calculator" Command="{Binding AddCalculatorCommand}"/>
|
||||
<Button Content="Add Calculator" Command="{Binding Add}"/>
|
||||
</ContextMenu>
|
||||
</Expander.ContextMenu>
|
||||
<ListBox ItemsSource="{Binding Calculators}" SelectedItem="{Binding SelectedCalculator}">
|
||||
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Edit" Command="{Binding EditCalculatorCommand}"/>
|
||||
<!--<Button Content="Delete" Command="{Binding DeleteForceCombinationCommand}"/>-->
|
||||
<Button Content="Run" Command="{Binding Run}"/>
|
||||
<Button Content="Edit" Command="{Binding Edit}"/>
|
||||
<Button Content="Delete" Command="{Binding Delete}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
<ListBox.ItemTemplate>
|
||||
|
||||
@@ -3,15 +3,11 @@ using LoaderCalculator.Logics.Geometry;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Infrastructure.UI.PrimitiveTemplates;
|
||||
using StructureHelper.MaterialCatalogWindow;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Models.Primitives.Factories;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||
using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
@@ -19,8 +15,7 @@ using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationResult;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelper.Windows.ViewModels.NdmCrossSections;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
@@ -30,15 +25,12 @@ using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
@@ -58,36 +50,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
public PrimitiveBase SelectedPrimitive { get; set; }
|
||||
public IForceCombinationList SelectedForceCombinationList { get; set; }
|
||||
public INdmCalculator SelectedCalculator { get; set; }
|
||||
|
||||
private readonly ICalculatorsViewModelLogic calculatorsLogic;
|
||||
public ICalculatorsViewModelLogic CalculatorsLogic { get => calculatorsLogic;}
|
||||
public IForceCombinationViewModelLogic CombinationsLogic { get => combinationsLogic; }
|
||||
|
||||
private MainModel Model { get; }
|
||||
public ObservableCollection<PrimitiveBase> Primitives { get; private set; }
|
||||
|
||||
public ObservableCollection<IForceCombinationList> ForceCombinationLists
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new ObservableCollection<IForceCombinationList>();
|
||||
foreach (var item in Model.Section.SectionRepository.ForceCombinationLists)
|
||||
{
|
||||
collection.Add(item);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
public ObservableCollection<INdmCalculator> Calculators
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new ObservableCollection<INdmCalculator>();
|
||||
foreach (var item in Model.Section.SectionRepository.Calculators)
|
||||
{
|
||||
collection.Add(item);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
private double panelX, panelY, scrollPanelX, scrollPanelY;
|
||||
private CalculationProperty calculationProperty;
|
||||
|
||||
@@ -187,116 +157,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
}
|
||||
public ICommand AddPrimitive { get; }
|
||||
|
||||
private ICommand addForceCombinationCommand;
|
||||
public ICommand AddForceCombinationCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return addForceCombinationCommand ??
|
||||
(
|
||||
addForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
AddForceCombination();
|
||||
OnPropertyChanged(nameof(ForceCombinationLists));
|
||||
}));
|
||||
}
|
||||
}
|
||||
private void AddForceCombination()
|
||||
{
|
||||
var item = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
Model.Section.SectionRepository.ForceCombinationLists.Add(item);
|
||||
}
|
||||
private ICommand deleteForceCombinationCommand;
|
||||
public ICommand DeleteForceCombinationCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return deleteForceCombinationCommand ??
|
||||
(
|
||||
deleteForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
DeleteForceCombination();
|
||||
OnPropertyChanged(nameof(ForceCombinationLists));
|
||||
}, o => SelectedForceCombinationList != null));
|
||||
}
|
||||
}
|
||||
private void DeleteForceCombination()
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
Model.Section.SectionRepository.ForceCombinationLists.Remove(SelectedForceCombinationList);
|
||||
}
|
||||
|
||||
}
|
||||
private ICommand editForceCombinationCommand;
|
||||
public ICommand EditForceCombinationCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return editForceCombinationCommand ??
|
||||
(
|
||||
editForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
EditForceCombination();
|
||||
OnPropertyChanged(nameof(ForceCombinationLists));
|
||||
}, o => SelectedForceCombinationList != null));
|
||||
}
|
||||
}
|
||||
private void EditForceCombination()
|
||||
{
|
||||
var wnd = new ForceCombinationView(SelectedForceCombinationList);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
private ICommand addCalculatorCommand;
|
||||
public ICommand AddCalculatorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return addCalculatorCommand ??
|
||||
(
|
||||
addCalculatorCommand = new RelayCommand(o =>
|
||||
{
|
||||
AddCalculator();
|
||||
OnPropertyChanged(nameof(Calculators));
|
||||
}));
|
||||
}
|
||||
}
|
||||
private void AddCalculator()
|
||||
{
|
||||
var item = new ForceCalculator() { Name = "New force calculator"};
|
||||
Model.Section.SectionRepository.Calculators.Add(item);
|
||||
}
|
||||
|
||||
private ICommand editCalculatorCommand;
|
||||
public ICommand EditCalculatorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return editCalculatorCommand ??
|
||||
(
|
||||
editCalculatorCommand = new RelayCommand(o =>
|
||||
{
|
||||
EditCalculator();
|
||||
OnPropertyChanged(nameof(Calculators));
|
||||
}, o => SelectedCalculator != null));
|
||||
}
|
||||
}
|
||||
private void EditCalculator()
|
||||
{
|
||||
if (SelectedCalculator is ForceCalculator)
|
||||
{
|
||||
var calculator = SelectedCalculator as ForceCalculator;
|
||||
var repository = Model.Section.SectionRepository;
|
||||
var primitives = Primitives.Select(x => x.GetNdmPrimitive()).ToArray();
|
||||
var vm = new ForceCalculatorViewModel( primitives, repository.ForceCombinationLists, calculator);
|
||||
|
||||
var wnd = new ForceCalculatorView(vm);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand Calculate { get; }
|
||||
public ICommand DeletePrimitive { get; }
|
||||
public ICommand EditCalculationPropertyCommand { get; }
|
||||
@@ -324,11 +184,14 @@ namespace StructureHelper.Windows.MainWindow
|
||||
private double delta = 0.0005;
|
||||
private double axisLineThickness;
|
||||
private double gridLineThickness;
|
||||
private IForceCombinationViewModelLogic combinationsLogic;
|
||||
|
||||
public MainViewModel(MainModel model)
|
||||
{
|
||||
Model = model;
|
||||
section = model.Section;
|
||||
combinationsLogic = new ForceCombinationViewModelLogic(repository);
|
||||
calculatorsLogic = new CalculatorsViewModelLogic(repository);
|
||||
CanvasWidth = 2d * scale;
|
||||
CanvasHeight = 1.5d * scale;
|
||||
XX2 = CanvasWidth;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
@@ -22,6 +23,31 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
IEnumerable<IForceCombinationList> allowedForceCombinations;
|
||||
ForceCalculator forcesCalculator;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return forcesCalculator.Name; }
|
||||
set { forcesCalculator.Name = value; }
|
||||
}
|
||||
|
||||
public double IterationAccuracy
|
||||
{
|
||||
get { return forcesCalculator.IterationAccuracy; }
|
||||
set { forcesCalculator.IterationAccuracy = value;}
|
||||
}
|
||||
|
||||
public int MaxIterationCount
|
||||
{
|
||||
get { return forcesCalculator.MaxIterationCount; }
|
||||
set { forcesCalculator.MaxIterationCount = value; }
|
||||
}
|
||||
|
||||
public bool ULS { get; set; }
|
||||
public bool SLS { get; set; }
|
||||
public bool ShortTerm { get; set; }
|
||||
public bool LongTerm { get; set; }
|
||||
|
||||
public ISourceToTargetViewModel<IForceCombinationList> CombinationViewModel { get; }
|
||||
|
||||
public PrimitiveBase SelectedAllowedPrimitive { get; set; }
|
||||
public PrimitiveBase SelectedPrimitive { get; set; }
|
||||
|
||||
@@ -69,7 +95,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
forcesCalculator.NdmPrimitives.Clear();
|
||||
forcesCalculator.NdmPrimitives.AddRange(allowedPrimitives);
|
||||
}
|
||||
|
||||
public ICommand ClearAllPrimitivesCommand
|
||||
{
|
||||
get
|
||||
@@ -84,7 +109,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}, o => forcesCalculator.NdmPrimitives.Count > 0 ));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand AddSelectedPrimitiveCommand
|
||||
{
|
||||
get
|
||||
@@ -99,7 +123,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}, o => SelectedAllowedPrimitive != null));
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand RemoveSelectedPrimitiveCommand
|
||||
{
|
||||
get
|
||||
@@ -120,6 +143,12 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
allowedPrimitives = _allowedPrimitives;
|
||||
allowedForceCombinations = _allowedForceCombinations;
|
||||
forcesCalculator = _forcesCalculator;
|
||||
|
||||
CombinationViewModel = new SourceToTargetViewModel<IForceCombinationList>();
|
||||
CombinationViewModel.SetTargetItems(forcesCalculator.ForceCombinationLists);
|
||||
CombinationViewModel.SetSourceItems(allowedForceCombinations);
|
||||
|
||||
InputRefresh();
|
||||
}
|
||||
|
||||
private ObservableCollection<PrimitiveBase> ConvertNdmPrimitivesToPrimitiveBase(IEnumerable<INdmPrimitive> primitives)
|
||||
@@ -141,5 +170,29 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}
|
||||
return viewItems;
|
||||
}
|
||||
|
||||
public void InputRefresh()
|
||||
{
|
||||
ULS = forcesCalculator.LimitStatesList.Contains(LimitStates.ULS);
|
||||
SLS = forcesCalculator.LimitStatesList.Contains(LimitStates.SLS);
|
||||
ShortTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.ShortTerm);
|
||||
LongTerm = forcesCalculator.CalcTermsList.Contains(CalcTerms.LongTerm);
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
var combinations = CombinationViewModel.GetTargetItems();
|
||||
forcesCalculator.ForceCombinationLists.Clear();
|
||||
foreach (var item in combinations)
|
||||
{
|
||||
forcesCalculator.ForceCombinationLists.Add(item);
|
||||
}
|
||||
forcesCalculator.LimitStatesList.Clear();
|
||||
if (ULS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.ULS); }
|
||||
if (SLS == true) { forcesCalculator.LimitStatesList.Add(LimitStates.SLS); }
|
||||
forcesCalculator.CalcTermsList.Clear();
|
||||
if (ShortTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.ShortTerm); }
|
||||
if (LongTerm == true) { forcesCalculator.CalcTermsList.Add(CalcTerms.LongTerm); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
{
|
||||
public interface ICombinationSourceToTargetViewModel : ISourceToTargetViewModel<IForceCombinationList>
|
||||
{
|
||||
}
|
||||
}
|
||||
20
Windows/ViewModels/ICRUDViewModel.cs
Normal file
20
Windows/ViewModels/ICRUDViewModel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public interface ICRUDViewModel<TItem>
|
||||
{
|
||||
TItem SelectedItem { get; set; }
|
||||
ObservableCollection<TItem> Items { get; }
|
||||
RelayCommand Add { get; }
|
||||
RelayCommand Delete { get; }
|
||||
RelayCommand Edit { get; }
|
||||
}
|
||||
}
|
||||
25
Windows/ViewModels/ISourceToTargetViewModel.cs
Normal file
25
Windows/ViewModels/ISourceToTargetViewModel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public interface ISourceToTargetViewModel<TItem>
|
||||
{
|
||||
TItem SelectedSourceItem { get; set; }
|
||||
TItem SelectedTargetItem { get; set; }
|
||||
ObservableCollection<TItem> SourceItems { get; }
|
||||
ObservableCollection<TItem> TargetItems { get; }
|
||||
RelayCommand AddAll { get; }
|
||||
RelayCommand ClearAll { get; }
|
||||
RelayCommand AddSelected { get; }
|
||||
RelayCommand RemoveSelected { get; }
|
||||
void SetSourceItems(IEnumerable<TItem> allowedItems);
|
||||
void SetTargetItems(IEnumerable<TItem> targetItems);
|
||||
IEnumerable<TItem> GetTargetItems();
|
||||
}
|
||||
}
|
||||
120
Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs
Normal file
120
Windows/ViewModels/NdmCrossSections/CalculatorsViewModelLogic.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.Calculators;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public class CalculatorsViewModelLogic : ViewModelBase, ICalculatorsViewModelLogic
|
||||
{
|
||||
private readonly ICrossSectionRepository repository;
|
||||
|
||||
public INdmCalculator SelectedItem { get; set; }
|
||||
public ObservableCollection<INdmCalculator> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new ObservableCollection<INdmCalculator>();
|
||||
foreach (var item in repository.CalculatorsList)
|
||||
{
|
||||
collection.Add(item);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
private RelayCommand addCalculatorCommand;
|
||||
public RelayCommand Add
|
||||
{
|
||||
get
|
||||
{
|
||||
return addCalculatorCommand ??
|
||||
(
|
||||
addCalculatorCommand = new RelayCommand(o =>
|
||||
{
|
||||
AddCalculator();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}));
|
||||
}
|
||||
}
|
||||
private void AddCalculator()
|
||||
{
|
||||
var item = new ForceCalculator() { Name = "New force calculator" };
|
||||
repository.CalculatorsList.Add(item);
|
||||
}
|
||||
private RelayCommand editCalculatorCommand;
|
||||
public RelayCommand Edit
|
||||
{
|
||||
get
|
||||
{
|
||||
return editCalculatorCommand ??
|
||||
(
|
||||
editCalculatorCommand = new RelayCommand(o =>
|
||||
{
|
||||
EditCalculator();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
}
|
||||
private void EditCalculator()
|
||||
{
|
||||
if (SelectedItem is ForceCalculator)
|
||||
{
|
||||
var calculator = SelectedItem as ForceCalculator;
|
||||
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceCombinationLists, calculator);
|
||||
|
||||
var wnd = new ForceCalculatorView(vm);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
}
|
||||
private RelayCommand deleteCalculatorCommand;
|
||||
private RelayCommand runCommand;
|
||||
public RelayCommand Delete
|
||||
{
|
||||
get
|
||||
{
|
||||
return deleteCalculatorCommand ??
|
||||
(
|
||||
deleteCalculatorCommand = new RelayCommand(o =>
|
||||
{
|
||||
DeleteCalculator();
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
}
|
||||
|
||||
public RelayCommand Run
|
||||
{
|
||||
get
|
||||
{
|
||||
return runCommand ??
|
||||
(
|
||||
runCommand = new RelayCommand(o =>
|
||||
{
|
||||
(SelectedItem as INdmCalculator).Run();
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteCalculator()
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Delete calculator?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
repository.CalculatorsList.Remove(SelectedItem as INdmCalculator);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}
|
||||
}
|
||||
public CalculatorsViewModelLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public class ForceCombinationViewModelLogic : ViewModelBase, IForceCombinationViewModelLogic
|
||||
{
|
||||
private readonly ICrossSectionRepository repository;
|
||||
|
||||
public IForceCombinationList SelectedItem { get; set; }
|
||||
|
||||
public ObservableCollection<IForceCombinationList> Items
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new ObservableCollection<IForceCombinationList>();
|
||||
foreach (var item in repository.ForceCombinationLists)
|
||||
{
|
||||
collection.Add(item);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
private RelayCommand addForceCombinationCommand;
|
||||
public RelayCommand Add
|
||||
{
|
||||
get
|
||||
{
|
||||
return addForceCombinationCommand ??
|
||||
(
|
||||
addForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
AddCombination();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}));
|
||||
}
|
||||
}
|
||||
private void AddCombination()
|
||||
{
|
||||
var item = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
repository.ForceCombinationLists.Add(item);
|
||||
}
|
||||
private RelayCommand deleteForceCombinationCommand;
|
||||
public RelayCommand Delete
|
||||
{
|
||||
get
|
||||
{
|
||||
return deleteForceCombinationCommand ??
|
||||
(
|
||||
deleteForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
DeleteForceCombination();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
}
|
||||
private void DeleteForceCombination()
|
||||
{
|
||||
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
repository.ForceCombinationLists.Remove(SelectedItem);
|
||||
}
|
||||
}
|
||||
private RelayCommand editForceCombinationCommand;
|
||||
public RelayCommand Edit
|
||||
{
|
||||
get
|
||||
{
|
||||
return editForceCombinationCommand ??
|
||||
(
|
||||
editForceCombinationCommand = new RelayCommand(o =>
|
||||
{
|
||||
EditForceCombination();
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
}
|
||||
private void EditForceCombination()
|
||||
{
|
||||
var wnd = new ForceCombinationView(SelectedItem);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
public ForceCombinationViewModelLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public interface ICalculatorsViewModelLogic : ICRUDViewModel<INdmCalculator>
|
||||
{
|
||||
RelayCommand Run { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public interface IForceCombinationViewModelLogic : ICRUDViewModel<IForceCombinationList>
|
||||
{
|
||||
}
|
||||
}
|
||||
117
Windows/ViewModels/SourceToTargetViewModel.cs
Normal file
117
Windows/ViewModels/SourceToTargetViewModel.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public class SourceToTargetViewModel<TItem> : ViewModelBase, ISourceToTargetViewModel<TItem>
|
||||
{
|
||||
private IEnumerable<TItem> allowedItems;
|
||||
private IEnumerable<TItem> targetItems;
|
||||
private RelayCommand addAll;
|
||||
private RelayCommand addSelected;
|
||||
private RelayCommand removeSelected;
|
||||
private RelayCommand clearAll;
|
||||
|
||||
public TItem SelectedSourceItem { get; set; }
|
||||
public TItem SelectedTargetItem { get; set; }
|
||||
public ObservableCollection<TItem> SourceItems { get; }
|
||||
public ObservableCollection<TItem> TargetItems { get; }
|
||||
public RelayCommand AddAll
|
||||
{
|
||||
get
|
||||
{
|
||||
return addAll ??
|
||||
(
|
||||
addAll = new RelayCommand(o =>
|
||||
{
|
||||
foreach (var item in SourceItems)
|
||||
{
|
||||
TargetItems.Add(item);
|
||||
}
|
||||
SourceItems.Clear();
|
||||
}, o=> SourceItems.Count() > 0));
|
||||
}
|
||||
}
|
||||
public RelayCommand ClearAll
|
||||
{
|
||||
get
|
||||
{
|
||||
return clearAll ??
|
||||
(
|
||||
clearAll = new RelayCommand(o =>
|
||||
{
|
||||
foreach (var item in TargetItems)
|
||||
{
|
||||
SourceItems.Add(item);
|
||||
}
|
||||
TargetItems.Clear();
|
||||
}, o => TargetItems.Count() > 0));
|
||||
}
|
||||
}
|
||||
public RelayCommand AddSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return addSelected ??
|
||||
(
|
||||
addSelected = new RelayCommand(o =>
|
||||
{
|
||||
TargetItems.Add(SelectedSourceItem);
|
||||
SourceItems.Remove(SelectedSourceItem);
|
||||
}, o => SelectedSourceItem != null));
|
||||
}
|
||||
}
|
||||
public RelayCommand RemoveSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return removeSelected ??
|
||||
(
|
||||
removeSelected = new RelayCommand(o =>
|
||||
{
|
||||
SourceItems.Add(SelectedTargetItem);
|
||||
TargetItems.Remove(SelectedTargetItem);
|
||||
}, o => SelectedTargetItem != null));
|
||||
}
|
||||
}
|
||||
|
||||
public SourceToTargetViewModel()
|
||||
{
|
||||
SourceItems = new ObservableCollection<TItem>();
|
||||
TargetItems = new ObservableCollection<TItem>();
|
||||
}
|
||||
|
||||
public void SetSourceItems(IEnumerable<TItem> allowedItems)
|
||||
{
|
||||
this.allowedItems = allowedItems;
|
||||
var rejectedItems = allowedItems.Where(x => TargetItems.Contains(x));
|
||||
var filteredItems = allowedItems.Except(rejectedItems);
|
||||
SourceItems.Clear();
|
||||
foreach (var item in filteredItems)
|
||||
{
|
||||
SourceItems.Add(item);
|
||||
}
|
||||
}
|
||||
public void SetTargetItems(IEnumerable<TItem> targetItems)
|
||||
{
|
||||
this.targetItems = targetItems;
|
||||
TargetItems.Clear();
|
||||
foreach (var item in this.targetItems)
|
||||
{
|
||||
TargetItems.Add(item);
|
||||
}
|
||||
}
|
||||
public IEnumerable<TItem> GetTargetItems()
|
||||
{
|
||||
return TargetItems;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user