Add beam shear calculator view

This commit is contained in:
Evgeny Redikultsev
2025-03-29 21:45:49 +05:00
parent 15bb7030cc
commit a0a25f183a
71 changed files with 969 additions and 472 deletions

View File

@@ -7,16 +7,7 @@
<ComboBox Height="25" VerticalAlignment="Top" ItemsSource="{Binding CodeList}" SelectedItem="{Binding CodeEntity}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}">
<!--<ToolTip>
<StackPanel>
<TextBlock FontWeight="Bold" Text="Code short name:"/>
<TextBlock Text="{Binding Name}"/>
<TextBlock FontWeight="Bold" Text="Full name:"/>
<TextBlock Text="{Binding FullName}"/>
</StackPanel>
</ToolTip>-->
</TextBlock>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
@@ -28,8 +19,11 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Text="Material Model"/>
<ComboBox Height="25" VerticalAlignment="Top" ItemsSource="{Binding MaterialLogics}" SelectedItem="{Binding MaterialLogic}">
<TextBlock Text="Material Model" Visibility="{Binding MaterialLogicVisibility, Converter = {StaticResource BooleanToVisibilityConverter}}"/>
<ComboBox Height="25" VerticalAlignment="Top"
ItemsSource="{Binding MaterialLogics}"
SelectedItem="{Binding MaterialLogic}"
Visibility="{Binding MaterialLogicVisibility, Converter = {StaticResource BooleanToVisibilityConverter}}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
@@ -113,12 +107,12 @@
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Tension for ULS"/>
<TextBlock Grid.Row="1" Text="Tension for SLS"/>
<TextBlock Grid.Row="2" Text="Relative humidity"/>
<CheckBox Grid.Column="1" IsChecked="{Binding TensionForULS}"/>
<CheckBox Grid.Column="1" Grid.Row="1" IsChecked="{Binding TensionForSLS}"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Humidity}"/>
<TextBlock Grid.Row="0" Text="Tension for ULS" Visibility="{Binding TensionForULSVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<CheckBox Grid.Column="1" IsChecked="{Binding TensionForULS}" Visibility="{Binding TensionForULSVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBlock Grid.Row="1" Text="Tension for SLS" Visibility="{Binding TensionForSLSVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<CheckBox Grid.Column="1" Grid.Row="1" IsChecked="{Binding TensionForSLS}" Visibility="{Binding TensionForSLSVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBlock Grid.Row="2" Text="Relative humidity" Visibility="{Binding HumidityVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Humidity}" Visibility="{Binding HumidityVisibility, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</Grid>
<Button Content="Show Safety Factors" Command="{Binding ShowSafetyFactors}"/>
<ContentControl ContentTemplate="{StaticResource MaterialSafetyFactors}" Content="{Binding SafetyFactors}"/>

View File

@@ -15,6 +15,9 @@
<Compile Update="Windows\BeamShears\BeamShearActionView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\BeamShearCalculatorView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\BeamShearView.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -24,9 +27,15 @@
<Compile Update="Windows\BeamShears\DistributedLoadView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\SectionView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\StirrupByDensityView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\BeamShears\StirrupByRebarView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\CalculationWindows\CalculatorsViews\Cracks\CrackCalculatorInputDataView.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -114,6 +123,9 @@
<Compile Update="Windows\UserControls\ListOfFileControl.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\UserControls\Materials\ReinforcementSelector.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -155,6 +167,9 @@
<Page Update="Windows\BeamShears\BeamShearActionView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\BeamShearCalculatorView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\BeamShearView.xaml">
<SubType>Designer</SubType>
</Page>
@@ -164,9 +179,15 @@
<Page Update="Windows\BeamShears\DistributedLoadView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\SectionView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\StirrupByDensityView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\BeamShears\StirrupByRebarView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\CalculationWindows\CalculatorsViews\Cracks\CrackCalculatorInputDataView.xaml">
<SubType>Designer</SubType>
</Page>
@@ -257,6 +278,9 @@
<Page Update="Windows\UserControls\ListOfFileControl.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\UserControls\Materials\ReinforcementSelector.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Windows\UserControls\MultiplyDouble.xaml">
<SubType>Designer</SubType>
</Page>

View File

@@ -32,7 +32,7 @@
<TextBox Grid.Column="1" Text="{Binding Name}"/>
</Grid>
<TabControl Grid.Row="1">
<TabItem Header="External forces" DataContext="{Binding ExternalForces}">
<TabItem Header="External force" DataContext="{Binding ExternalForces}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
@@ -53,7 +53,7 @@
<uc:FactoredCombination Grid.Row="1" DataContext="{Binding CombinationProperty}"/>
</Grid>
</TabItem>
<TabItem Header="Support" DataContext="{Binding SupportAction.SupportForces}">
<TabItem Header="Imternal force" DataContext="{Binding SupportAction.SupportForces}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>

View File

@@ -12,7 +12,7 @@ namespace StructureHelper.Windows.BeamShears
private readonly IBeamShearRepository shearRepository;
private IUpdateStrategy<IBeamShearAction> updateStrategy;
public BeamShearActionsViewModel(IBeamShearRepository shearRepository) : base(shearRepository.BeamShearActions)
public BeamShearActionsViewModel(IBeamShearRepository shearRepository) : base(shearRepository.Actions)
{
this.shearRepository = shearRepository;
}
@@ -36,7 +36,7 @@ namespace StructureHelper.Windows.BeamShears
}
public override void DeleteMethod(object parameter)
{
shearRepository.DeleteAction(SelectedItem);
BeamShearRepositoryService.DeleteAction(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.ViewModels;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.BeamShears;
namespace StructureHelper.Windows.BeamShears
{
public class BeamShearCalculatorInputDataViewModel : ViewModelBase
{
private readonly IBeamShearRepository shearRepository;
private readonly IBeamShearCalculatorInputData inputData;
public SourceTargetVM<IBeamShearAction> ActionSourceTarget { get; } = new();
public SourceTargetVM<IStirrup> StirrupSourceTarget { get; } = new();
public SourceTargetVM<IBeamShearSection> SectionSourceTarget { get; } = new();
public BeamShearCalculatorInputDataViewModel(IBeamShearRepository shearRepository, IBeamShearCalculatorInputData inputData)
{
this.shearRepository = shearRepository;
this.inputData = inputData;
InitializeViewModels();
}
private void InitializeViewModels()
{
ActionSourceTarget.SetTargetItems(inputData.Actions);
ActionSourceTarget.SetSourceItems(shearRepository.Actions);
ActionSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate();
StirrupSourceTarget.SetTargetItems(inputData.Stirrups);
StirrupSourceTarget.SetSourceItems(shearRepository.Stirrups);
StirrupSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate();
SectionSourceTarget.SetTargetItems(inputData.Sections);
SectionSourceTarget.SetSourceItems(shearRepository.Sections);
SectionSourceTarget.ItemDataDemplate = SourceTargetFactory.GetSimpleTemplate();
}
}
}

View File

@@ -0,0 +1,40 @@
<Window x:Class="StructureHelper.Windows.BeamShears.BeamShearCalculatorView"
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.BeamShears"
d:DataContext="{d:DesignInstance local:BeamShearCalculatorViewModel}"
mc:Ignorable="d"
Title="Beam Shear Calculator" Height="300" Width="350" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<TabControl Grid.Row="1" Grid.ColumnSpan="2" DataContext="{Binding InputDataViewModel}">
<TabItem Header="Sections">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding SectionSourceTarget}"/>
</TabItem>
<TabItem Header="Stirrups">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding StirrupSourceTarget}"/>
</TabItem>
<TabItem Header="Actions">
<ContentControl ContentTemplate="{StaticResource SourceToTarget}" Content="{Binding ActionSourceTarget}"/>
</TabItem>
</TabControl>
</Grid>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,19 @@
using System.Windows;
namespace StructureHelper.Windows.BeamShears
{
/// <summary>
/// Interaction logic for BeamShearCalculatorView.xaml
/// </summary>
public partial class BeamShearCalculatorView : Window
{
private BeamShearCalculatorViewModel viewModel;
public BeamShearCalculatorView(BeamShearCalculatorViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel;
}
}
}

View File

@@ -1,19 +1,29 @@
using StructureHelper.Windows.ViewModels;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.BeamShears
{
public class BeamShearCalculatorViewModel : OkCancelViewModelBase
{
private IBeamShearCalculator calculator;
public BeamShearCalculatorViewModel(IBeamShearCalculator calculator)
private readonly IBeamShearRepository shearRepository;
private readonly IBeamShearCalculator calculator;
public string Name
{
get => calculator.Name;
set
{
calculator.Name = value;
OnPropertyChanged(nameof(Name));
}
}
public BeamShearCalculatorInputDataViewModel InputDataViewModel { get; }
public BeamShearCalculatorViewModel(IBeamShearRepository shearRepository, IBeamShearCalculator calculator)
{
this.shearRepository = shearRepository;
this.calculator = calculator;
InputDataViewModel = new(this.shearRepository, this.calculator.InputData);
}
}
}

View File

@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
@@ -72,14 +73,17 @@ namespace StructureHelper.Windows.BeamShears
}
private void EditCalculator()
{
Window window;
if (SelectedItem is IBeamShearCalculator beamShearCalculator)
{
//to do
var viewModel = new BeamShearCalculatorViewModel(shearRepository, beamShearCalculator);
window = new BeamShearCalculatorView(viewModel);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
window.ShowDialog();
}
private void RunMethod(object param)
{

View File

@@ -1,24 +1,72 @@
using StructureHelper.Windows.ViewModels;
using StructureHelper.Infrastructure.Enums;
using StructureHelper.Windows.ViewModels;
using StructureHelper.Windows.ViewModels.Errors;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.BeamShears;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows;
namespace StructureHelper.Windows.BeamShears
{
public class BeamShearSectionsViewModel : SelectItemVM<IBeamShearSection>
{
IBeamShearRepository shearRepository;
public BeamShearSectionsViewModel(IBeamShearRepository shearRepository) : base(shearRepository.ShearSections)
private const string ErrorText = "Error of creating of section";
private IUpdateStrategy<IBeamShearSection> updateStrategy;
private IBeamShearRepository shearRepository;
private PrimitiveType sectionType;
public BeamShearSectionsViewModel(IBeamShearRepository shearRepository) : base(shearRepository.Sections)
{
this.shearRepository = shearRepository;
}
public override void EditMethod(object parameter)
{
if (SelectedItem is null) { return; }
SafetyProcessor.RunSafeProcess(EditSection, "Error of editing of section");
base.EditMethod(parameter);
}
public override void AddMethod(object parameter)
{
if (parameter is PrimitiveType primitiveType)
{
sectionType = primitiveType;
SafetyProcessor.RunSafeProcess(AddSection, ErrorText);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(parameter));
}
base.AddMethod(parameter);
}
private void AddSection()
{
if (sectionType is PrimitiveType.Rectangle)
{
NewItem = new BeamShearSection(Guid.NewGuid())
{
Name = "New rectangle section"
};
}
}
private void EditSection()
{
Window window;
IBeamShearSection temporarySection = SelectedItem.Clone() as IBeamShearSection;
window = new SectionView(SelectedItem);
window.ShowDialog();
if (window.DialogResult != true)
{
updateStrategy ??= new BeamShearSectionUpdateStrategy();
updateStrategy.Update(SelectedItem, temporarySection);
}
}
public override void DeleteMethod(object parameter)
{
shearRepository.DeleteSection(SelectedItem);
BeamShearRepositoryService.DeleteSection(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}

View File

@@ -24,9 +24,10 @@
</Viewbox>
</Button>
</ToolBar>
<ToolBar ToolTip="Sections">
<ToolBar ToolTip="Sections" DataContext="{Binding Sections}">
<Button Style="{StaticResource ToolButton}"
Command="{Binding FileOpen}">
Command="{Binding Add}"
CommandParameter="{x:Static enums:PrimitiveType.Rectangle}">
<Button.ToolTip>
<uc:ButtonToolTipEh HeaderText="Rectangle section"
IconContent="{StaticResource ShearRectangleSection}"

View File

@@ -9,8 +9,14 @@ using StructureHelperLogics.Models.Materials;
using System;
using System.Windows;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelper.Windows.BeamShears
{
/// <summary>
/// Implements logic of CRUD operations with stirrups in beam shear calculations
/// </summary>
public class BeamStirrupsViewModel : SelectItemVM<IStirrup>
{
private const string ErrorText = "Error of creating of stirrup";
@@ -22,37 +28,14 @@ namespace StructureHelper.Windows.BeamShears
{
this.shearRepository = shearRepository;
}
/// <inheritdoc/>
public override void EditMethod(object parameter)
{
if (SelectedItem is null) { return; }
SafetyProcessor.RunSafeProcess(EditStirrup, "Error of editing of stirrup");
base.EditMethod(parameter);
}
private void EditStirrup()
{
Window window;
IStirrup temporaryStirrup = SelectedItem.Clone() as IStirrup;
if (SelectedItem is IStirrupByDensity stirrupByDensity)
{
window = new StirrupByDensityView(stirrupByDensity);
}
//else if (SelectedItem is IStirrupByUniformRebar stirrupByUniformRebar)
//{
// window = ;
//}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
window.ShowDialog();
if (window.DialogResult != true)
{
updateStrategy ??= new StirrupUpdateStrategy();
}
}
/// <inheritdoc/>
public override void AddMethod(object parameter)
{
if (parameter is StirrupTypes stirrupParameter)
@@ -66,6 +49,29 @@ namespace StructureHelper.Windows.BeamShears
return;
}
}
private void EditStirrup()
{
Window window;
IStirrup temporaryStirrup = SelectedItem.Clone() as IStirrup;
if (SelectedItem is IStirrupByDensity stirrupByDensity)
{
window = new StirrupByDensityView(stirrupByDensity);
}
else if (SelectedItem is IStirrupByRebar stirrupByRebar)
{
window = new StirrupByRebarView(stirrupByRebar);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(SelectedItem));
}
window.ShowDialog();
if (window.DialogResult != true)
{
updateStrategy ??= new StirrupUpdateStrategy();
updateStrategy.Update(SelectedItem, temporaryStirrup);
}
}
private void AddStirrup()
{
@@ -73,26 +79,29 @@ namespace StructureHelper.Windows.BeamShears
{
AddStirrupByDensity();
}
if (stirrupType is StirrupTypes.UniformRebar)
else if (stirrupType is StirrupTypes.UniformRebar)
{
AddUniformRebarStirrup();
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(stirrupType));
}
base.AddMethod(stirrupType);
}
private void AddUniformRebarStirrup()
{
IReinforcementLibMaterial reinforcement = new ReinforcementLibMaterial(Guid.NewGuid());
NewItem = new StirrupByUniformRebar(Guid.NewGuid())
IReinforcementLibMaterial reinforcement = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400).HelperMaterial as IReinforcementLibMaterial;
NewItem = new StirrupByRebar(Guid.NewGuid())
{
Name = "New stirrup by uniformly distributed rebar",
Diameter = 0.008,
LegCount = 2,
Step = 0.1,
Spacing = 0.1,
Material = reinforcement
};
}
private void AddStirrupByDensity()
{
NewItem = new StirrupByDensity(Guid.NewGuid())
@@ -104,7 +113,7 @@ namespace StructureHelper.Windows.BeamShears
public override void DeleteMethod(object parameter)
{
shearRepository.DeleteStirrup(SelectedItem);
BeamShearRepositoryService.DeleteStirrup(shearRepository, SelectedItem);
base.DeleteMethod(parameter);
}
}

View File

@@ -0,0 +1,48 @@
<Window x:Class="StructureHelper.Windows.BeamShears.SectionView"
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.BeamShears"
d:DataContext="{d:DesignInstance local:SectionViewModel}"
mc:Ignorable="d"
Title="Beam shear section" Height="400" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary Source="/Infrastructure/UI/Resources/Materials.xaml"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Main">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Cover to center of rebar"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding CenterCover, Converter={StaticResource LengthConverter}}"/>
</Grid>
<!--ShapeEditTemplates.xaml-->
<ContentControl ContentTemplate="{StaticResource RectangleShapeEdit}" Content="{Binding Shape}"/>
</StackPanel>
</TabItem>
<TabItem Header="Material" DataContext="{Binding Material}">
<!--Material.xaml-->
<ContentControl ContentTemplate="{StaticResource ConcreteMaterial}" Content="{Binding}"/>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,24 @@
using StructureHelperLogics.Models.BeamShears;
using System.Windows;
namespace StructureHelper.Windows.BeamShears
{
/// <summary>
/// Interaction logic for SectionView.xaml
/// </summary>
public partial class SectionView : Window
{
private readonly SectionViewModel viewModel;
public SectionView(SectionViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel;
}
public SectionView(IBeamShearSection section) : this(new SectionViewModel(section))
{
}
}
}

View File

@@ -0,0 +1,51 @@
using StructureHelper.Windows.ViewModels;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.BeamShears;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelper.Windows.BeamShears
{
public class SectionViewModel : OkCancelViewModelBase
{
private readonly IBeamShearSection beamShearSection;
public string Name
{
get => beamShearSection.Name;
set
{
beamShearSection.Name = value;
}
}
public double CenterCover
{
get => beamShearSection.CenterCover;
set
{
if (value < 0)
{
value = 0;
}
beamShearSection.CenterCover = value;
}
}
public IRectangleShape Shape { get; }
public ConcreteViewModel Material { get; }
public SectionViewModel(IBeamShearSection beamShearSection)
{
this.beamShearSection = beamShearSection;
Material = new(beamShearSection.Material)
{
MaterialLogicVisibility = false,
TensionForULSVisibility = false,
TensionForSLSVisibility = false,
HumidityVisibility = false
};
Shape = beamShearSection.Shape as IRectangleShape;
}
}
}

View File

@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:StructureHelper.Windows.BeamShears"
d:DataContext="{d:DesignInstance local:StirrupByDensityViewModel}"
mc:Ignorable="d"
Title="Stirrup By Density" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
Title="Stirrups by uniform density" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>

View File

@@ -1,17 +1,5 @@
using StructureHelperLogics.Models.BeamShears;
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.BeamShears
{
@@ -26,6 +14,7 @@ namespace StructureHelper.Windows.BeamShears
InitializeComponent();
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel;
}
public StirrupByDensityView(IStirrupByDensity stirrupByDensity) : this(new StirrupByDensityViewModel(stirrupByDensity))
{

View File

@@ -0,0 +1,48 @@
<Window x:Class="StructureHelper.Windows.BeamShears.StirrupByRebarView"
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.BeamShears"
d:DataContext="{d:DesignInstance local:StirrupByRebarViewModel}"
mc:Ignorable="d"
Title="Stirrup by uniformly distributed rebars" Height="350" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Window.Resources>
<ResourceDictionary Source="/Infrastructure/UI/Resources/Materials.xaml"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<TabControl>
<TabItem Header="Main">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Name"/>
<TextBox Grid.Column="1" Text="{Binding Name}"/>
<TextBlock Grid.Row="1" Text="Diameter"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Diameter, Converter={StaticResource LengthConverter}}"/>
<TextBlock Grid.Row="2" Text="Number of legs"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding LegCount, Converter={StaticResource PlainDouble}}"/>
<TextBlock Grid.Row="3" Text="Spacing"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Spacing, Converter={StaticResource LengthConverter}}"/>
</Grid>
</TabItem>
<TabItem Header="Material" DataContext="{Binding Material}">
<ContentControl ContentTemplate="{StaticResource ReinforcementMaterial}" Content="{Binding}"/>
</TabItem>
</TabControl>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource OkCancelButtons}" Content="{Binding}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,36 @@
using StructureHelperLogics.Models.BeamShears;
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.BeamShears
{
/// <summary>
/// Interaction logic for StirrupByRebarView.xaml
/// </summary>
public partial class StirrupByRebarView : Window
{
private StirrupByRebarViewModel viewModel;
public StirrupByRebarView(StirrupByRebarViewModel viewModel)
{
InitializeComponent();
this.viewModel = viewModel;
this.viewModel.ParentWindow = this;
this.DataContext = this.viewModel;
}
public StirrupByRebarView(IStirrupByRebar stirrupByRebar) : this(new StirrupByRebarViewModel(stirrupByRebar))
{
}
}
}

View File

@@ -0,0 +1,70 @@
using StructureHelper.Windows.ViewModels;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperLogics.Models.BeamShears;
namespace StructureHelper.Windows.BeamShears
{
public class StirrupByRebarViewModel : OkCancelViewModelBase
{
private readonly IStirrupByRebar stirrupByRebar;
public string Name
{
get => stirrupByRebar.Name;
set
{
stirrupByRebar.Name = value;
}
}
public double Diameter
{
get => stirrupByRebar.Diameter;
set
{
if (value < 0)
{
value = 0.008;
}
stirrupByRebar.Diameter = value;
OnPropertyChanged(nameof(Diameter));
}
}
public double LegCount
{
get => stirrupByRebar.LegCount;
set
{
if (value < 0)
{
value = 0;
}
stirrupByRebar.LegCount = value;
OnPropertyChanged(nameof(LegCount));
}
}
public double Spacing
{
get => stirrupByRebar.Spacing;
set
{
if (value < 0)
{
value = 0.1;
}
stirrupByRebar.Spacing = value;
OnPropertyChanged(nameof(Spacing));
}
}
public ReinforcementViewModel Material { get; private set; }
public StirrupByRebarViewModel(IStirrupByRebar stirrupByRebar)
{
this.stirrupByRebar = stirrupByRebar;
Material = new(this.stirrupByRebar.Material) { MaterialLogicVisibility = false};
}
}
}

View File

@@ -1,20 +1,9 @@
using LoaderCalculator.Data.Materials;
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class ConcreteViewModel : LibMaterialViewModel<IConcreteMaterialEntity>
public class ConcreteViewModel : LibMaterialViewModel<IConcreteMaterialEntity>
{
readonly IConcreteLibMaterial concreteMaterial;
public bool TensionForULS
@@ -26,6 +15,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(TensionForULS));
}
}
public bool TensionForULSVisibility { get; set; } = true;
public bool TensionForSLS
{
get => concreteMaterial.TensionForSLS;
@@ -35,6 +25,7 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(TensionForSLS));
}
}
public bool TensionForSLSVisibility { get; set; } = true;
public double Humidity
{
get => concreteMaterial.RelativeHumidity;
@@ -44,14 +35,11 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(Humidity));
}
}
public bool HumidityVisibility { get; set; } = true;
public ConcreteViewModel(ILibMaterial material) : base(material)
public ConcreteViewModel(IConcreteLibMaterial concreteMaterial) : base(concreteMaterial)
{
if (material is not IConcreteLibMaterial)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $". Expected: {typeof(IConcreteLibMaterial)}, but was: {material.GetType()}");
}
concreteMaterial = material as IConcreteLibMaterial;
this.concreteMaterial = concreteMaterial;
}
}
}

View File

@@ -24,10 +24,10 @@ namespace StructureHelper.Windows.MainWindow.Materials
/// </summary>
public partial class HeadMaterialView : Window
{
IHeadMaterial headMaterial;
HeadMaterialViewModel viewModel;
Dictionary<string, Binding> bindings = new();
IHelperMaterial helperMaterial;
private readonly IHeadMaterial headMaterial;
private readonly HeadMaterialViewModel viewModel;
private readonly Dictionary<string, Binding> bindings = new();
private readonly IHelperMaterial helperMaterial;
string templateName;
public HeadMaterialView(HeadMaterialViewModel viewModel)
@@ -64,7 +64,7 @@ namespace StructureHelper.Windows.MainWindow.Materials
}
else if (helperMaterial is IReinforcementLibMaterial)
{
SetReinForcementLibraryMaterial();
SetReinforcementLibraryMaterial();
}
else if (helperMaterial is IElasticMaterial)
{
@@ -81,7 +81,7 @@ namespace StructureHelper.Windows.MainWindow.Materials
{
foreach (var item in bindings)
{
ContentControl contentControl = new ContentControl();
ContentControl contentControl = new();
contentControl.SetResourceReference(ContentTemplateProperty, item.Key);
contentControl.SetBinding(ContentProperty, item.Value);
StpMaterialProperties.Children.Add(contentControl);
@@ -105,11 +105,13 @@ namespace StructureHelper.Windows.MainWindow.Materials
frBinding.Source = (viewModel.HelperMaterialViewModel as ElasticViewModel).SafetyFactors;
bindings.Add(templateName, frBinding);
}
private void SetReinForcementLibraryMaterial()
private void SetReinforcementLibraryMaterial()
{
templateName = "ReinforcementMaterial";
var binding = new Binding();
binding.Source = viewModel.HelperMaterialViewModel;
var binding = new Binding
{
Source = viewModel.HelperMaterialViewModel
};
bindings.Add(templateName, binding);
}
private void SetConcreteLibraryMaterial()

View File

@@ -13,8 +13,8 @@ namespace StructureHelper.Windows.ViewModels.Materials
{
public class HeadMaterialViewModel : OkCancelViewModelBase
{
IHeadMaterial headMaterial;
HelperMaterialViewModel helperMaterialViewModel;
private readonly IHeadMaterial headMaterial;
private readonly HelperMaterialViewModel helperMaterialViewModel;
private ICommand showSafetyFactors;
private ICommand editColorCommand;
@@ -41,10 +41,9 @@ namespace StructureHelper.Windows.ViewModels.Materials
{
return showSafetyFactors ??= new RelayCommand(o =>
{
if (headMaterial is ILibMaterial)
if (headMaterial is ILibMaterial libMaterial)
{
var material = headMaterial as ILibMaterial;
var wnd = new SafetyFactorsView(material.SafetyFactors);
var wnd = new SafetyFactorsView(libMaterial.SafetyFactors);
wnd.ShowDialog();
}
}, o => headMaterial is LibMaterial
@@ -66,27 +65,23 @@ namespace StructureHelper.Windows.ViewModels.Materials
{
this.headMaterial = headMaterial;
var helperMaterial = headMaterial.HelperMaterial;
if (helperMaterial is IConcreteLibMaterial)
if (helperMaterial is IConcreteLibMaterial concreteMaterial)
{
var material = helperMaterial as IConcreteLibMaterial;
helperMaterialViewModel = new ConcreteViewModel(material);
helperMaterialViewModel = new ConcreteViewModel(concreteMaterial);
}
else if (helperMaterial is IReinforcementLibMaterial)
else if (helperMaterial is IReinforcementLibMaterial reinforcementMaterial)
{
var material = helperMaterial as IReinforcementLibMaterial;
helperMaterialViewModel = new LibMaterialViewModel<IReinforcementMaterialEntity>(material);
helperMaterialViewModel = new LibMaterialViewModel<IReinforcementMaterialEntity>(reinforcementMaterial);
}
else if (helperMaterial is IElasticMaterial)
else if (helperMaterial is IElasticMaterial elasticMaterial)
{
if (helperMaterial is IFRMaterial)
if (helperMaterial is IFRMaterial fRMaterial)
{
var material = helperMaterial as IFRMaterial;
helperMaterialViewModel = new FRViewModel(material);
helperMaterialViewModel = new FRViewModel(fRMaterial);
}
else
{
var material = helperMaterial as IElasticMaterial;
helperMaterialViewModel = new ElasticViewModel(material);
helperMaterialViewModel = new ElasticViewModel(elasticMaterial);
}
}
else

View File

@@ -1,23 +1,15 @@
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
using StructureHelper.Services.Primitives;
using StructureHelper.Windows.AddMaterialWindow;
using StructureHelper.Windows.MainWindow;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperCommon.Services.ColorServices;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections;
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;
using System.Windows.Media;
@@ -26,10 +18,10 @@ namespace StructureHelper.Windows.ViewModels.Materials
{
public class HeadMaterialsViewModel : ViewModelBase
{
IHasHeadMaterials parent;
List<IHeadMaterial> headMaterials;
IHeadMaterial selectedMaterial;
ILibMaterialEntity selectedLibMaterial;
private readonly IHasHeadMaterials parent;
private readonly List<IHeadMaterial> headMaterials;
private IHeadMaterial selectedMaterial;
private ILibMaterialEntity selectedLibMaterial;
public ICommand AddNewConcreteMaterialCommand { get;}
public ICommand AddNewReinforcementMaterialCommand { get; }

View File

@@ -1,29 +1,23 @@
using LoaderCalculator.Data.Materials;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure;
using StructureHelper.Windows.AddMaterialWindow;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class LibMaterialViewModel<T> : HelperMaterialViewModel where T: class, ILibMaterialEntity
public class LibMaterialViewModel<T> : HelperMaterialViewModel where T: class, ILibMaterialEntity
{
ILibMaterial material;
ICommand showSafetyFactors;
private readonly ILibMaterial material;
private ICommand showSafetyFactors;
SafetyFactorsViewModel safetyFactorsViewModel;
private ICodeEntity codeEntity;
private IMaterialLogic materialLogic;
//private IMaterialLogic materialLogic;
public ILibMaterialEntity MaterialEntity
{
@@ -50,28 +44,12 @@ namespace StructureHelper.Windows.ViewModels.Materials
}
public List<IMaterialLogic> MaterialLogics => material.MaterialLogics;
public IMaterialLogic MaterialLogic { get => material.MaterialLogic; set => material.MaterialLogic = value; }
private void FillMaterialKinds()
public IMaterialLogic MaterialLogic
{
var materialKinds = ProgramSetting
.MaterialRepository
.Repository
.Where(x => x.Code == codeEntity & x is T);
MaterialLibrary = new ObservableCollection<T>();
if (materialKinds.Count() > 0)
{
foreach (var item in materialKinds)
{
MaterialLibrary.Add((T)item);
}
OnPropertyChanged(nameof(MaterialLibrary));
material.MaterialEntity = MaterialLibrary.First();
OnPropertyChanged(nameof(MaterialEntity));
}
get => material.MaterialLogic;
set => material.MaterialLogic = value;
}
public bool MaterialLogicVisibility { get; set; } = true;
public ObservableCollection<ICodeEntity> CodeList { get; }
public ObservableCollection<T> MaterialLibrary { get; private set; }
public SafetyFactorsViewModel SafetyFactors => safetyFactorsViewModel;
@@ -85,7 +63,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(SafetyFactors));
});
public LibMaterialViewModel(ILibMaterial material)
{
this.material = material;
@@ -108,5 +85,24 @@ namespace StructureHelper.Windows.ViewModels.Materials
OnPropertyChanged(nameof(MaterialEntity));
safetyFactorsViewModel = new SafetyFactorsViewModel(material.SafetyFactors);
}
private void FillMaterialKinds()
{
var materialKinds = ProgramSetting
.MaterialRepository
.Repository
.Where(x => x.Code == codeEntity & x is T);
MaterialLibrary = new ObservableCollection<T>();
if (materialKinds.Count() > 0)
{
foreach (var item in materialKinds)
{
MaterialLibrary.Add((T)item);
}
OnPropertyChanged(nameof(MaterialLibrary));
material.MaterialEntity = MaterialLibrary.First();
OnPropertyChanged(nameof(MaterialEntity));
}
}
}
}

View File

@@ -0,0 +1,21 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
public class ReinforcementViewModel : LibMaterialViewModel<IReinforcementMaterialEntity>
{
public ReinforcementViewModel(IReinforcementLibMaterial reinforcementMaterial) : base(reinforcementMaterial)
{
}
}
}

View File

@@ -2,18 +2,12 @@
using StructureHelper.Windows.AddMaterialWindow;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class SafetyFactorsViewModel : SelectItemVM<IMaterialSafetyFactor>
public class SafetyFactorsViewModel : SelectItemVM<IMaterialSafetyFactor>
{
List<IMaterialSafetyFactor> safetyFactors;
private RelayCommand showPartialCommand;
@@ -22,13 +16,12 @@ namespace StructureHelper.Windows.ViewModels.Materials
{
get
{
return showPartialCommand ??
(showPartialCommand = new RelayCommand(o =>
return showPartialCommand ??= new RelayCommand(o =>
{
var wnd = new PartialFactorsView(SelectedItem.PartialFactors);
wnd.ShowDialog();
}, o => SelectedItem != null
));
);
}
}

View File

@@ -9,23 +9,9 @@
mc:Ignorable="d"
Title="PrimitiveProperties" Height="450" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<DataTemplate x:Key="RectangleProperties">
<Expander Header="Rectangle" IsExpanded="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Text="Width"/>
<TextBlock Grid.Row="1" Text="Height"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Width, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding Height, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
</Grid>
<ContentControl ContentTemplate="{StaticResource RectangleShapeEdit}" Content="{Binding}"/>
</Expander>
</DataTemplate>
<DataTemplate x:Key="CircleProperties">

View File

@@ -0,0 +1,12 @@
<UserControl x:Class="StructureHelper.Windows.UserControls.ReinforcementSelector"
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.UserControls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>

View File

@@ -0,0 +1,28 @@
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.UserControls
{
/// <summary>
/// Interaction logic for ReinforcementSelector.xaml
/// </summary>
public partial class ReinforcementSelector : UserControl
{
public ReinforcementSelector()
{
InitializeComponent();
}
}
}

View File

@@ -38,6 +38,16 @@ namespace StructureHelper.Windows.ViewModels
return result;
}
public static DataTemplate GetSimpleTemplate()
{
return GetDataTemplate(SimpleItemTemplate);
}
public static DataTemplate GetColoredTemplate()
{
return GetDataTemplate(ColoredItemTemplate);
}
private static DataTemplate GetDataTemplate(string dataTemplateName)
{
DataTemplate dataTemplate;

View File

@@ -1,33 +0,0 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class ReinforcementViewModel
{
public IEnumerable<ICodeEntity> CodeList => ProgramSetting
.MaterialRepository
.Repository
.Select( x => x.Code)
.Distinct();
public IEnumerable<ILibMaterialEntity> MaterialLibrary => LibMaterialPepository.GetReinforcementRepository();
public ReinforcementViewModel(ILibMaterial material)
{
if (material is not IReinforcementLibMaterial)
{
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $". Expected: {typeof(IConcreteLibMaterial)}, but was: {material.GetType()}");
}
}
}
}

View File

@@ -1,7 +1,5 @@
using LoaderCalculator;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -86,7 +84,10 @@ namespace StructureHelper.Windows.ViewModels
));
}
}
/// <summary>
/// Incaplsulates logic of editing of object when Edit-command runs
/// </summary>
/// <param name="parameter"></param>
public virtual void EditMethod(object parameter)
{
Items.Clear();

View File

@@ -12,7 +12,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
/// </summary>
public interface IHasBeamShearActions
{
List<IBeamShearAction> BeamShearActions { get; }
void DeleteAction(IBeamShearAction action);
List<IBeamShearAction> Actions { get; }
}
}

View File

@@ -47,10 +47,10 @@ namespace StructureHelperCommon.Models.Forces.BeamShearActions
private static void SetExternalForceFactors(IFactoredCombinationProperty combinationProperty)
{
combinationProperty.CalcTerm = CalcTerms.ShortTerm;
combinationProperty.LimitState = LimitStates.ULS;
combinationProperty.CalcTerm = CalcTerms.ShortTerm;
combinationProperty.LongTermFactor = 1;
combinationProperty.ULSFactor = 1;
combinationProperty.ULSFactor = 1.2;
}
private static void SetAction(IBeamShearAxisAction beamShearAxisAction, double supportForce)

View File

@@ -16,9 +16,9 @@ namespace StructureHelperLogics.Models.BeamShears
/// <inheritdoc/>
public List<IBeamShearAction> BeamShearActions { get; } = new();
public List<IBeamShearAction> Actions { get; } = new();
/// <inheritdoc/>
public List<IBeamShearSection> ShearSections { get; } = new();
public List<IBeamShearSection> Sections { get; } = new();
/// <inheritdoc/>
public List<IStirrup> Stirrups { get; } = new();
public BeamShearCalculatorInputData(Guid id)

View File

@@ -67,11 +67,11 @@ namespace StructureHelperLogics.Models.BeamShears
private void GetSectionInputDatas(IBeamShearCalculatorInputData inputData)
{
sectionInputDatas = new();
foreach (var beamShearSection in inputData.ShearSections)
foreach (var beamShearSection in inputData.Sections)
{
foreach (var stirrup in inputData.Stirrups)
{
foreach (var beamShearAction in inputData.BeamShearActions)
foreach (var beamShearAction in inputData.Actions)
{
BeamShearSectionCalculatorInputData newInputData = new(Guid.NewGuid())
{

View File

@@ -14,11 +14,11 @@ namespace StructureHelperLogics.Models.BeamShears
public Guid Id { get; }
public List<IBeamShearAction> BeamShearActions { get; } = new();
public List<IBeamShearAction> Actions { get; } = new();
public List<ICalculator> Calculators { get; } = new();
public List<IBeamShearSection> ShearSections { get; } = new();
public List<IBeamShearSection> Sections { get; } = new();
public List<IStirrup> Stirrups { get; } = new();
@@ -28,65 +28,9 @@ namespace StructureHelperLogics.Models.BeamShears
Id = id;
}
public void DeleteBeamShearAction(IBeamShearAction beamShearAction)
{
foreach (var calculator in Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
var inputData = beamShearCalculator.InputData;
inputData.BeamShearActions.Remove(beamShearAction);
}
}
BeamShearActions.Remove(beamShearAction);
}
public object Clone()
{
throw new NotImplementedException();
}
public void DeleteSection(IBeamShearSection section)
{
foreach (var calculator in Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
if (beamShearCalculator.InputData.ShearSections.Contains(section))
{
beamShearCalculator.InputData.DeleteSection(section);
beamShearCalculator.InputData.ShearSections.Remove(section);
}
}
}
}
public void DeleteAction(IBeamShearAction action)
{
foreach (var calculator in Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
if (beamShearCalculator.InputData.BeamShearActions.Contains(action))
{
beamShearCalculator.InputData.DeleteAction(action);
beamShearCalculator.InputData.BeamShearActions.Remove(action);
}
}
}
}
public void DeleteStirrup(IStirrup stirrup)
{
foreach (var calculator in Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
if (beamShearCalculator.InputData.Stirrups.Contains(stirrup))
{
beamShearCalculator.InputData.DeleteStirrup(stirrup);
beamShearCalculator.InputData.Stirrups.Remove(stirrup);
}
}
}
}
}
}

View File

@@ -1,4 +1,4 @@
using StructureHelperCommon.Models.Materials;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperLogics.Models.Materials;
@@ -6,24 +6,30 @@ namespace StructureHelperLogics.Models.BeamShears
{
public class BeamShearSection : IBeamShearSection
{
private IUpdateStrategy<IBeamShearSection> updateStrategy;
public Guid Id { get; }
public string? Name { get; set; }
/// <inheritdoc/>
public IMaterialStrength MaterialStrength { get; } = new MaterialStrengthByLibMaterial(Guid.NewGuid(), new ConcreteLibMaterial(Guid.NewGuid()));
public IConcreteLibMaterial Material { get; set; }
/// <inheritdoc/>
public IShape Shape { get; } = new RectangleShape(Guid.NewGuid()) { Height = 0.6, Width = 0.4};
public double CenterCover { get; set; }
public double CenterCover { get; set; } = 0.05;
public BeamShearSection(Guid id)
{
Id = id;
Material = ConcreteLibMaterialFactory.GetConcreteLibMaterial(ConcreteLibTypes.Concrete25);
Material.TensionForULS = true;
}
public object Clone()
{
throw new NotImplementedException();
BeamShearSection newItem = new(Guid.NewGuid());
updateStrategy ??= new BeamShearSectionUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -32,14 +32,15 @@ namespace StructureHelperLogics.Models.BeamShears
BeamShearRepository shearRepository = new(Guid.Empty);
IBeamShearAction shearAction = BeamShearActionFactory.GetBeamShearAction(ShearActionTypes.DistributedLoad);
shearAction.Name = "New shear action";
shearRepository.BeamShearActions.Add(shearAction);
shearRepository.Actions.Add(shearAction);
BeamShearSection section = new(Guid.Empty) { Name = "New shear section"};
shearRepository.ShearSections.Add(section);
StirrupByUniformRebar stirrupByUniformRebar = new(Guid.Empty) { Name = "New uniform stirrup"};
shearRepository.Sections.Add(section);
StirrupByRebar stirrupByUniformRebar = new(Guid.Empty) { Name = "New uniform stirrup"};
shearRepository.Stirrups.Add(stirrupByUniformRebar);
BeamShearCalculator beamShearCalculator = new(Guid.Empty) { Name = "New shear calculator"};
beamShearCalculator.InputData.ShearSections.Add(section);
beamShearCalculator.InputData.Sections.Add(section);
beamShearCalculator.InputData.Stirrups.Add(stirrupByUniformRebar);
beamShearCalculator.InputData.Actions.Add(shearAction);
shearRepository.Calculators.Add(beamShearCalculator);
return shearRepository;
}

View File

@@ -19,7 +19,7 @@ namespace StructureHelperLogics.Models.BeamShears
/// <summary>
/// Concrete of cross-section
/// </summary>
IMaterialStrength MaterialStrength { get;}
IConcreteLibMaterial Material { get; set; }
/// <summary>
/// Shape of cross-section
/// </summary>

View File

@@ -8,7 +8,6 @@ namespace StructureHelperLogics.Models.BeamShears
{
public interface IHasBeamShearSections
{
List<IBeamShearSection> ShearSections { get; }
void DeleteSection(IBeamShearSection section);
List<IBeamShearSection> Sections { get; }
}
}

View File

@@ -9,6 +9,5 @@ namespace StructureHelperLogics.Models.BeamShears
public interface IHasStirrups
{
List<IStirrup> Stirrups { get; }
void DeleteStirrup(IStirrup stirrup);
}
}

View File

@@ -1,9 +1,7 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.Models.BeamShears
{

View File

@@ -10,7 +10,7 @@ namespace StructureHelperLogics.Models.BeamShears
/// <summary>
/// Implement properties for uniformly distributed stirrups
/// </summary>
public interface IStirrupByUniformRebar : IStirrup
public interface IStirrupByRebar : IStirrup
{
/// <summary>
/// Material of stirrups
@@ -27,6 +27,6 @@ namespace StructureHelperLogics.Models.BeamShears
/// <summary>
/// Step of uniformly distibuted stirrup along axis of beam, m
/// </summary>
double Step { get; set; }
double Spacing { get; set; }
}
}

View File

@@ -11,8 +11,8 @@ namespace StructureHelperLogics.Models.BeamShears
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
targetObject.BeamShearActions.AddRange(sourceObject.BeamShearActions);
targetObject.ShearSections.AddRange(sourceObject.ShearSections);
targetObject.Actions.AddRange(sourceObject.Actions);
targetObject.Sections.AddRange(sourceObject.Sections);
targetObject.Stirrups.AddRange(sourceObject.Stirrups);
targetObject.Calculators.AddRange(sourceObject.Calculators);
}

View File

@@ -0,0 +1,52 @@
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Forces.BeamShearActions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public static class BeamShearRepositoryService
{
public static void DeleteAction(IBeamShearRepository repository, IBeamShearAction action)
{
foreach (var calculator in repository.Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
var inputData = beamShearCalculator.InputData;
inputData.Actions.Remove(action);
}
}
repository.Actions.Remove(action);
}
public static void DeleteSection(IBeamShearRepository repository, IBeamShearSection section)
{
foreach (var calculator in repository.Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
if (beamShearCalculator.InputData.Sections.Contains(section))
{
beamShearCalculator.InputData.Sections.Remove(section);
}
}
}
}
public static void DeleteStirrup(IBeamShearRepository repository, IStirrup stirrup)
{
foreach (var calculator in repository.Calculators)
{
if (calculator is IBeamShearCalculator beamShearCalculator)
{
if (beamShearCalculator.InputData.Stirrups.Contains(stirrup))
{
beamShearCalculator.InputData.Stirrups.Remove(stirrup);
}
}
}
}
}
}

View File

@@ -0,0 +1,37 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models.Shapes;
using StructureHelperCommon.Models.Shapes.Logics;
using StructureHelperCommon.Services;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class BeamShearSectionUpdateStrategy : IUpdateStrategy<IBeamShearSection>
{
private IUpdateStrategy<IShape> shapeUpdateStrategy;
private IUpdateStrategy<IConcreteLibMaterial> concreteUpdateStrategy;
public void Update(IBeamShearSection targetObject, IBeamShearSection sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; }
InitializeStrategies();
targetObject.Name = sourceObject.Name;
shapeUpdateStrategy.Update(targetObject.Shape, sourceObject.Shape);
targetObject.Material ??= new ConcreteLibMaterial();
concreteUpdateStrategy.Update(targetObject.Material, sourceObject.Material);
targetObject.CenterCover = sourceObject.CenterCover;
}
private void InitializeStrategies()
{
shapeUpdateStrategy ??= new ShapeUpdateStrategy();
concreteUpdateStrategy ??= new ConcreteLibUpdateStrategy();
}
}
}

View File

@@ -1,17 +1,13 @@
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Loggers;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Copyright (c) 2025 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.Models.BeamShears
{
/// <inheritdoc/>
public class BeamShearStrengthByStirrupDensityLogic : IBeamShearStrenghLogic
{
private readonly IStirrupEffectiveness stirrupEffectiveness;
@@ -32,7 +28,7 @@ namespace StructureHelperLogics.Models.BeamShears
}
public IShiftTraceLogger? TraceLogger { get; set; }
/// <inheritdoc/>
public double GetShearStrength()
{
Check();

View File

@@ -34,13 +34,13 @@ namespace StructureHelperLogics.Models.BeamShears
string errorString = ErrorStrings.ParameterIsNull + ": Input data";
throw new StructureHelperException(errorString);
}
if (InputData.BeamShearActions is null || ! InputData.BeamShearActions.Any())
if (InputData.Actions is null || ! InputData.Actions.Any())
{
result = false;
string errorString = "Collection of actions does not contain any action";
TraceMessage(errorString);
}
if (InputData.ShearSections is null || ! InputData.ShearSections.Any())
if (InputData.Sections is null || ! InputData.Sections.Any())
{
result = false;
string errorString = "Collection of sections does not contain any section";

View File

@@ -1,12 +1,7 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears.Logics
namespace StructureHelperLogics.Models.BeamShears
{
public class StirrupBaseUpdateStrategy : IUpdateStrategy<IStirrup>
{

View File

@@ -4,7 +4,7 @@ using StructureHelperCommon.Services;
//Copyright (c) 2026 Redikultsev Evgeny, Ekaterinburg, Russia
//All rights reserved.
namespace StructureHelperLogics.Models.BeamShears.Logics
namespace StructureHelperLogics.Models.BeamShears
{
public class StirrupByDensityUpdateStrategy : IUpdateStrategy<IStirrupByDensity>
{

View File

@@ -1,15 +1,10 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
public class StirrupByUniformRebarToDensityConvertStrategy : IConvertStrategy<IStirrupByDensity, IStirrupByUniformRebar>
public class StirrupByRebarToDensityConvertStrategy : IConvertStrategy<IStirrupByDensity, IStirrupByRebar>
{
private const double stirrupStrengthFactor = 1d;
private const double maxStirrupStrength = 3e8;
@@ -18,30 +13,30 @@ namespace StructureHelperLogics.Models.BeamShears
public Dictionary<(Guid id, Type type), ISaveable> ReferenceDictionary { get; set; }
public IShiftTraceLogger TraceLogger { get; set; }
public StirrupByUniformRebarToDensityConvertStrategy(IUpdateStrategy<IStirrup> updateStrategy, IShiftTraceLogger traceLogger)
public StirrupByRebarToDensityConvertStrategy(IUpdateStrategy<IStirrup> updateStrategy, IShiftTraceLogger traceLogger)
{
this.updateStrategy = updateStrategy;
TraceLogger = traceLogger;
}
public IStirrupByDensity Convert(IStirrupByUniformRebar source)
public IStirrupByDensity Convert(IStirrupByRebar source)
{
updateStrategy ??= new StirrupUpdateStrategy();
updateStrategy ??= new StirrupBaseUpdateStrategy();
StirrupByDensity stirrupByDensity = new(Guid.NewGuid());
updateStrategy.Update(stirrupByDensity, source);
stirrupByDensity.StirrupDensity = GetStirrupDensity(source);
return stirrupByDensity;
}
private double GetStirrupDensity(IStirrupByUniformRebar source)
private double GetStirrupDensity(IStirrupByRebar source)
{
double area = Math.PI * source.Diameter * source.Diameter / 4d;
TraceLogger?.AddMessage($"Area of rebar = {Math.PI} * ({source.Diameter})^2 / 4 = {area}, m^2");
double strength = stirrupStrengthFactor * source.Material.GetStrength(LimitStates.ULS, CalcTerms.ShortTerm).Tensile;
TraceLogger?.AddMessage($"Strength of rebar = {strength}, Pa");
strength = Math.Min(strength, maxStirrupStrength);
double density = strength * area * source.LegCount / source.Step;
TraceLogger?.AddMessage($"Density of stirrups = {strength} * {area} * {source.LegCount} / {source.Step} = {density}, N/m");
double density = strength * area * source.LegCount / source.Spacing;
TraceLogger?.AddMessage($"Density of stirrups = {strength} * {area} * {source.LegCount} / {source.Spacing} = {density}, N/m");
return density;
}
}

View File

@@ -7,12 +7,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears.Logics
namespace StructureHelperLogics.Models.BeamShears
{
public class StirrupByUniformRebarUpdateStrategy : IUpdateStrategy<IStirrupByUniformRebar>
public class StirrupByRebarUpdateStrategy : IUpdateStrategy<IStirrupByRebar>
{
private IUpdateStrategy<IStirrup>? baseUpdateStrategy;
public void Update(IStirrupByUniformRebar targetObject, IStirrupByUniformRebar sourceObject)
public void Update(IStirrupByRebar targetObject, IStirrupByRebar sourceObject)
{
CheckObject.IsNull(targetObject);
CheckObject.IsNull(sourceObject);
@@ -23,7 +23,7 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
targetObject.Material = sourceObject.Material.Clone() as IReinforcementLibMaterial;
targetObject.Diameter = sourceObject.Diameter;
targetObject.LegCount = sourceObject.LegCount;
targetObject.Step = sourceObject.Step;
targetObject.Spacing = sourceObject.Spacing;
}
}
}

View File

@@ -12,7 +12,7 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
public class StirrupUpdateStrategy : IUpdateStrategy<IStirrup>
{
private IUpdateStrategy<IStirrupByDensity> densityUpdateStrategy;
private IUpdateStrategy<IStirrupByUniformRebar> uniformUpdateStrategy;
private IUpdateStrategy<IStirrupByRebar> uniformUpdateStrategy;
public void Update(IStirrup targetObject, IStirrup sourceObject)
{
CheckObject.IsNull(targetObject);
@@ -22,7 +22,7 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
{
UpdateByDensity(targetObject, density);
}
else if (sourceObject is IStirrupByUniformRebar stirrupByUniformRebar)
else if (sourceObject is IStirrupByRebar stirrupByUniformRebar)
{
UpdateByUniformRebar(targetObject, stirrupByUniformRebar);
}
@@ -32,10 +32,10 @@ namespace StructureHelperLogics.Models.BeamShears.Logics
}
}
private void UpdateByUniformRebar(IStirrup targetObject, IStirrupByUniformRebar stirrupByUniformRebar)
private void UpdateByUniformRebar(IStirrup targetObject, IStirrupByRebar stirrupByUniformRebar)
{
uniformUpdateStrategy ??= new StirrupByUniformRebarUpdateStrategy();
if (targetObject is IStirrupByUniformRebar targetUniformRebar)
uniformUpdateStrategy ??= new StirrupByRebarUpdateStrategy();
if (targetObject is IStirrupByRebar targetUniformRebar)
{
uniformUpdateStrategy.Update(targetUniformRebar, stirrupByUniformRebar);
}

View File

@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Infrastructures.Interfaces;
namespace StructureHelperLogics.Models.BeamShears
{
public class StirrupByDensity : IStirrupByDensity
{
private IUpdateStrategy<IStirrupByDensity> updateStrategy;
public Guid Id { get; }
public string Name { get; set; } = string.Empty;
public double StirrupDensity { get; set; }
@@ -20,7 +17,10 @@ namespace StructureHelperLogics.Models.BeamShears
public object Clone()
{
throw new NotImplementedException();
StirrupByDensity newItem = new(Guid.NewGuid());
updateStrategy ??= new StirrupByDensityUpdateStrategy();
updateStrategy.Update(newItem, this);
return newItem;
}
}
}

View File

@@ -0,0 +1,75 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperLogics.Models.Materials;
namespace StructureHelperLogics.Models.BeamShears
{
/// <inheritdoc/>
public class StirrupByRebar : IStirrupByRebar
{
private IUpdateStrategy<IStirrupByRebar> updateStrategy;
private double diameter = 0.008;
private double step = 0.1;
private double legCount = 2;
/// <inheritdoc/>
public Guid Id { get; }
public string? Name { get; set; }
/// <inheritdoc/>
public IReinforcementLibMaterial Material { get; set; }
/// <inheritdoc/>
public double LegCount
{
get => legCount; set
{
if (value < 0)
{
throw new StructureHelperException("Number of legs of stirrup must be greater than zero");
}
legCount = value;
}
} /// <inheritdoc/>
public double Diameter
{
get => diameter; set
{
if (value < 0.001)
{
throw new StructureHelperException("Diameter of stirrup must not be less than 1mm");
}
if (value > 0.050)
{
throw new StructureHelperException("Diameter of stirrup must be less or equal than 50mm");
}
diameter = value;
}
} /// <inheritdoc/>
public double Spacing
{
get => step; set
{
if (value < 0.01)
{
throw new StructureHelperException("Spacing of stirrups must not be less than 10mm");
}
step = value;
}
} /// <inheritdoc/>
public double CompressedGap { get; set; } = 0;
public StirrupByRebar(Guid id)
{
Id = id;
Material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Reinforcement400).HelperMaterial as IReinforcementLibMaterial;
}
public object Clone()
{
StirrupByRebar stirrupByRebar = new(Guid.NewGuid());
updateStrategy ??= new StirrupByRebarUpdateStrategy();
updateStrategy.Update(stirrupByRebar, this);
return stirrupByRebar;
}
}
}

View File

@@ -1,38 +0,0 @@
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
/// <inheritdoc/>
public class StirrupByUniformRebar : IStirrupByUniformRebar
{
/// <inheritdoc/>
public Guid Id { get; }
public string? Name { get; set; }
/// <inheritdoc/>
public IReinforcementLibMaterial Material { get; set; }
/// <inheritdoc/>
public double LegCount { get; set; } = 2;
/// <inheritdoc/>
public double Diameter { get; set; } = 0.008;
/// <inheritdoc/>
public double Step { get; set; } = 0.1;
/// <inheritdoc/>
public double CompressedGap { get; set; } = 0;
public StirrupByUniformRebar(Guid id)
{
Id = id;
}
public object Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -1,23 +0,0 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Interfaces;
using StructureHelperCommon.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.BeamShears
{
internal class StirrupUpdateStrategy : IUpdateStrategy<IStirrup>
{
public void Update(IStirrup targetObject, IStirrup sourceObject)
{
CheckObject.IsNull(sourceObject, ErrorStrings.SourceObject);
CheckObject.IsNull(targetObject, ErrorStrings.TargetObject);
if (ReferenceEquals(targetObject, sourceObject)) { return; };
targetObject.CompressedGap = sourceObject.CompressedGap;
targetObject.Name = sourceObject.Name;
}
}
}

View File

@@ -28,17 +28,17 @@ namespace StructureHelperLogics.Models.Materials
/// <inheritdoc/>
public List<IMaterialSafetyFactor> SafetyFactors { get; set; }
/// <inheritdoc/>
public bool TensionForULS { get ; set; }
public bool TensionForULS { get; set; } = false;
/// <inheritdoc/>
public bool TensionForSLS { get; set; }
public bool TensionForSLS { get; set; } = true;
/// <inheritdoc/>
public double RelativeHumidity { get; set; }
public double RelativeHumidity { get; set; } = 0.55d;
/// <inheritdoc/>
public IMaterialLogic MaterialLogic { get; set; }
/// <inheritdoc/>
public double MinAge { get; set; }
public double MinAge { get; set; } = 0d;
/// <inheritdoc/>
public double MaxAge { get; set; }
public double MaxAge { get; set; } = maxAge;
/// <inheritdoc/>
public List<IMaterialLogic> MaterialLogics => materialLogics;
@@ -51,11 +51,6 @@ namespace StructureHelperLogics.Models.Materials
SafetyFactors = new List<IMaterialSafetyFactor>();
lmOptions = new LMBuilders.ConcreteOptions();
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType));
TensionForULS = false;
TensionForSLS = true;
RelativeHumidity = 0.55d;
MinAge = 0d;
MaxAge = maxAge;
}
public ConcreteLibMaterial() : this (Guid.NewGuid())

View File

@@ -0,0 +1,49 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Models.Materials.Libraries;
namespace StructureHelperLogics.Models.Materials
{
public enum ConcreteLibTypes
{
Concrete15,
Concrete20,
Concrete25,
Concrete30,
Concrete35,
Concrete40,
}
public static class ConcreteLibMaterialFactory
{
private static IEnumerable<ILibMaterialEntity> LibConcreteMaterials => LibMaterialPepository.GetConcreteRepository();
public static IConcreteLibMaterial GetConcreteLibMaterial(ConcreteLibTypes concreteLibTypes)
{
if (concreteLibTypes == ConcreteLibTypes.Concrete25)
{
return GetConcrete(25);
}
if (concreteLibTypes == ConcreteLibTypes.Concrete40)
{
return GetConcrete(40);
}
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(concreteLibTypes));
}
}
private static IConcreteLibMaterial GetConcrete(double strength)
{
string stringStrength = Convert.ToString(strength);
var libMaterial = LibConcreteMaterials
.Where(x => x.Name.Contains(stringStrength))
.First();
var libMat = new ConcreteLibMaterial
{
MaterialEntity = libMaterial,
TensionForULS = false,
TensionForSLS = true
};
return libMat;
}
}
}

View File

@@ -1,15 +1,7 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Codes;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials
{
@@ -17,7 +9,7 @@ namespace StructureHelperLogics.Models.Materials
{
Concrete40,
Reinforcement400,
Reinforecement500,
Reinforcement500,
Elastic200,
Carbon1400,
Glass1200
@@ -33,7 +25,7 @@ namespace StructureHelperLogics.Models.Materials
{
if (type == HeadmaterialType.Concrete40) { return GetConcrete40(); }
if (type == HeadmaterialType.Reinforcement400) { return GetReinforcement400(); }
if (type == HeadmaterialType.Reinforecement500) { return GetReinforcement500(); }
if (type == HeadmaterialType.Reinforcement500) { return GetReinforcement500(); }
if (type == HeadmaterialType.Elastic200) { return GetElastic200(); }
if (type == HeadmaterialType.Carbon1400) { return GetCarbon1400(); }
if (type == HeadmaterialType.Glass1200) { return GetGlass1200(); }
@@ -94,12 +86,7 @@ namespace StructureHelperLogics.Models.Materials
private static IHeadMaterial GetConcrete40()
{
var material = new HeadMaterial();
var libMaterial = LibConcreteMaterials.Where(x => x.Name.Contains("40")).First();
var libMat = new ConcreteLibMaterial();
libMat.MaterialEntity = libMaterial;
libMat.TensionForULS = false;
libMat.TensionForSLS = true;
material.HelperMaterial = libMat;
material.HelperMaterial = ConcreteLibMaterialFactory.GetConcreteLibMaterial(ConcreteLibTypes.Concrete40);
return material;
}
}

View File

@@ -1,12 +1,5 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace StructureHelperLogics.Models.Templates.CrossSections.RCs

View File

@@ -1,9 +1,4 @@
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.NdmCalculations.Primitives
{

View File

@@ -17,7 +17,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
{
private Mock<IUpdateStrategy<IStirrup>> _mockUpdateStrategy;
private Mock<IShiftTraceLogger> _mockTraceLogger;
private StirrupByUniformRebarToDensityConvertStrategy _convertStrategy;
private StirrupByRebarToDensityConvertStrategy _convertStrategy;
[SetUp]
public void Setup()
@@ -25,7 +25,7 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
_mockUpdateStrategy = new Mock<IUpdateStrategy<IStirrup>>();
_mockTraceLogger = new Mock<IShiftTraceLogger>();
_convertStrategy = new StirrupByUniformRebarToDensityConvertStrategy(
_convertStrategy = new StirrupByRebarToDensityConvertStrategy(
_mockUpdateStrategy.Object,
_mockTraceLogger.Object
);
@@ -38,11 +38,11 @@ namespace StructureHelperTests.UnitTests.BeamShearTests
var mockMaterial = new Mock<IReinforcementLibMaterial>();
mockMaterial.Setup(m => m.GetStrength(LimitStates.ULS, CalcTerms.ShortTerm)).Returns((2e8, 2e8));
var stirrupRebar = new Mock<IStirrupByUniformRebar>();
var stirrupRebar = new Mock<IStirrupByRebar>();
stirrupRebar.Setup(s => s.Diameter).Returns(0.02);
stirrupRebar.Setup(s => s.Material).Returns(mockMaterial.Object);
stirrupRebar.Setup(s => s.LegCount).Returns(2);
stirrupRebar.Setup(s => s.Step).Returns(0.15);
stirrupRebar.Setup(s => s.Spacing).Returns(0.15);
// Act
var result = _convertStrategy.Convert(stirrupRebar.Object);

View File

@@ -10,10 +10,10 @@ namespace StructureHelperTests.UnitTests.MaterialTests
{
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 339130434.78260875d, 339130434.78260875d)]
[TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 390000000d, 390000000d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 400000000.0d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 434782608.69565225d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
[TestCase(HeadmaterialType.Reinforecement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
[TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 400000000.0d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 434782608.69565225d, 434782608.69565225d)]
[TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
[TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
[TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 22461538.46153846d, 1395297.0017909051d)]
[TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 20215384.615384616d, 1255767.3016118146d)]
[TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 29200000.0d, 2092945.5026863578d)]