Interpolation View for calculation result was added

This commit is contained in:
Evgeny Redikultsev
2023-01-08 14:11:16 +05:00
parent 2d7c8648ab
commit 401e3dd02b
52 changed files with 1428 additions and 61 deletions

View File

@@ -11,6 +11,10 @@
<ResourceDictionary Source="Infrastructure/UI/Resources/Converters.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/PrimitiveToolTips.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ITemEditPanels.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/ButtonStyles.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/CommonEnums.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridTemplates.xaml"/>
<ResourceDictionary Source="Infrastructure/UI/Resources/DataGridStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

View File

@@ -0,0 +1,53 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="ButtonBase">
</Style>
<Style TargetType="Button" x:Key="CommandButton" BasedOn="{StaticResource ButtonBase}">
<Style.Setters>
<Setter Property="Height" Value="25"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="AddButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Add"/>
<Setter Property="Command" Value="{Binding Add}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="EditButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Edit"/>
<Setter Property="Command" Value="{Binding Edit}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="DeleteButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Delete"/>
<Setter Property="Command" Value="{Binding Delete}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="CopyButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Copy"/>
<Setter Property="Command" Value="{Binding Copy}"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="OkButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Ok"/>
<Setter Property="IsDefault" Value="True"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Margin" Value="5"/>
</Style.Setters>
</Style>
<Style TargetType="Button" x:Key="CancelButton" BasedOn="{StaticResource CommandButton}">
<Style.Setters>
<Setter Property="Content" Value="Cancel"/>
<Setter Property="IsCancel" Value="True"/>
<Setter Property="Width" Value="60"/>
<Setter Property="Margin" Value="5"/>
</Style.Setters>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,21 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="clr-namespace:System;assembly=mscorlib"
xmlns:enums="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon">
<ObjectDataProvider x:Key="StressStateEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:StressStates"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="LimitStateEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:LimitStates"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<ObjectDataProvider x:Key="CalcTermEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type Type="enums:CalcTerms"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</ResourceDictionary>

View File

@@ -0,0 +1,15 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="DataGrid" x:Key="DataGridBase">
<Style.Setters>
<Setter Property="AutoGenerateColumns" Value="False"/>
</Style.Setters>
</Style>
<Style TargetType="DataGrid" x:Key="ItemsDataGrid" BasedOn="{StaticResource DataGridBase}">
<Style.Setters>
<Setter Property="ItemsSource" Value="{Binding Items}"/>
<Setter Property="SelectedItem" Value="{Binding SelectedItem}"/>
</Style.Setters>
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,22 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<DataTemplate x:Key="MaterialSafetyFactors">
<DataGrid Style="{StaticResource ItemsDataGrid}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Take}" Value="false">
<Setter Property="Background" Value="LightGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridCheckBoxColumn Header="Take" Width="40" Binding="{Binding Take}"/>
<DataGridTextColumn Header="Name" Width="70" MinWidth="70" Binding="{Binding Name}"/>
<DataGridTextColumn Header="Description" Width="300" MinWidth="100" Binding="{Binding Description}"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</ResourceDictionary>

View File

@@ -178,6 +178,15 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Windows\Forces\InterpolateTuplesView.xaml.cs">
<DependentUpon>InterpolateTuplesView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow\Materials\PartialFactorsView.xaml.cs">
<DependentUpon>PartialFactorsView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow\Materials\SafetyFactorsView.xaml.cs">
<DependentUpon>SafetyFactorsView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\CalculationWindows\CalculationPropertyWindow\CalculationPropertyView.xaml.cs">
<DependentUpon>CalculationPropertyView.xaml</DependentUpon>
</Compile>
@@ -232,14 +241,27 @@
<Compile Include="Windows\PrimitivePropertiesWindow\PrimitivePropertiesView.xaml.cs">
<DependentUpon>PrimitivePropertiesView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\PrimitivePropertiesWindow\SelectPrimitivesView.xaml.cs">
<DependentUpon>SelectPrimitivesView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\PrimitiveTemplates\RCs\RectangleBeam\RectangleBeamView.xaml.cs">
<DependentUpon>RectangleBeamView.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ViewModels\Calculations\CalculationProperies\CalculationPropertyViewModel.cs" />
<Compile Include="Windows\ViewModels\Calculations\CalculationResult\CalculationResultViewModel.cs" />
<Compile Include="Windows\ViewModels\Calculations\Calculators\ForcesResultsViewModel.cs" />
<Compile Include="Windows\ViewModels\CRUDViewModelBase.cs" />
<Compile Include="Windows\ViewModels\Forces\ForceTuplesViewModel.cs" />
<Compile Include="Windows\ViewModels\Forces\InterpolateTuplesViewModel.cs" />
<Compile Include="Windows\ViewModels\Materials\ISafetyFactorViewModel.cs" />
<Compile Include="Windows\ViewModels\Materials\PartialFactorsViewModel.cs" />
<Compile Include="Windows\ViewModels\Materials\SafetyFactorsViewModel.cs" />
<Compile Include="Windows\ViewModels\Forces\ActionsViewModel.cs" />
<Compile Include="Windows\ViewModels\NdmCrossSections\IPrimitiveViewModelLogic.cs" />
<Compile Include="Windows\ViewModels\NdmCrossSections\PrimitiveViewModelLogic.cs" />
<Compile Include="Windows\ViewModels\OkCancelViewModelBase.cs" />
<Compile Include="Windows\ViewModels\PrimitiveProperties\SelectPrimitivesViewModel.cs" />
<Compile Include="Windows\ViewModels\SelectItemsViewModel.cs" />
<Compile Include="Windows\ViewModels\SourceToTargetViewModel.cs" />
<Compile Include="Windows\ViewModels\Calculations\Calculators\ForceCalculatorViewModel.cs" />
<Compile Include="Windows\ViewModels\Calculations\Calculators\ICombinationSourceToTargetViewModel.cs" />
@@ -273,10 +295,26 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Page Include="Infrastructure\UI\Resources\ButtonStyles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\Resources\CommonEnums.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\Resources\Converters.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\Resources\DataGridStyles.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\Resources\DataGridTemplates.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Infrastructure\UI\Resources\ItemEditPanels.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -305,6 +343,18 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\Forces\InterpolateTuplesView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow\Materials\PartialFactorsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\MainWindow\Materials\SafetyFactorsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\CalculationWindows\CalculationPropertyWindow\CalculationPropertyView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -361,6 +411,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\PrimitivePropertiesWindow\SelectPrimitivesView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\PrimitiveTemplates\RCs\RectangleBeam\RectangleBeamView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -395,6 +449,8 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Resource Include="Documentation\2021-06-14 10-46-38.JPG" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Enums
{
public enum StressStates
{
Tension,
Compression
}
}

View File

@@ -19,5 +19,6 @@ namespace StructureHelperCommon.Infrastructures.Strings
public static string FileCantBeDeleted => "#0008: File can't be deleted";
public static string FileCantBeSaved => "#0009: File can't be saved";
public static string VisualPropertyIsNotRight => "#0010: VisualPropertyIsNotRight";
public static string FactorMustBeGraterThanZero => "#0011: Partial factor must not be less than zero";
}
}

View File

@@ -0,0 +1,112 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public enum FactorType
{
LongTermFactor,
BleedingFactor,
PlainConcreteFactor
}
public static class ConcreteFactorsFactory
{
public static IMaterialSafetyFactor GetFactor(FactorType factorType)
{
if (factorType == FactorType.LongTermFactor) { return LongTerm(); }
else if (factorType == FactorType.BleedingFactor) { return Bleeding(); }
else if (factorType == FactorType.PlainConcreteFactor) { return PlainConcrete(); }
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
}
private static IMaterialSafetyFactor LongTerm()
{
IMaterialSafetyFactor safetyFactor = new MaterialSafetyFactor()
{
Name = "Gamma_b1",
Description = "Coefficient for considering long term calculations",
};
IMaterialPartialFactor partialFactor;
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Tension,
CalcTerm = CalcTerms.LongTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.9d
};
safetyFactor.PartialFactors.Add(partialFactor);
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Compression,
CalcTerm = CalcTerms.LongTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.9d
};
safetyFactor.PartialFactors.Add(partialFactor);
return safetyFactor;
}
private static IMaterialSafetyFactor Bleeding()
{
IMaterialSafetyFactor safetyFactor = new MaterialSafetyFactor()
{
Name = "Gamma_b3",
Description = "Coefficient for considering bleeding in vertical placement conditionals",
};
IMaterialPartialFactor partialFactor;
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Compression,
CalcTerm = CalcTerms.ShortTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.85d
};
safetyFactor.PartialFactors.Add(partialFactor);
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Compression,
CalcTerm = CalcTerms.LongTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.85d
};
safetyFactor.PartialFactors.Add(partialFactor);
return safetyFactor;
}
private static IMaterialSafetyFactor PlainConcrete()
{
IMaterialSafetyFactor safetyFactor = new MaterialSafetyFactor()
{
Name = "Gamma_b2",
Description = "Coefficient for plain concrete structures",
};
IMaterialPartialFactor partialFactor;
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Compression,
CalcTerm = CalcTerms.ShortTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.9d
};
safetyFactor.PartialFactors.Add(partialFactor);
partialFactor = new MaterialPartialFactor
{
StressState = StressStates.Compression,
CalcTerm = CalcTerms.LongTerm,
LimitState = LimitStates.ULS,
FactorValue = 0.9d
};
safetyFactor.PartialFactors.Add(partialFactor);
return safetyFactor;
}
}
}

View File

@@ -0,0 +1,16 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public interface IMaterialPartialFactor : IPartialFactor
{
StressStates StressState { get; set; }
CalcTerms CalcTerm { get; set; }
LimitStates LimitState { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public interface IMaterialSafetyFactor : ICloneable
{
string Name { get; set; }
bool Take { get; set; }
string Description { get; set; }
List<IMaterialPartialFactor> PartialFactors { get; }
double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates);
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public interface IPartialFactor : ICloneable
{
double FactorValue {get;set;}
}
}

View File

@@ -0,0 +1,52 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public class MaterialPartialFactor : IMaterialPartialFactor
{
private double factorValue;
public StressStates StressState { get; set; }
public CalcTerms CalcTerm { get; set; }
public LimitStates LimitState { get; set; }
public double FactorValue
{
get => factorValue;
set
{
if (value < 0 )
{
throw new StructureHelperException(ErrorStrings.FactorMustBeGraterThanZero);
}
factorValue = value;
}
}
public MaterialPartialFactor()
{
StressState = StressStates.Compression;
LimitState = LimitStates.ULS;
CalcTerm = CalcTerms.LongTerm;
FactorValue = 1d;
}
public object Clone()
{
var newItem = new MaterialPartialFactor()
{
StressState = StressState,
CalcTerm = CalcTerm,
LimitState = LimitState,
FactorValue = FactorValue,
};
return newItem;
}
}
}

View File

@@ -0,0 +1,46 @@
using StructureHelperCommon.Infrastructures.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Materials.Libraries
{
public class MaterialSafetyFactor : IMaterialSafetyFactor
{
public string Name {get; set; }
public bool Take { get; set; }
public string Description { get; set; }
public List<IMaterialPartialFactor> PartialFactors { get; }
public MaterialSafetyFactor()
{
Take = true;
Name = "New factor";
Description = "Material safety factor for ...";
PartialFactors = new List<IMaterialPartialFactor>();
}
public double GetFactor(StressStates stressState, CalcTerms calcTerm, LimitStates limitStates)
{
double result = 1d;
var coefficients = PartialFactors.Where(x => (x.StressState == stressState & x.CalcTerm == calcTerm & x.LimitState == limitStates));
foreach (var item in coefficients) { result *= item.FactorValue;}
return result;
}
public object Clone()
{
var newItem = new MaterialSafetyFactor();
newItem.Take = Take;
newItem.Name = Name;
newItem.Description = Description;
foreach (var item in PartialFactors)
{
newItem.PartialFactors.Add(item.Clone() as IMaterialPartialFactor);
}
return newItem;
}
}
}

View File

@@ -1,4 +1,6 @@
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
@@ -18,8 +20,9 @@ namespace StructureHelperCommon.Services.Forces
return newTuple;
}
public static IForceTuple InterpolateTuples(IForceTuple startTuple, IForceTuple endTuple, double coefficient)
public static IForceTuple InterpolateTuples(IForceTuple endTuple, IForceTuple startTuple = null, double coefficient = 0.5d)
{
if (startTuple == null) startTuple = new ForceTuple();
double dMx, dMy, dNz;
dMx = endTuple.Mx - startTuple.Mx;
dMy = endTuple.My - startTuple.My;
@@ -32,20 +35,17 @@ namespace StructureHelperCommon.Services.Forces
};
}
public static IForceTuple InterpolateTuples(IForceTuple endTuple, double coefficient)
{
IForceTuple startTuple = new ForceTuple();
return InterpolateTuples(startTuple, endTuple, coefficient);
}
public static List<IDesignForceTuple> InterpolateDesignTuple(IDesignForceTuple endTuple, int stepCount)
public static List<IDesignForceTuple> InterpolateDesignTuple(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce = null, int stepCount = 10)
{
if (startDesignForce.LimitState != finishDesignForce.LimitState) throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm) throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
var tuples =new List<IDesignForceTuple>();
double step = 1d / stepCount;
for (int i = 0; i <= stepCount; i++)
{
var currentTuple = InterpolateTuples(endTuple.ForceTuple, i * step);
var currentDesignTuple = new DesignForceTuple() { LimitState = endTuple.LimitState, CalcTerm = endTuple.CalcTerm, ForceTuple = currentTuple };
var currentTuple = InterpolateTuples(finishDesignForce.ForceTuple, startDesignForce.ForceTuple, i * step);
var currentDesignTuple = new DesignForceTuple() { LimitState = finishDesignForce.LimitState, CalcTerm = finishDesignForce.CalcTerm, ForceTuple = currentTuple };
tuples.Add(currentDesignTuple);
}
return tuples;

View File

@@ -49,6 +49,7 @@
<Compile Include="Infrastructures\Enums\CalcTerms.cs" />
<Compile Include="Infrastructures\Enums\CodeTypes.cs" />
<Compile Include="Infrastructures\Enums\LimitStates.cs" />
<Compile Include="Infrastructures\Enums\StressStates.cs" />
<Compile Include="Infrastructures\Enums\UnitTypes.cs" />
<Compile Include="Infrastructures\Exceptions\StructureHelperException.cs" />
<Compile Include="Infrastructures\Interfaces\IHasForceCombinations.cs" />
@@ -68,11 +69,17 @@
<Compile Include="Models\Forces\IForceRepository.cs" />
<Compile Include="Models\Forces\IForceTuple.cs" />
<Compile Include="Models\Materials\Libraries\ConcreteMaterialEntity.cs" />
<Compile Include="Models\Materials\Libraries\Factories\ConcreteFactorsFactory.cs" />
<Compile Include="Models\Materials\Libraries\Factories\LibMaterialFactory.cs" />
<Compile Include="Models\Materials\Libraries\IConcreteMaterialEntity.cs" />
<Compile Include="Models\Materials\Libraries\ILibMaterialEntity.cs" />
<Compile Include="Models\Materials\Libraries\IMaterialPartialFactor.cs" />
<Compile Include="Models\Materials\Libraries\IMaterialSafetyFactor.cs" />
<Compile Include="Models\Materials\Libraries\IPartialFactor.cs" />
<Compile Include="Models\Materials\Libraries\IReinforcementMaterialEntity.cs" />
<Compile Include="Models\Materials\Libraries\LibMaterialPepository.cs" />
<Compile Include="Models\Materials\Libraries\MaterialPartialFactor.cs" />
<Compile Include="Models\Materials\Libraries\MaterialSafetyFactor.cs" />
<Compile Include="Models\Materials\Libraries\ReinforcementMaterialEntity.cs" />
<Compile Include="Models\Shapes\Point2D.cs" />
<Compile Include="Models\Shapes\IPoint2D.cs" />

View File

@@ -9,12 +9,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StructureHelperCommon.Infrastructures.Settings;
namespace StructureHelperLogics.Models.Materials
{
public class ConcreteLibMaterial : IConcreteLibMaterial
{
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; }
public bool TensionForULS { get ; set; }
public bool TensionForSLS { get; set; }
@@ -22,6 +24,8 @@ namespace StructureHelperLogics.Models.Materials
public ConcreteLibMaterial()
{
SafetyFactors = new List<IMaterialSafetyFactor>();
SafetyFactors.AddRange(PartialCoefficientFactory.GetDefaultConcreteSafetyFactors(ProgramSetting.CodeType));
optionLogic = new MaterialOptionLogic(new LCMB.ConcreteOptions());
}
@@ -33,6 +37,15 @@ namespace StructureHelperLogics.Models.Materials
public LCM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
var materialOptions = optionLogic.SetMaterialOptions(MaterialEntity, limitState, calcTerm);
double compressionVal = 1d;
double tensionVal = 1d;
foreach (var item in SafetyFactors.Where(x => x.Take == true))
{
compressionVal *= item.GetFactor(StressStates.Compression, calcTerm, limitState);
tensionVal *= item.GetFactor(StressStates.Tension, calcTerm, limitState);
}
materialOptions.ExternalFactor.Compressive = compressionVal;
materialOptions.ExternalFactor.Tensile = tensionVal;
LCMB.IMaterialBuilder builder = new LCMB.ConcreteBuilder(materialOptions);
LCMB.IBuilderDirector director = new LCMB.BuilderDirector(builder);
return director.BuildMaterial();

View File

@@ -0,0 +1,44 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperLogics.Models.Materials
{
public static class PartialCoefficientFactory
{
public static List<IMaterialSafetyFactor> GetDefaultConcreteSafetyFactors(CodeTypes codeType)
{
if (codeType == CodeTypes.SP63_13330_2018) return GetConcreteFactorsSP63_2018();
else if (codeType == CodeTypes.EuroCode_2_1990) return GetConcreteFactorsEC2_1990();
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + ": " + codeType);
}
private static List<IMaterialSafetyFactor> GetConcreteFactorsEC2_1990()
{
List<IMaterialSafetyFactor> factors = new List<IMaterialSafetyFactor>();
return factors;
}
private static List<IMaterialSafetyFactor> GetConcreteFactorsSP63_2018()
{
List<IMaterialSafetyFactor> factors = new List<IMaterialSafetyFactor>();
IMaterialSafetyFactor coefficient;
coefficient = ConcreteFactorsFactory.GetFactor(FactorType.LongTermFactor);
coefficient.Take = true;
factors.Add(coefficient);
coefficient = ConcreteFactorsFactory.GetFactor(FactorType.PlainConcreteFactor);
coefficient.Take = false;
factors.Add(coefficient);
coefficient = ConcreteFactorsFactory.GetFactor(FactorType.BleedingFactor);
coefficient.Take = false;
factors.Add(coefficient);
return factors;
}
}
}

View File

@@ -10,5 +10,6 @@ namespace StructureHelperLogics.Models.Materials
public interface ILibMaterial : IHelperMaterial
{
ILibMaterialEntity MaterialEntity { get; set; }
List<IMaterialSafetyFactor> SafetyFactors { get; }
}
}

View File

@@ -2,6 +2,7 @@
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Materials.Libraries;
using System.Collections.Generic;
using LCM = LoaderCalculator.Data.Materials;
using LCMB = LoaderCalculator.Data.Materials.MaterialBuilders;
@@ -18,7 +19,10 @@ namespace StructureHelperLogics.Models.Materials
private CalcTerms calcTerm;
public string Name { get; set; }
public double MainStrength { get; set; }
public ILibMaterialEntity MaterialEntity { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; }
public LibMaterial(MaterialTypes materialType, CodeTypes codeType, string name, double mainStrength)
{

View File

@@ -13,11 +13,13 @@ namespace StructureHelperLogics.Models.Materials
public class ReinforcementLibMaterial : IReinforcementLibMaterial
{
public ILibMaterialEntity MaterialEntity { get; set; }
public List<IMaterialSafetyFactor> SafetyFactors { get; }
private IMaterialOptionLogic optionLogic;
public ReinforcementLibMaterial()
{
SafetyFactors = new List<IMaterialSafetyFactor>();
optionLogic = new MaterialOptionLogic(new LCMB.ReinforcementOptions());
}
@@ -29,6 +31,15 @@ namespace StructureHelperLogics.Models.Materials
public LCM.IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
{
var materialOptions = optionLogic.SetMaterialOptions(MaterialEntity, limitState, calcTerm);
double compressionVal = 1d;
double tensionVal = 1d;
foreach (var item in SafetyFactors.Where(x => x.Take == true))
{
compressionVal *= item.GetFactor(StressStates.Compression, calcTerm, limitState);
tensionVal *= item.GetFactor(StressStates.Tension, calcTerm, limitState);
}
materialOptions.ExternalFactor.Compressive = compressionVal;
materialOptions.ExternalFactor.Tensile = tensionVal;
LCMB.IMaterialBuilder builder = new LCMB.ReinforcementBuilder(materialOptions);
LCMB.IBuilderDirector director = new LCMB.BuilderDirector(builder);
return director.BuildMaterial();

View File

@@ -1,5 +1,6 @@
using StructureHelper.Models.Materials;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials.Libraries;
using StructureHelperLogics.Models.Materials;
using System;
using System.Collections.Generic;

View File

@@ -39,6 +39,7 @@ namespace StructureHelperLogics.NdmCalculations.Primitives
NdmMaxSize = 0.01d;
NdmMinDivision = 10;
VisualProperty = new VisualProperty();
VisualProperty.Opacity = 0.8;
}
public RectanglePrimitive(IHeadMaterial material) : this() { HeadMaterial = material; }

View File

@@ -12,13 +12,13 @@ namespace StructureHelperLogics.Services.NdmCalculations
{
public static class InterpolateService
{
public static IForceCalculator InterpolateForceCalculator(IForceCalculator source, IDesignForceTuple sourceTuple, int stepCount)
public static IForceCalculator InterpolateForceCalculator(IForceCalculator source, IDesignForceTuple finishDesignForce,IDesignForceTuple startDesignForce, int stepCount)
{
IForceCalculator calculator = new ForceCalculator();
calculator.LimitStatesList.Clear();
calculator.LimitStatesList.Add(sourceTuple.LimitState);
calculator.LimitStatesList.Add(finishDesignForce.LimitState);
calculator.CalcTermsList.Clear();
calculator.CalcTermsList.Add(sourceTuple.CalcTerm);
calculator.CalcTermsList.Add(finishDesignForce.CalcTerm);
calculator.IterationAccuracy = source.IterationAccuracy;
calculator.MaxIterationCount = source.MaxIterationCount;
calculator.Primitives.AddRange(source.Primitives);
@@ -29,7 +29,7 @@ namespace StructureHelperLogics.Services.NdmCalculations
SetInGravityCenter = false
};
combination.DesignForces.Clear();
combination.DesignForces.AddRange(TupleService.InterpolateDesignTuple(sourceTuple, stepCount));
combination.DesignForces.AddRange(TupleService.InterpolateDesignTuple(finishDesignForce, startDesignForce, stepCount));
combination.ForcePoint.X = 0;
combination.ForcePoint.Y = 0;
calculator.ForceCombinationLists.Add(combination);

View File

@@ -0,0 +1,53 @@
using LoaderCalculator.Tests.Infrastructures.Logics;
using NUnit.Framework;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
namespace StructureHelperTests.FunctionalTests.Ndms.Calculators.ForceCalculatorTests
{
public class RCSectionsTest
{
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, -0.00062544561815463693d, -0.0029292919541166911d, 0.00035383082501577246d)]
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 3, 2, -0.00046762265275279838d, -0.0025101896869558888d, 0.00027185795017719519d)]
[TestCase(0.5d, 0.5d, 0.025d, 0.025d, 3, 3, -0.00080914991212906239d, -0.00080914991212906184d, 0.00011900072665826425d)]
public void Run_SouldPass(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, double expectedKx, double expectedKy, double expectedEpsZ)
{
//Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount};
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0];
//Act
calculator.Run();
var result = calculator.Result as IForcesResults;
//Assert
Assert.IsNotNull(result);
Assert.IsTrue(result.IsValid);
var strainMatrix = result.ForcesResultList[0].LoaderResults.StrainMatrix;
var kx = strainMatrix.Kx;
var ky = strainMatrix.Ky;
var epsz = strainMatrix.EpsZ;
Assert.AreEqual(expectedKx, kx, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKx));
Assert.AreEqual(expectedKy, ky, ExpectedProcessor.GetAccuracyForExpectedValue(expectedKy));
Assert.AreEqual(expectedEpsZ, epsz, ExpectedProcessor.GetAccuracyForExpectedValue(expectedEpsZ));
}
[TestCase(0.4d, 0.6d, 0.012d, 0.025d, 2, 2, true, true)]
[TestCase(1d, 0.2d, 0.012d, 0.012d, 5, 2, true, false)]
[TestCase(1d, 0.2d, 0.012d, 0.025d, 5, 2, true, true)]
public void Run_SouldPass_Result_IsNotValid(double width, double height, double topDiametr, double bottomDiametr, int widthCount, int heightCount, bool calcResult, bool firstForceResult)
{
//Arrange
var template = new RectangleBeamTemplate(width, height) { TopDiameter = topDiametr, BottomDiameter = bottomDiametr, WidthCount = widthCount, HeightCount = heightCount };
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var calculator = newSection.SectionRepository.CalculatorsList[0];
//Act
calculator.Run();
var result = calculator.Result as IForcesResults;
//Assert
Assert.IsNotNull(result);
Assert.True(calcResult == result.IsValid);
Assert.True(firstForceResult == result.ForcesResultList[0].IsValid);
}
}
}

View File

@@ -42,6 +42,7 @@
<ItemGroup>
<Compile Include="FieldsVisualizerTests\ColorOperationTests\GetColorByValueTest.cs" />
<Compile Include="FieldsVisualizerTests\WindowTests\ViewerTest.cs" />
<Compile Include="FunctionalTests\Ndms\Calculators\ForceCalculatorTests\RCSectionsTest.cs" />
<Compile Include="FunctionalTests\Ndms\RCSections\RCSectionTest.cs" />
<Compile Include="FunctionalTests\Ndms\SteelSections\ReinforcementTest.cs" />
<Compile Include="Infrastructures\Logics\ExpectedProcessor.cs" />

View File

@@ -21,7 +21,7 @@ namespace StructureHelperTests.ViewModelTests
public class NdmPrimitiveTests
{
[Test]
public void Run_ShouldPass()
public void Rectangle_Run_ShouldPass()
{
//Arrange
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018);
@@ -32,5 +32,18 @@ namespace StructureHelperTests.ViewModelTests
//Assert
Assert.NotNull(vm);
}
[Test]
public void Point_Run_ShouldPass()
{
//Arrange
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Concrete40, CodeTypes.SP63_13330_2018);
var primitive = new PointPrimitive(material);
var primitiveBase = new PointViewPrimitive(primitive);
//Act
var vm = new PrimitivePropertiesViewModel(primitiveBase, new CrossSectionRepository());
//Assert
Assert.NotNull(vm);
}
}
}

View File

@@ -7,43 +7,58 @@
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Forces"
d:DataContext="{d:DesignInstance vm:ForceCombinationViewModel}"
mc:Ignorable="d"
Title="Force Combination" Height="250" Width="450" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
Title="Force Combination" Height="250" Width="550" MinHeight="300" MinWidth="450" MaxWidth="500" WindowStartupLocation="CenterScreen">
<Window.Resources>
<DataTemplate x:Key="ForceTemplate">
</DataTemplate>
</Window.Resources>
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<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 Width="200"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition/>
<ColumnDefinition Width="80"/>
</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}"/>
<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>
<DataGrid x:Name="ForceGrid" AutoGenerateColumns="False"
ItemsSource="{Binding ForceTuples}"
SelectedItem="{Binding SelectedTuple}">
<DataGrid.Columns>
<DataGridTextColumn Header="Limit State" Width="90" Binding="{Binding LimitState}" IsReadOnly="True"/>
<DataGridTextColumn Header="Duration" Width="90" Binding="{Binding CalcTerm}" IsReadOnly="True"/>
<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Moment My" Width="90" Binding="{Binding ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<DataGridTextColumn Header="Force Nz" Width="90" Binding="{Binding ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,49 @@
<Window x:Class="StructureHelper.Windows.Forces.InterpolateTuplesView"
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:InterpolateTuplesViewModel}"
mc:Ignorable="d"
Title="Interpolate Combinations" Height="200" Width="350" MinHeight="180" MinWidth="250" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Text="Moment Mx" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="2" Text="Moment My" HorizontalAlignment="Center"/>
<TextBlock Grid.Column="3" Text="Force Nz" HorizontalAlignment="Center"/>
<TextBlock Grid.Row="1" Text="Start Combination"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding StartDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding StartDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding StartDesignForce.ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Finish Combination"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding FinishDesignForce.ForceTuple.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding FinishDesignForce.ForceTuple.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding FinishDesignForce.ForceTuple.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="3" Text="Step count"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding StepCount, ValidatesOnExceptions=True}"/>
</Grid>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,37 @@
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.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace StructureHelper.Windows.Forces
{
/// <summary>
/// Логика взаимодействия для InterpolateTuplesView.xaml
/// </summary>
public partial class InterpolateTuplesView : Window
{
public InterpolateTuplesView(InterpolateTuplesViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
Close();
}
}
}

View File

@@ -11,6 +11,7 @@ using StructureHelper.Windows.MainWindow.Materials;
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
using StructureHelper.Windows.ViewModels.Calculations.CalculationResult;
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelper.Windows.ViewModels.NdmCrossSections;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
@@ -45,7 +46,7 @@ namespace StructureHelper.Windows.MainWindow
private readonly ICalculatorsViewModelLogic calculatorsLogic;
public ICalculatorsViewModelLogic CalculatorsLogic { get => calculatorsLogic;}
public IForceCombinationViewModelLogic CombinationsLogic { get => combinationsLogic; }
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
public IPrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
private MainModel Model { get; }
@@ -171,14 +172,14 @@ namespace StructureHelper.Windows.MainWindow
private double delta = 0.0005;
private double axisLineThickness;
private double gridLineThickness;
private IForceCombinationViewModelLogic combinationsLogic;
private ActionsViewModel combinationsLogic;
private IPrimitiveViewModelLogic primitiveLogic;
public MainViewModel(MainModel model)
{
Model = model;
section = model.Section;
combinationsLogic = new ForceCombinationViewModelLogic(repository);
combinationsLogic = new ActionsViewModel(repository);
calculatorsLogic = new CalculatorsViewModelLogic(repository);
CanvasWidth = 2d * scale;
CanvasHeight = 1.5d * scale;

View File

@@ -9,28 +9,40 @@
mc:Ignorable="d"
Title="Materials" Height="350" Width="680" MinHeight="350" MinWidth="680" WindowStartupLocation="CenterScreen">
<Window.Resources>
<DataTemplate x:Key="SafetyFactors">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="200"/>
</Grid.RowDefinitions>
<Button Content="Show Safety Factors" Command="{Binding DataContext.ShowSafetyFactors, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}"/>
<ContentControl Grid.Row="1" ContentTemplate="{StaticResource MaterialSafetyFactors}" Content="{Binding DataContext, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=Window}}"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="ConcreteLibMaterial">
<StackPanel>
<TextBlock Text="Library material"/>
<ComboBox Grid.Row="2" Height="25" VerticalAlignment="Top" ItemsSource="{Binding LibConcreteMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox Height="25" VerticalAlignment="Top" ItemsSource="{Binding LibConcreteMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ContentControl ContentTemplate="{StaticResource SafetyFactors}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ReinforcementLibMaterial">
<StackPanel>
<TextBlock Text="Library material"/>
<ComboBox Grid.Row="2" Height="25" VerticalAlignment="Top" ItemsSource="{Binding LibReinforcementMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox Height="25" VerticalAlignment="Top" ItemsSource="{Binding LibReinforcementMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ContentControl ContentTemplate="{StaticResource SafetyFactors}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ElasticMaterial">

View File

@@ -0,0 +1,42 @@
<Window x:Class="StructureHelper.Windows.MainWindow.Materials.PartialFactorsView"
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.MainWindow.Materials"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Materials"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:PartialFactorsViewModel}"
Title="Material Partial Factors" Height="350" Width="500" WindowStartupLocation="CenterScreen">
<Window.Resources>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<DataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False" SelectedItem="{Binding SelectedItem}">
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Take}" Value="false">
<Setter Property="Background" Value="LightGray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Stress state" Width="90" MinWidth="70" SelectedItemBinding="{Binding StressState}" ItemsSource="{Binding Source={StaticResource StressStateEnum}}"/>
<DataGridComboBoxColumn Header="Limit state" Width="90" MinWidth="70" SelectedItemBinding="{Binding LimitState}" ItemsSource="{Binding Source={StaticResource LimitStateEnum}}"/>
<DataGridComboBoxColumn Header="Duration" Width="90" MinWidth="70" SelectedItemBinding="{Binding CalcTerm}" ItemsSource="{Binding Source={StaticResource CalcTermEnum}}"/>
<DataGridTextColumn Header="Value" Width="70" MinWidth="70" Binding="{Binding FactorValue, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Column="1">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,31 @@
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
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.MainWindow.Materials
{
/// <summary>
/// Логика взаимодействия для PartialFactorsView.xaml
/// </summary>
public partial class PartialFactorsView : Window
{
public PartialFactorsView(List<IMaterialPartialFactor> factors)
{
InitializeComponent();
var vm = new PartialFactorsViewModel(factors);
this.DataContext = vm;
}
}
}

View File

@@ -0,0 +1,24 @@
<Window x:Class="StructureHelper.Windows.AddMaterialWindow.SafetyFactorsView"
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.MainWindow.Materials"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Materials"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:SafetyFactorsViewModel}"
Title="Material Safety Factors" Height="350" Width="500" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<ContentControl ContentTemplate="{StaticResource MaterialSafetyFactors}" Content="{Binding}"/>
<StackPanel Grid.Column="1">
<Button Style="{StaticResource AddButton}"/>
<Button Style="{StaticResource DeleteButton}"/>
<Button Style="{StaticResource CopyButton}"/>
<Button Style="{StaticResource CommandButton}" Content="Partial frs" Command="{Binding ShowPartialFactors}"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,31 @@
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
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.AddMaterialWindow
{
/// <summary>
/// Логика взаимодействия для SafetyFactorsView.xaml
/// </summary>
public partial class SafetyFactorsView : Window
{
public SafetyFactorsView(List<IMaterialSafetyFactor> safetyFactors)
{
InitializeComponent();
var vm = new SafetyFactorsViewModel(safetyFactors);
this.DataContext = vm;
}
}
}

View File

@@ -0,0 +1,35 @@
<Window x:Class="StructureHelper.Windows.PrimitivePropertiesWindow.SelectPrimitivesView"
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.PrimitivePropertiesWindow"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.PrimitiveProperties"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vm:SelectPrimitivesViewModel}"
Title="Select Primitives" Height="250" Width="250" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding Items.CollectionItems}" SelectedItem="Items.SelectedItem">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="22"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding IsSelected}"/>
<ContentControl Grid.Column="1" ContentTemplate="{StaticResource ColoredItemTemplate}" Content="{Binding Item}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Style="{StaticResource CancelButton}"/>
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,35 @@
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
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.PrimitivePropertiesWindow
{
/// <summary>
/// Логика взаимодействия для SelectPrimitivesView.xaml
/// </summary>
public partial class SelectPrimitivesView : Window
{
public SelectPrimitivesView(SelectPrimitivesViewModel vm)
{
InitializeComponent();
DataContext = vm;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
this.Close();
}
}
}

View File

@@ -0,0 +1,126 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
namespace StructureHelper.Windows.ViewModels
{
public abstract class CRUDViewModelBase<TItem> : ViewModelBase, ICRUDViewModel<TItem> where TItem : class
{
private RelayCommand addCommand;
private RelayCommand deleteCommand;
private RelayCommand copyCommand;
private RelayCommand editCommand;
public List<TItem> Collection { get; set; }
public TItem NewItem { get; set; }
public TItem SelectedItem { get; set; }
public ObservableCollection<TItem> Items { get; private set; }
public RelayCommand Add
{
get
{
return addCommand ??
(
addCommand = new RelayCommand(o =>
{
AddMethod(o);
}
));
}
}
public virtual void AddMethod(object parameter)
{
Collection.Add(NewItem);
Items.Add(NewItem);
}
public RelayCommand Delete
{
get
{
return deleteCommand ??
(
deleteCommand = new RelayCommand(o =>
{
DeleteMethod();
}, o => SelectedItem != null
));
}
}
public virtual void DeleteMethod()
{
Collection.Remove(SelectedItem);
Items.Remove(SelectedItem);
}
public RelayCommand Edit
{
get
{
return editCommand ??
(editCommand = new RelayCommand(o=>
{
EditMethod(o);
}, o => SelectedItem != null
));
}
}
public virtual void EditMethod(object parameter)
{
Items.Clear();
foreach (var item in Collection)
{
Items.Add(item);
}
OnPropertyChanged(nameof(Items));
}
public RelayCommand Copy
{
get
{
return copyCommand ??
(copyCommand = new RelayCommand (o=>
{
CopyMethod();
}, o => SelectedItem != null
));
}
}
public virtual void CopyMethod()
{
if (SelectedItem is ICloneable)
{
NewItem = (SelectedItem as ICloneable).Clone() as TItem;
}
Collection.Add(NewItem);
Items.Add(NewItem);
}
public void AddItems(IEnumerable<TItem> items)
{
foreach (var item in items)
{
Items.Add(item);
}
}
public CRUDViewModelBase()
{
Items = new ObservableCollection<TItem>();
}
public CRUDViewModelBase(List<TItem> collection)
{
Collection = collection;
Items = new ObservableCollection<TItem>(collection);
}
}
}

View File

@@ -7,8 +7,13 @@ using StructureHelper.Services.Reports;
using StructureHelper.Services.Reports.CalculationReports;
using StructureHelper.Services.ResultViewers;
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
using StructureHelper.Windows.Forces;
using StructureHelper.Windows.PrimitivePropertiesWindow;
using StructureHelper.Windows.ViewModels.Forces;
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.NdmCalculations.Analyses;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using StructureHelperLogics.NdmCalculations.Primitives;
@@ -30,6 +35,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
private IForceCalculator forceCalculator;
private IForcesResults forcesResults;
private IEnumerable<INdmPrimitive> ndmPrimitives;
private IEnumerable<INdmPrimitive> selectedNdmPrimitives;
private IEnumerable<INdm> ndms;
private IReport isoFieldReport;
@@ -50,8 +56,15 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
return showIsoFieldCommand ??
(showIsoFieldCommand = new RelayCommand(o =>
{
GetNdms();
ShowIsoField();
var vm = new SelectPrimitivesViewModel(ndmPrimitives);
var wnd = new SelectPrimitivesView(vm);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
GetNdms();
ShowIsoField();
}
}, o => (SelectedResult != null) && SelectedResult.IsValid));
}
}
@@ -73,7 +86,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "csv |*.csv";
saveFileDialog.Title = "Save an Image File";
saveFileDialog.Title = "Save an csv File";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var filename = saveFileDialog.FileName;
@@ -119,8 +132,16 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
private void Interpolate()
{
int stepCount = 100;
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, SelectedResult.DesignForceTuple, stepCount);
IDesignForceTuple startDesignTuple, finishDesignTuple;
finishDesignTuple = SelectedResult.DesignForceTuple.Clone() as IDesignForceTuple;
var viewModel = new InterpolateTuplesViewModel(finishDesignTuple, null, 100);
var wndTuples = new InterpolateTuplesView(viewModel);
wndTuples.ShowDialog();
if (wndTuples.DialogResult != true) return;
startDesignTuple = viewModel.StartDesignForce;
finishDesignTuple = viewModel.FinishDesignForce;
int stepCount = viewModel.StepCount;
var calculator = InterpolateService.InterpolateForceCalculator(forceCalculator, finishDesignTuple, startDesignTuple, stepCount);
calculator.Run();
var result = calculator.Result;
if (result is null || result.IsValid == false)
@@ -154,7 +175,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
{
var limitState = SelectedResult.DesignForceTuple.LimitState;
var calcTerm = SelectedResult.DesignForceTuple.CalcTerm;
ndms = NdmPrimitivesService.GetNdms(ndmPrimitives, limitState, calcTerm);
ndms = NdmPrimitivesService.GetNdms(selectedNdmPrimitives, limitState, calcTerm);
}
}
}

View File

@@ -0,0 +1,60 @@
using StructureHelper.Windows.Forces;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StructureHelper.Windows.ViewModels.Forces
{
public class ActionsViewModel : CRUDViewModelBase<IForceCombinationList>
{
ICrossSectionRepository repository;
public override void AddMethod(object parameter)
{
NewItem = new ForceCombinationList() { Name = "New Force Combination" };
base.AddMethod(parameter);
}
public override void DeleteMethod()
{
var dialogResult = MessageBox.Show("Delete action?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dialogResult == DialogResult.Yes)
{
var calcRepository = repository.CalculatorsList;
foreach (var item in calcRepository)
{
if (item is IForceCalculator)
{
var forceCalculator = item as IForceCalculator;
var containSelected = forceCalculator.ForceCombinationLists.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); }
else return;
}
}
}
base.DeleteMethod();
}
}
public override void EditMethod(object parameter)
{
var wnd = new ForceCombinationView(SelectedItem);
wnd.ShowDialog();
base.EditMethod(parameter);
}
public ActionsViewModel(ICrossSectionRepository repository) : base (repository.ForceCombinationLists)
{
this.repository = repository;
}
}
}

View File

@@ -12,7 +12,9 @@ namespace StructureHelper.Windows.ViewModels.Forces
{
IForceCombinationList combinationList;
public IDesignForceTuple SelectedTuple { get; set; }
//public IDesignForceTuple SelectedTuple { get; set; }
public ForceTuplesViewModel DesignForces { get;}
public string Name
{
get => combinationList.Name;
@@ -55,11 +57,12 @@ namespace StructureHelper.Windows.ViewModels.Forces
}
}
public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
//public IEnumerable<IDesignForceTuple> ForceTuples { get => combinationList.DesignForces; }
public ForceCombinationViewModel(IForceCombinationList combinationList)
{
this.combinationList = combinationList;
DesignForces = new ForceTuplesViewModel(this.combinationList.DesignForces);
}
}
}

View File

@@ -0,0 +1,25 @@
using StructureHelper.Properties;
using StructureHelperCommon.Infrastructures.Enums;
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 ForceTuplesViewModel : CRUDViewModelBase<IDesignForceTuple>
{
public override void AddMethod(object parameter)
{
NewItem = new DesignForceTuple() { LimitState=LimitStates.ULS, CalcTerm=CalcTerms.ShortTerm};
base.AddMethod(parameter);
}
public ForceTuplesViewModel(List<IDesignForceTuple> collection) : base(collection)
{
}
}
}

View File

@@ -0,0 +1,40 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
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 InterpolateTuplesViewModel : OkCancelViewModelBase
{
public IDesignForceTuple StartDesignForce { get; }
public IDesignForceTuple FinishDesignForce { get; }
public int StepCount { get; set; }
public InterpolateTuplesViewModel(IDesignForceTuple finishDesignForce, IDesignForceTuple startDesignForce=null, int stepCount = 100)
{
if (startDesignForce !=null)
{
if (startDesignForce.LimitState != finishDesignForce.LimitState) throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid);
if (startDesignForce.CalcTerm != finishDesignForce.CalcTerm) throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid);
StartDesignForce = startDesignForce;
}
else
{
StartDesignForce = new DesignForceTuple()
{
CalcTerm = finishDesignForce.CalcTerm,
LimitState = finishDesignForce.LimitState,
ForceTuple = new ForceTuple() { Mx = 0, My = 0, Nz = 0 },
};
}
FinishDesignForce = finishDesignForce;
StepCount = stepCount;
}
}
}

View File

@@ -1,6 +1,7 @@
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
using StructureHelper.Services.Primitives;
using StructureHelper.Windows.AddMaterialWindow;
using StructureHelper.Windows.MainWindow;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
@@ -56,6 +57,29 @@ namespace StructureHelper.Windows.ViewModels.Materials
public ICommand DeleteMaterialCommand { get; set; }
public ICommand EditHeadMaterial;
private RelayCommand showSafetyfactors;
public RelayCommand ShowSafetyFactors
{
get
{
return showSafetyfactors ??
(
showSafetyfactors = new RelayCommand(o =>
{
if (selectedMaterial.HelperMaterial is ILibMaterial)
{
var material = selectedMaterial.HelperMaterial as ILibMaterial;
var wnd = new SafetyFactorsView(material.SafetyFactors);
wnd.ShowDialog();
OnPropertyChanged(nameof(Items));
}
}, o=> SelectedLibMaterial != null
));
}
}
private ICommand addElasticMaterialCommand;
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
@@ -74,6 +98,19 @@ namespace StructureHelper.Windows.ViewModels.Materials
}
}
public ObservableCollection<IMaterialSafetyFactor> Items
{
get
{
if (selectedMaterial.HelperMaterial is ILibMaterial)
{
var material = selectedMaterial.HelperMaterial as ILibMaterial;
return new ObservableCollection<IMaterialSafetyFactor>(material.SafetyFactors);
}
else return null;
}
}
public string SelectedName
{
get => selectedMaterial.Name;

View File

@@ -0,0 +1,15 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal interface ISafetyFactorViewModel<TItem> : ICRUDViewModel<TItem>
{
RelayCommand ShowPartialFactors { get; }
}
}

View File

@@ -0,0 +1,22 @@
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class PartialFactorsViewModel : CRUDViewModelBase<IMaterialPartialFactor>
{
public override void AddMethod(object parameter)
{
NewItem = new MaterialPartialFactor();
base.AddMethod(parameter);
}
public PartialFactorsViewModel(List<IMaterialPartialFactor> safetyFactors) : base(safetyFactors)
{
}
}
}

View File

@@ -0,0 +1,41 @@
using StructureHelper.Infrastructure;
using StructureHelper.Windows.MainWindow.Materials;
using StructureHelperCommon.Models.Materials.Libraries;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels.Materials
{
internal class SafetyFactorsViewModel : CRUDViewModelBase<IMaterialSafetyFactor>
{
private RelayCommand showPartialCommand;
public RelayCommand ShowPartialFactors
{
get
{
return showPartialCommand ??
(showPartialCommand = new RelayCommand(o =>
{
var wnd = new PartialFactorsView(SelectedItem.PartialFactors);
wnd.ShowDialog();
}, o => SelectedItem != null
));
}
}
public override void AddMethod(object parameter)
{
NewItem = new MaterialSafetyFactor();
base.AddMethod(parameter);
}
public SafetyFactorsViewModel(List<IMaterialSafetyFactor> safetyFactors) : base(safetyFactors)
{
}
}
}

View File

@@ -0,0 +1,17 @@
using StructureHelper.Infrastructure;
using StructureHelperCommon.Infrastructures.Exceptions;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelper.Windows.ViewModels
{
public abstract class OkCancelViewModelBase : ViewModelBase
{
}
}

View File

@@ -0,0 +1,23 @@
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelperLogics.NdmCalculations.Primitives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
{
public class SelectPrimitivesViewModel
{
public SelectItemsViewModel<PrimitiveBase> Items { get; }
public SelectPrimitivesViewModel(IEnumerable<INdmPrimitive> primitives)
{
var primitiveViews = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(primitives);
Items = new SelectItemsViewModel<PrimitiveBase>(primitiveViews);
Items.ItemDataDemplate = Application.Current.Resources["ColoredItemTemplate"] as DataTemplate;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace StructureHelper.Windows.ViewModels
{
public class SelectItemsViewModel<TItem>
where TItem : class
{
public class CollectionItem
{
public bool IsSelected { get; set; }
public TItem Item { get; set; }
}
public DataTemplate ItemDataDemplate { get; set; }
public ObservableCollection<CollectionItem> CollectionItems { get; }
public SelectItemsViewModel(IEnumerable<TItem> items)
{
CollectionItems = new ObservableCollection<CollectionItem>();
foreach (var item in items)
{
CollectionItems.Add(new CollectionItem() { IsSelected = true, Item = item });
}
}
}
}