Surrounding property was added
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
<ResourceDictionary Source="Infrastructure/UI/Resources/ShapeEditTemplates.xaml"/>
|
||||
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveToolTips.xaml"/>
|
||||
<ResourceDictionary Source="Infrastructure/UI/Resources/ITemEditPanels.xaml"/>
|
||||
<ResourceDictionary Source="Infrastructure/UI/Resources/ForceTemplates.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
14
StructureHelper/Infrastructure/Enums/ActionType.cs
Normal file
14
StructureHelper/Infrastructure/Enums/ActionType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.Enums
|
||||
{
|
||||
public enum ActionType
|
||||
{
|
||||
ForceCombination,
|
||||
ForceCombinationByFactor
|
||||
}
|
||||
}
|
||||
@@ -263,13 +263,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
|
||||
public virtual INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
RefreshNdmPrimitive();
|
||||
//RefreshNdmPrimitive();
|
||||
return primitive;
|
||||
}
|
||||
|
||||
public virtual void RefreshNdmPrimitive()
|
||||
{
|
||||
}
|
||||
//public virtual void RefreshNdmPrimitive()
|
||||
//{
|
||||
//}
|
||||
|
||||
public void RefreshColor()
|
||||
{
|
||||
|
||||
@@ -17,26 +17,37 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
public static ObservableCollection<PrimitiveBase> ConvertNdmPrimitivesToPrimitiveBase(IEnumerable<INdmPrimitive> primitives)
|
||||
{
|
||||
ObservableCollection<PrimitiveBase> viewItems = new ObservableCollection<PrimitiveBase>();
|
||||
foreach (var item in primitives)
|
||||
foreach (var primitive in primitives)
|
||||
{
|
||||
if (item is IRectanglePrimitive)
|
||||
{
|
||||
var rect = item as IRectanglePrimitive;
|
||||
viewItems.Add(new RectangleViewPrimitive(rect));
|
||||
}
|
||||
else if (item is ICirclePrimitive)
|
||||
{
|
||||
var circle = item as ICirclePrimitive;
|
||||
viewItems.Add(new CircleViewPrimitive(circle));
|
||||
}
|
||||
else if (item is IPointPrimitive)
|
||||
{
|
||||
var point = item as IPointPrimitive;
|
||||
viewItems.Add(new PointViewPrimitive(point));
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
|
||||
viewItems.Add(ConvertNdmPrimitiveToPrimitiveBase(primitive));
|
||||
}
|
||||
return viewItems;
|
||||
}
|
||||
public static PrimitiveBase ConvertNdmPrimitiveToPrimitiveBase(INdmPrimitive primitive)
|
||||
{
|
||||
PrimitiveBase viewItem;
|
||||
if (primitive is IRectanglePrimitive)
|
||||
{
|
||||
var rect = primitive as IRectanglePrimitive;
|
||||
viewItem = new RectangleViewPrimitive(rect);
|
||||
}
|
||||
else if (primitive is ICirclePrimitive)
|
||||
{
|
||||
var circle = primitive as ICirclePrimitive;
|
||||
viewItem = new CircleViewPrimitive(circle);
|
||||
}
|
||||
else if (primitive is IPointPrimitive & primitive is not ReinforcementPrimitive)
|
||||
{
|
||||
var point = primitive as IPointPrimitive;
|
||||
viewItem = new PointViewPrimitive(point);
|
||||
}
|
||||
else if (primitive is ReinforcementPrimitive)
|
||||
{
|
||||
var point = primitive as ReinforcementPrimitive;
|
||||
viewItem = new ReinforcementViewPrimitive(point);
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Actual type: {primitive.GetType()}");
|
||||
return viewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,10 +7,23 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
internal class ReinforcementViewPrimitive : PointViewPrimitive
|
||||
public class ReinforcementViewPrimitive : PointViewPrimitive, IHasSurroundingPrimitive
|
||||
{
|
||||
public ReinforcementViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
|
||||
ReinforcementPrimitive primitive;
|
||||
|
||||
public INdmPrimitive SurroundingPrimitive
|
||||
{
|
||||
get => primitive.SurroundingPrimitive;
|
||||
set
|
||||
{
|
||||
primitive.SurroundingPrimitive = value;
|
||||
OnPropertyChanged(nameof(SurroundingPrimitive));
|
||||
}
|
||||
}
|
||||
|
||||
public ReinforcementViewPrimitive(ReinforcementPrimitive _primitive) : base(_primitive)
|
||||
{
|
||||
primitive = _primitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<DataTemplate x:Key="ForceActionTemplate">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Name"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Set force into initial Gravity Center"/>
|
||||
<CheckBox Grid.Row="1" Grid.Column="1" Margin="3,5,3,5" IsChecked="{Binding SetInGravityCenter}"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CenterX}" IsEnabled="{Binding CoordEnable}"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding CenterY}" IsEnabled="{Binding CoordEnable}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="CombinationListTemplate">
|
||||
<Grid Grid.Row="1" DataContext="{Binding DesignForces}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DataGrid x:Name="ForceGrid" Style="{StaticResource ItemsDataGrid}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridComboBoxColumn Header="Limit state" Width="80" MinWidth="70" SelectedItemBinding="{Binding LimitState}" ItemsSource="{Binding Source={StaticResource LimitStateEnum}}"/>
|
||||
<DataGridComboBoxColumn Header="Duration" Width="80" MinWidth="70" SelectedItemBinding="{Binding CalcTerm}" ItemsSource="{Binding Source={StaticResource CalcTermEnum}}"/>
|
||||
<DataGridTextColumn Header="Moment Mx" Width="85" Binding="{Binding ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Moment My" Width="85" Binding="{Binding ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Force Nz" Width="85" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Style="{StaticResource AddButton}"/>
|
||||
<Button Style="{StaticResource DeleteButton}"/>
|
||||
<Button Style="{StaticResource CopyButton}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -9,6 +9,9 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Windows\Forces\ForceCombinationByFactorView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\MainWindow\AboutView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -17,6 +20,12 @@
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Infrastructure\UI\Resources\ForceTemplates.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\Forces\ForceCombinationByFactorView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\MainWindow\AboutView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<Window x:Class="StructureHelper.Windows.Forces.ForceCombinationByFactorView"
|
||||
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.Forces"
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
|
||||
d:DataContext="{d:DesignInstance vm:ForceCombinationByFactorVM}"
|
||||
mc:Ignorable="d"
|
||||
Title="Force Combination By Factor" Height="250" Width="350" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="95"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<!--ForceTemplates.xaml-->
|
||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
||||
<StackPanel Grid.Row="1">
|
||||
<TextBlock Text="Full service load combination"/>
|
||||
<Grid DataContext="{Binding ForceTupleVM}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock HorizontalAlignment="Center" Text="Mx" />
|
||||
<TextBlock Grid.Column="1" HorizontalAlignment="Center" Text="My" />
|
||||
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Text="Nz" />
|
||||
<TextBox Grid.Row="1" Text="{Binding Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Long Term factor"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding LongTermFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
||||
<TextBlock Grid.Row="1" Text="ULS Safety Factor"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding ULSFactor, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelper.Windows.ViewModels.Forces;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
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 StructureHelper.Windows.Forces
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ForceCombinationByFactor.xaml
|
||||
/// </summary>
|
||||
public partial class ForceCombinationByFactorView : Window
|
||||
{
|
||||
ForceCombinationByFactorVM viewModel;
|
||||
public ForceCombinationByFactorView(IForceCombinationByFactor forceCombination)
|
||||
{
|
||||
InitializeComponent();
|
||||
viewModel = new ForceCombinationByFactorVM(forceCombination);
|
||||
DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,56 +9,14 @@
|
||||
mc:Ignorable="d"
|
||||
Title="Force Combination" Height="250" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="ForceTemplate">
|
||||
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="95"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Name"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Set force into initial Gravity Center"/>
|
||||
<CheckBox Grid.Row="1" Grid.Column="1" Margin="3,5,3,5" IsChecked="{Binding SetInGravityCenter}"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CenterX}" IsEnabled="{Binding CoordEnable}"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding CenterY}" IsEnabled="{Binding CoordEnable}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="1" DataContext="{Binding DesignForces}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="80"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<DataGrid x:Name="ForceGrid" Style="{StaticResource ItemsDataGrid}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridComboBoxColumn Header="Limit state" Width="80" MinWidth="70" SelectedItemBinding="{Binding LimitState}" ItemsSource="{Binding Source={StaticResource LimitStateEnum}}"/>
|
||||
<DataGridComboBoxColumn Header="Duration" Width="80" MinWidth="70" SelectedItemBinding="{Binding CalcTerm}" ItemsSource="{Binding Source={StaticResource CalcTermEnum}}"/>
|
||||
<DataGridTextColumn Header="Moment Mx" Width="85" Binding="{Binding ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Moment My" Width="85" Binding="{Binding ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Force Nz" Width="85" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Style="{StaticResource AddButton}"/>
|
||||
<Button Style="{StaticResource DeleteButton}"/>
|
||||
<Button Style="{StaticResource CopyButton}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<!--ForceTemplates.xaml-->
|
||||
<ContentControl ContentTemplate="{StaticResource ResourceKey=ForceActionTemplate}" Content="{Binding}"/>
|
||||
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource ResourceKey=CombinationListTemplate}" Content="{Binding}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -75,7 +75,10 @@
|
||||
<Expander Header="Actions" MinWidth="20" DataContext="{Binding CombinationsLogic}">
|
||||
<Expander.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Add Force Combination" Command="{Binding Add}"/>
|
||||
<MenuItem Header="Add">
|
||||
<Button Content="Combination" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombination}"/>
|
||||
<Button Content="Combination By Factors" Command="{Binding Add}" CommandParameter="{x:Static enums:ActionType.ForceCombinationByFactor}"/>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Expander.ContextMenu>
|
||||
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
private readonly AnalysisVewModelLogic calculatorsLogic;
|
||||
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}
|
||||
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
|
||||
public IPrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
|
||||
public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
|
||||
public HelpLogic HelpLogic => new HelpLogic();
|
||||
|
||||
private MainModel Model { get; }
|
||||
@@ -214,7 +214,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
private double delta = 0.0005;
|
||||
private ActionsViewModel combinationsLogic;
|
||||
private IPrimitiveViewModelLogic primitiveLogic;
|
||||
private PrimitiveViewModelLogic primitiveLogic;
|
||||
private RelayCommand showVisualProperty;
|
||||
private RelayCommand selectPrimitive;
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
section = model.Section;
|
||||
combinationsLogic = new ActionsViewModel(repository);
|
||||
calculatorsLogic = new AnalysisVewModelLogic(repository);
|
||||
primitiveLogic = new PrimitiveViewModelLogic(repository) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
|
||||
primitiveLogic = new PrimitiveViewModelLogic(section) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
|
||||
XX2 = CanvasWidth;
|
||||
XY1 = CanvasHeight / 2d;
|
||||
YX1 = CanvasWidth / 2d;
|
||||
@@ -342,11 +342,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckAnalisysOptions()
|
||||
{
|
||||
if (CheckMaterials() == false) { return false; }
|
||||
return true;
|
||||
}
|
||||
private bool CheckMaterials()
|
||||
{
|
||||
foreach (var item in primitiveLogic.Items)
|
||||
@@ -405,10 +400,10 @@ namespace StructureHelper.Windows.MainWindow
|
||||
var newRepository = newSection.SectionRepository;
|
||||
repository.HeadMaterials.AddRange(newRepository.HeadMaterials);
|
||||
repository.Primitives.AddRange(newRepository.Primitives);
|
||||
repository.ForceCombinationLists.AddRange(newRepository.ForceCombinationLists);
|
||||
repository.ForceActions.AddRange(newRepository.ForceActions);
|
||||
repository.CalculatorsList.AddRange(newRepository.CalculatorsList);
|
||||
OnPropertyChanged(nameof(HeadMaterials));
|
||||
CombinationsLogic.AddItems(newRepository.ForceCombinationLists);
|
||||
CombinationsLogic.AddItems(newRepository.ForceActions);
|
||||
CalculatorsLogic.AddItems(newRepository.CalculatorsList);
|
||||
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
|
||||
foreach (var item in primitives)
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Inside of"/>
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding PrimitiveMaterial}">
|
||||
<ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding SurroundingPrimitives}" SelectedItem="{Binding SurroundingPrimitive}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -29,10 +30,10 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
|
||||
{
|
||||
PrimitiveBase primitive;
|
||||
private PrimitivePropertiesViewModel viewModel;
|
||||
public PrimitivePropertiesView(PrimitiveBase primitive, IHasHeadMaterials headMaterials)
|
||||
public PrimitivePropertiesView(PrimitiveBase primitive, ICrossSectionRepository sectionRepository)
|
||||
{
|
||||
this.primitive = primitive;
|
||||
viewModel = new PrimitivePropertiesViewModel(this.primitive, headMaterials);
|
||||
viewModel = new PrimitivePropertiesViewModel(this.primitive, sectionRepository);
|
||||
this.DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
if (primitive is RectangleViewPrimitive) { AddPrimitiveProperties(PrimitiveType.Rectangle); }
|
||||
@@ -42,13 +43,13 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
|
||||
}
|
||||
private void AddPrimitiveProperties(PrimitiveType type)
|
||||
{
|
||||
List<string> names = new List<string>();
|
||||
if (primitive.DivisionViewModel is not null) { names.Add("TriangulationProperties");}
|
||||
if (primitive is RectangleViewPrimitive) { names.Add("RectangleProperties"); }
|
||||
if (primitive is CircleViewPrimitive) { names.Add("CircleProperties"); }
|
||||
if (primitive is PointViewPrimitive) { names.Add("PointProperties"); }
|
||||
if (primitive is ReinforcementViewPrimitive) { names.Add("ReinforcementProperties"); }
|
||||
foreach (var name in names)
|
||||
List<string> templateNames = new List<string>();
|
||||
if (primitive.DivisionViewModel is not null) { templateNames.Add("TriangulationProperties");}
|
||||
if (primitive is RectangleViewPrimitive) { templateNames.Add("RectangleProperties"); }
|
||||
if (primitive is CircleViewPrimitive) { templateNames.Add("CircleProperties"); }
|
||||
if (primitive is PointViewPrimitive) { templateNames.Add("PointProperties"); }
|
||||
if (primitive is ReinforcementViewPrimitive) { templateNames.Add("ReinforcementProperties"); }
|
||||
foreach (var name in templateNames)
|
||||
{
|
||||
ContentControl contentControl = new ContentControl();
|
||||
contentControl.SetResourceReference(ContentTemplateProperty, name);
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
public class ForceCalculatorViewModel : ViewModelBase
|
||||
{
|
||||
IEnumerable<INdmPrimitive> allowedPrimitives;
|
||||
IEnumerable<IForceCombinationList> allowedForceCombinations;
|
||||
IEnumerable<IForceAction> allowedForceCombinations;
|
||||
ForceCalculator forcesCalculator;
|
||||
SecondOrderViewModel secondOrderViewModel;
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
public bool ShortTerm { get; set; }
|
||||
public bool LongTerm { get; set; }
|
||||
|
||||
public ISourceToTargetViewModel<IForceCombinationList> CombinationViewModel { get; }
|
||||
public ISourceToTargetViewModel<IForceAction> CombinationViewModel { get; }
|
||||
public ISourceToTargetViewModel<PrimitiveBase> PrimitivesViewModel { get; }
|
||||
|
||||
public PrimitiveBase SelectedAllowedPrimitive { get; set; }
|
||||
@@ -146,15 +146,15 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}
|
||||
}
|
||||
|
||||
public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> _allowedPrimitives, IEnumerable<IForceCombinationList> _allowedForceCombinations, ForceCalculator _forcesCalculator)
|
||||
public ForceCalculatorViewModel(IEnumerable<INdmPrimitive> _allowedPrimitives, IEnumerable<IForceAction> _allowedForceCombinations, ForceCalculator _forcesCalculator)
|
||||
{
|
||||
allowedPrimitives = _allowedPrimitives;
|
||||
allowedForceCombinations = _allowedForceCombinations;
|
||||
forcesCalculator = _forcesCalculator;
|
||||
secondOrderViewModel = new SecondOrderViewModel(forcesCalculator.CompressedMember);
|
||||
|
||||
CombinationViewModel = new SourceToTargetViewModel<IForceCombinationList>();
|
||||
CombinationViewModel.SetTargetItems(forcesCalculator.ForceCombinationLists);
|
||||
CombinationViewModel = new SourceToTargetViewModel<IForceAction>();
|
||||
CombinationViewModel.SetTargetItems(forcesCalculator.ForceActions);
|
||||
CombinationViewModel.SetSourceItems(allowedForceCombinations);
|
||||
CombinationViewModel.ItemDataDemplate = Application.Current.Resources["SimpleItemTemplate"] as DataTemplate;
|
||||
|
||||
@@ -180,10 +180,10 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
public void Refresh()
|
||||
{
|
||||
var combinations = CombinationViewModel.GetTargetItems();
|
||||
forcesCalculator.ForceCombinationLists.Clear();
|
||||
forcesCalculator.ForceActions.Clear();
|
||||
foreach (var item in combinations)
|
||||
{
|
||||
forcesCalculator.ForceCombinationLists.Add(item);
|
||||
forcesCalculator.ForceActions.Add(item);
|
||||
}
|
||||
forcesCalculator.Primitives.Clear();
|
||||
foreach (var item in PrimitivesViewModel.GetTargetItems())
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
@@ -11,14 +14,27 @@ using System.Windows.Forms;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ActionsViewModel : CRUDViewModelBase<IForceCombinationList>
|
||||
public class ActionsViewModel : CRUDViewModelBase<IForceAction>
|
||||
{
|
||||
ICrossSectionRepository repository;
|
||||
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
base.AddMethod(parameter);
|
||||
if (parameter is not null)
|
||||
{
|
||||
ActionType paramType = (ActionType)parameter;
|
||||
if (paramType == ActionType.ForceCombination)
|
||||
{
|
||||
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
}
|
||||
else if (paramType == ActionType.ForceCombinationByFactor)
|
||||
{
|
||||
NewItem = new ForceCombinationByFactor() { Name = "New Factored Combination" };
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $": Actual type: {nameof(paramType)}");
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void DeleteMethod(object parameter)
|
||||
@@ -32,11 +48,11 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
if (item is IForceCalculator)
|
||||
{
|
||||
var forceCalculator = item as IForceCalculator;
|
||||
var containSelected = forceCalculator.ForceCombinationLists.Contains(SelectedItem);
|
||||
var containSelected = forceCalculator.ForceActions.Contains(SelectedItem);
|
||||
if (containSelected)
|
||||
{
|
||||
var dialogResultCalc = MessageBox.Show($"Action is contained in calculator {item.Name}", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceCombinationLists.Remove(SelectedItem); }
|
||||
if (dialogResultCalc == DialogResult.OK) { forceCalculator.ForceActions.Remove(SelectedItem); }
|
||||
else return;
|
||||
}
|
||||
}
|
||||
@@ -47,12 +63,23 @@ namespace StructureHelper.Windows.ViewModels.Forces
|
||||
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
var wnd = new ForceCombinationView(SelectedItem);
|
||||
System.Windows.Window wnd;
|
||||
if (SelectedItem is IForceCombinationList)
|
||||
{
|
||||
var item = (IForceCombinationList)SelectedItem;
|
||||
wnd = new ForceCombinationView(item);
|
||||
}
|
||||
else if (SelectedItem is IForceCombinationByFactor)
|
||||
{
|
||||
var item = (IForceCombinationByFactor)SelectedItem;
|
||||
wnd = new ForceCombinationByFactorView(item);
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $"actual object type: {nameof(SelectedItem)}");
|
||||
wnd.ShowDialog();
|
||||
base.EditMethod(parameter);
|
||||
}
|
||||
|
||||
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceCombinationLists)
|
||||
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceActions)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public abstract class ForceActionVMBase : ViewModelBase
|
||||
{
|
||||
IForceAction forceAction;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => forceAction.Name;
|
||||
set
|
||||
{
|
||||
forceAction.Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetInGravityCenter
|
||||
{
|
||||
get => forceAction.SetInGravityCenter;
|
||||
set
|
||||
{
|
||||
forceAction.SetInGravityCenter = value;
|
||||
OnPropertyChanged(nameof(SetInGravityCenter));
|
||||
OnPropertyChanged(nameof(CoordEnable));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CoordEnable => !SetInGravityCenter;
|
||||
|
||||
public double CenterX
|
||||
{
|
||||
get => forceAction.ForcePoint.X;
|
||||
set
|
||||
{
|
||||
forceAction.ForcePoint.X = value;
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
}
|
||||
}
|
||||
|
||||
public double CenterY
|
||||
{
|
||||
get => forceAction.ForcePoint.Y;
|
||||
set
|
||||
{
|
||||
forceAction.ForcePoint.Y = value;
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
}
|
||||
}
|
||||
public ForceActionVMBase(IForceAction forceAction)
|
||||
{
|
||||
this.forceAction = forceAction;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media.Media3D;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ForceCombinationByFactorVM : ForceActionVMBase, IDataErrorInfo
|
||||
{
|
||||
IForceCombinationByFactor forceAction;
|
||||
ForceTupleVM forceTupleVM;
|
||||
|
||||
public double ULSFactor
|
||||
{
|
||||
get => forceAction.ULSFactor;
|
||||
set
|
||||
{
|
||||
forceAction.ULSFactor = value;
|
||||
OnPropertyChanged(nameof(ULSFactor));
|
||||
}
|
||||
}
|
||||
|
||||
public ForceTupleVM ForceTupleVM => forceTupleVM;
|
||||
|
||||
public double LongTermFactor
|
||||
{
|
||||
get => forceAction.LongTermFactor;
|
||||
set
|
||||
{
|
||||
if (value <0d) { value = 0d; }
|
||||
if (value > 1d) { value = 1d; }
|
||||
forceAction.LongTermFactor = value;
|
||||
OnPropertyChanged(nameof(LongTermFactor));
|
||||
}
|
||||
}
|
||||
|
||||
public string Error => throw new NotImplementedException();
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
string error = null;
|
||||
|
||||
if (columnName == nameof(ULSFactor))
|
||||
{
|
||||
if (ULSFactor <= 0)
|
||||
{
|
||||
error = "Safety factor for ULS must be greater than zero";
|
||||
}
|
||||
}
|
||||
if (columnName == nameof(LongTermFactor))
|
||||
{
|
||||
if (LongTermFactor < 0d || LongTermFactor > 1d)
|
||||
{
|
||||
error = "Long term factor must be between 0.0 and 1.0";
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
public ForceCombinationByFactorVM(IForceCombinationByFactor forceAction) : base(forceAction)
|
||||
{
|
||||
this.forceAction = forceAction;
|
||||
forceTupleVM = new ForceTupleVM(forceAction.FullSLSForces);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,61 +8,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ForceCombinationViewModel : ViewModelBase
|
||||
public class ForceCombinationViewModel : ForceActionVMBase
|
||||
{
|
||||
IForceCombinationList combinationList;
|
||||
ForceTuplesViewModel designForces;
|
||||
|
||||
//public IDesignForceTuple SelectedTuple { get; set; }
|
||||
public ForceTuplesViewModel DesignForces { get;}
|
||||
public ForceTuplesViewModel DesignForces => designForces;
|
||||
|
||||
public string Name
|
||||
public ForceCombinationViewModel(IForceCombinationList combinationList) : base(combinationList)
|
||||
{
|
||||
get => combinationList.Name;
|
||||
set
|
||||
{
|
||||
combinationList.Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetInGravityCenter
|
||||
{
|
||||
get => combinationList.SetInGravityCenter;
|
||||
set
|
||||
{
|
||||
combinationList.SetInGravityCenter = value;
|
||||
OnPropertyChanged(nameof(SetInGravityCenter));
|
||||
OnPropertyChanged(nameof(CoordEnable));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CoordEnable => !SetInGravityCenter;
|
||||
|
||||
public double CenterX
|
||||
{
|
||||
get => combinationList.ForcePoint.X;
|
||||
set
|
||||
{
|
||||
combinationList.ForcePoint.X = value;
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
}
|
||||
}
|
||||
|
||||
public double CenterY
|
||||
{
|
||||
get => combinationList.ForcePoint.Y;
|
||||
set
|
||||
{
|
||||
combinationList.ForcePoint.Y = value;
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
}
|
||||
}
|
||||
|
||||
//public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
|
||||
|
||||
public ForceCombinationViewModel(IForceCombinationList combinationList)
|
||||
{
|
||||
this.combinationList = combinationList;
|
||||
DesignForces = new ForceTuplesViewModel(this.combinationList.DesignForces);
|
||||
designForces = new ForceTuplesViewModel(combinationList.DesignForces);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
73
StructureHelper/Windows/ViewModels/Forces/ForceTupleVM.cs
Normal file
73
StructureHelper/Windows/ViewModels/Forces/ForceTupleVM.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Forces
|
||||
{
|
||||
public class ForceTupleVM : ViewModelBase
|
||||
{
|
||||
IForceTuple forceTuple;
|
||||
public double Mx
|
||||
{
|
||||
get => forceTuple.Mx;
|
||||
set
|
||||
{
|
||||
forceTuple.Mx = value;
|
||||
OnPropertyChanged(nameof(Mx));
|
||||
}
|
||||
}
|
||||
public double My
|
||||
{
|
||||
get => forceTuple.My;
|
||||
set
|
||||
{
|
||||
forceTuple.My = value;
|
||||
OnPropertyChanged(nameof(My));
|
||||
}
|
||||
}
|
||||
public double Nz
|
||||
{
|
||||
get => forceTuple.Nz;
|
||||
set
|
||||
{
|
||||
forceTuple.Nz = value;
|
||||
OnPropertyChanged(nameof(Nz));
|
||||
}
|
||||
}
|
||||
public double Qx
|
||||
{
|
||||
get => forceTuple.Qx;
|
||||
set
|
||||
{
|
||||
forceTuple.Qx = value;
|
||||
OnPropertyChanged(nameof(Qx));
|
||||
}
|
||||
}
|
||||
public double Qy
|
||||
{
|
||||
get => forceTuple.Qy;
|
||||
set
|
||||
{
|
||||
forceTuple.Qy = value;
|
||||
OnPropertyChanged(nameof(Qy));
|
||||
}
|
||||
}
|
||||
public double Mz
|
||||
{
|
||||
get => forceTuple.Mz;
|
||||
set
|
||||
{
|
||||
forceTuple.Mz = value;
|
||||
OnPropertyChanged(nameof(Mz));
|
||||
}
|
||||
}
|
||||
public ForceTupleVM(IForceTuple forceTuple)
|
||||
{
|
||||
this.forceTuple = forceTuple;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
if (SelectedItem is ForceCalculator)
|
||||
{
|
||||
var calculator = SelectedItem as ForceCalculator;
|
||||
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceCombinationLists, calculator);
|
||||
var vm = new ForceCalculatorViewModel(repository.Primitives, repository.ForceActions, calculator);
|
||||
|
||||
var wnd = new ForceCalculatorView(vm);
|
||||
wnd.ShowDialog();
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
private readonly ICrossSectionRepository repository;
|
||||
|
||||
public IForceCombinationList SelectedItem { get; set; }
|
||||
public IForceAction SelectedItem { get; set; }
|
||||
|
||||
public ObservableCollection<IForceCombinationList> Items { get; private set; }
|
||||
public ObservableCollection<IForceAction> Items { get; private set; }
|
||||
|
||||
private RelayCommand addForceCombinationCommand;
|
||||
public RelayCommand Add
|
||||
@@ -41,7 +41,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
var item = new ForceCombinationList() { Name = "New Force Combination" };
|
||||
Items.Add(item);
|
||||
repository.ForceCombinationLists.Add(item);
|
||||
repository.ForceActions.Add(item);
|
||||
}
|
||||
private RelayCommand deleteForceCombinationCommand;
|
||||
public RelayCommand Delete
|
||||
@@ -62,7 +62,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
repository.ForceCombinationLists.Remove(SelectedItem);
|
||||
repository.ForceActions.Remove(SelectedItem);
|
||||
}
|
||||
}
|
||||
private RelayCommand editForceCombinationCommand;
|
||||
@@ -78,7 +78,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
EditForceCombination();
|
||||
Items.Clear();
|
||||
AddItems(repository.ForceCombinationLists);
|
||||
AddItems(repository.ForceActions);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}, o => SelectedItem != null));
|
||||
}
|
||||
@@ -93,7 +93,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
copyCommand = new RelayCommand(o =>
|
||||
{
|
||||
var item = SelectedItem.Clone() as IForceCombinationList;
|
||||
repository.ForceCombinationLists.Add(item);
|
||||
repository.ForceActions.Add(item);
|
||||
Items.Add(item);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
}, o => SelectedItem != null));
|
||||
@@ -102,11 +102,11 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
|
||||
private void EditForceCombination()
|
||||
{
|
||||
var wnd = new ForceCombinationView(SelectedItem);
|
||||
wnd.ShowDialog();
|
||||
//var wnd = new ForceCombinationView(SelectedItem);
|
||||
//wnd.ShowDialog();
|
||||
}
|
||||
|
||||
public void AddItems(IEnumerable<IForceCombinationList> items)
|
||||
public void AddItems(IEnumerable<IForceAction> items)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -117,8 +117,8 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
public ForceCombinationViewModelLogic(ICrossSectionRepository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
Items = new ObservableCollection<IForceCombinationList>();
|
||||
AddItems(this.repository.ForceCombinationLists);
|
||||
Items = new ObservableCollection<IForceAction>();
|
||||
AddItems(this.repository.ForceActions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public interface IForceCombinationViewModelLogic : ICRUDViewModel<IForceCombinationList>
|
||||
public interface IForceCombinationViewModelLogic : ICRUDViewModel<IForceAction>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public interface IPrimitiveViewModelLogic : ICRUDViewModel<PrimitiveBase>
|
||||
{
|
||||
RelayCommand SetToFront { get; }
|
||||
RelayCommand SetToBack { get; }
|
||||
int PrimitivesCount { get; }
|
||||
void Refresh();
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,10 @@ using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
public class PrimitiveViewModelLogic : ViewModelBase, IPrimitiveViewModelLogic
|
||||
public class PrimitiveViewModelLogic : ViewModelBase, ICRUDViewModel<PrimitiveBase>
|
||||
{
|
||||
private readonly ICrossSectionRepository repository;
|
||||
private ICrossSection section;
|
||||
private ICrossSectionRepository repository => section.SectionRepository;
|
||||
private RelayCommand addCommand;
|
||||
private RelayCommand deleteCommand;
|
||||
private RelayCommand editCommand;
|
||||
@@ -99,6 +100,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(primitiveType)); }
|
||||
viewPrimitive.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
|
||||
repository.Primitives.Add(ndmPrimitive);
|
||||
ndmPrimitive.CrossSection = section;
|
||||
Items.Add(viewPrimitive);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
OnPropertyChanged(nameof(PrimitivesCount));
|
||||
@@ -132,6 +134,14 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
forceCalc.Primitives.Remove(ndmPrimitive);
|
||||
}
|
||||
}
|
||||
foreach (var primitive in repository.Primitives)
|
||||
{
|
||||
if (primitive is IHasSurroundingPrimitive)
|
||||
{
|
||||
var sPrimitive = primitive as IHasSurroundingPrimitive;
|
||||
if (sPrimitive.SurroundingPrimitive == ndmPrimitive) { sPrimitive.SurroundingPrimitive = null; }
|
||||
}
|
||||
}
|
||||
Items.Remove(SelectedItem);
|
||||
}
|
||||
OnPropertyChanged(nameof(Items));
|
||||
@@ -243,9 +253,9 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
OnPropertyChanged(nameof(PrimitivesCount));
|
||||
}
|
||||
|
||||
public PrimitiveViewModelLogic(ICrossSectionRepository repository)
|
||||
public PrimitiveViewModelLogic(ICrossSection section)
|
||||
{
|
||||
this.repository = repository;
|
||||
this.section = section;
|
||||
Items = new ObservableCollection<PrimitiveBase>();
|
||||
AddItems(PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(this.repository.Primitives));
|
||||
}
|
||||
|
||||
@@ -4,14 +4,19 @@ using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelper.Windows.ViewModels.NdmCrossSections;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
@@ -25,12 +30,13 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
public class PrimitivePropertiesViewModel : ViewModelBase, IDataErrorInfo
|
||||
{
|
||||
private PrimitiveBase primitive;
|
||||
private IHasHeadMaterials hasHeadMaterials;
|
||||
private ICrossSectionRepository sectionRepository;
|
||||
|
||||
public ICommand EditColorCommand { get; private set; }
|
||||
public ICommand EditMaterialCommand { get; private set; }
|
||||
|
||||
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
|
||||
public ObservableCollection<PrimitiveBase> SurroundingPrimitives { get; private set; }
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -54,7 +60,42 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PrimitiveBase? SurroundingPrimitive
|
||||
{
|
||||
get
|
||||
{
|
||||
if (primitive is not IHasSurroundingPrimitive)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
var sPrimitive = ((IHasSurroundingPrimitive)primitive).SurroundingPrimitive;
|
||||
if (sPrimitive is null) { return null; }
|
||||
foreach (var item in SurroundingPrimitives)
|
||||
{
|
||||
if (item.GetNdmPrimitive() == sPrimitive)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is not null)
|
||||
{
|
||||
if (primitive is IHasSurroundingPrimitive)
|
||||
{
|
||||
var sPrimitive = value.GetNdmPrimitive();
|
||||
((IHasSurroundingPrimitive)primitive).SurroundingPrimitive = sPrimitive;
|
||||
OnPropertyChanged(nameof(SurroundingPrimitive));
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $", Actual type: {value.GetType()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
public double CenterX
|
||||
{
|
||||
get => primitive.CenterX;
|
||||
@@ -126,7 +167,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
CenterX = CenterX;
|
||||
}
|
||||
}
|
||||
|
||||
public double Height
|
||||
{
|
||||
get
|
||||
@@ -148,7 +188,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
CenterY = CenterY; ;
|
||||
}
|
||||
}
|
||||
|
||||
public double Area
|
||||
{
|
||||
get
|
||||
@@ -171,7 +210,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double Diameter
|
||||
{
|
||||
get
|
||||
@@ -194,7 +232,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get => primitive.Color;
|
||||
@@ -204,7 +241,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
|
||||
public bool SetMaterialColor
|
||||
{
|
||||
get => primitive.SetMaterialColor;
|
||||
@@ -215,7 +251,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
OnPropertyChanged(nameof(SetMaterialColor));
|
||||
}
|
||||
}
|
||||
|
||||
public int ZIndex
|
||||
{ get => primitive.ZIndex;
|
||||
set
|
||||
@@ -223,7 +258,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
primitive.ZIndex = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsVisible
|
||||
{
|
||||
get => primitive.IsVisible;
|
||||
@@ -233,7 +267,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
OnPropertyChanged(nameof(IsVisible));
|
||||
}
|
||||
}
|
||||
|
||||
public double Opacity
|
||||
{
|
||||
get => primitive.Opacity * 100d;
|
||||
@@ -245,7 +278,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
OnPropertyChanged(nameof(Opacity));
|
||||
}
|
||||
}
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
@@ -267,23 +299,28 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
|
||||
|
||||
public string Error => throw new NotImplementedException();
|
||||
|
||||
public PrimitivePropertiesViewModel(PrimitiveBase primitive, IHasHeadMaterials hasHeadMaterials)
|
||||
public PrimitivePropertiesViewModel(PrimitiveBase primitive, ICrossSectionRepository sectionRepository)
|
||||
{
|
||||
this.primitive = primitive;
|
||||
this.hasHeadMaterials = hasHeadMaterials;
|
||||
this.sectionRepository = sectionRepository;
|
||||
HeadMaterials = new ObservableCollection<IHeadMaterial>();
|
||||
foreach (var material in hasHeadMaterials.HeadMaterials)
|
||||
foreach (var material in sectionRepository.HeadMaterials)
|
||||
{
|
||||
HeadMaterials.Add(material);
|
||||
}
|
||||
EditColorCommand = new RelayCommand(o => EditColor(), o => !SetMaterialColor);
|
||||
EditMaterialCommand = new RelayCommand(o => EditMaterial());
|
||||
|
||||
SurroundingPrimitives = new ObservableCollection<PrimitiveBase>();
|
||||
foreach (var item in sectionRepository.Primitives)
|
||||
{
|
||||
if (item is RectanglePrimitive || item is CirclePrimitive)
|
||||
{SurroundingPrimitives.Add(PrimitiveOperations.ConvertNdmPrimitiveToPrimitiveBase(item));}
|
||||
}
|
||||
}
|
||||
|
||||
private void EditMaterial()
|
||||
{
|
||||
var wnd = new HeadMaterialsView(hasHeadMaterials);
|
||||
var wnd = new HeadMaterialsView(sectionRepository);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user