Templates was added
This commit is contained in:
1
App.xaml
1
App.xaml
@@ -6,6 +6,7 @@
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Infrastructure/UI/Styles.xaml"/>
|
||||
<ResourceDictionary Source="Infrastructure/UI/Resources/ShapeEditTemplates.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -5,6 +5,7 @@ using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Services;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
|
||||
namespace StructureHelper
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.PrimitiveTemplates
|
||||
{
|
||||
public interface IRectangleBeamProperties
|
||||
{
|
||||
IShape Shape { get; }
|
||||
}
|
||||
}
|
||||
41
Infrastructure/UI/PrimitiveTemplates/TemplateFactory.cs
Normal file
41
Infrastructure/UI/PrimitiveTemplates/TemplateFactory.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Shapes = StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.PrimitiveTemplates
|
||||
{
|
||||
internal static class TemplateFactory
|
||||
{
|
||||
//public static IEnumerable<PrimitiveBase> RectangleBeam(IRectangleBeamTemplate properties)
|
||||
//{
|
||||
// var rect = properties.Shape as Shapes.Rectangle;
|
||||
// var width = rect.Width;
|
||||
// var height = rect.Height;
|
||||
// var area1 = Math.PI * properties.BottomDiameter * properties.BottomDiameter / 4d;
|
||||
// var area2 = Math.PI * properties.TopDiameter * properties.TopDiameter / 4d;
|
||||
// var gap = properties.CoverGap;
|
||||
|
||||
//IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete 40" };
|
||||
//concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
|
||||
//IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement 400" };
|
||||
//reinforcement.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Reinforcement & x.Name.Contains("400"))).First();
|
||||
//headMaterials.Add(concrete);
|
||||
//headMaterials.Add(reinforcement);
|
||||
//OnPropertyChanged(nameof(headMaterials));
|
||||
|
||||
//yield return new Rectangle(width, height, 0, 0, this) { HeadMaterial = concrete };
|
||||
//yield return new Point(area1, -width / 2 + gap, -height / 2 + gap, this) { HeadMaterial = reinforcement };
|
||||
//yield return new Point(area1, width / 2 - gap, -height / 2 + gap, this) { HeadMaterial = reinforcement };
|
||||
//yield return new Point(area2, -width / 2 + gap, height / 2 - gap, this) { HeadMaterial = reinforcement };
|
||||
//yield return new Point(area2, width / 2 - gap, height / 2 - gap, this) { HeadMaterial = reinforcement };
|
||||
//}
|
||||
}
|
||||
}
|
||||
21
Infrastructure/UI/Resources/ShapeEditTemplates.xaml
Normal file
21
Infrastructure/UI/Resources/ShapeEditTemplates.xaml
Normal file
@@ -0,0 +1,21 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<DataTemplate x:Key="RectangleShapeEdit">
|
||||
<DataTemplate.Resources>
|
||||
</DataTemplate.Resources>
|
||||
<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" Style="{StaticResource ValidatedError}" Text="{Binding Width, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding Height, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
@@ -11,6 +11,14 @@
|
||||
<converters:Length x:Key="LengthConverter"/>
|
||||
<converters:Area x:Key="AreaConverter"/>
|
||||
|
||||
<Style TargetType="TextBox" x:Key="ValidatedError">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="Validation.HasError" Value="True">
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Shape" x:Key="ShapeStyle">
|
||||
<Setter Property="Fill">
|
||||
<Setter.Value>
|
||||
|
||||
Binary file not shown.
@@ -138,6 +138,7 @@
|
||||
<Compile Include="Infrastructure\UI\Converters\Units\Length.cs" />
|
||||
<Compile Include="Infrastructure\UI\Converters\Units\UnitBase.cs" />
|
||||
<Compile Include="Infrastructure\UI\Converters\Units\UnitConstatnts.cs" />
|
||||
<Compile Include="Infrastructure\UI\PrimitiveTemplates\IRectangleBeamProperties.cs" />
|
||||
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
|
||||
<DependentUpon>PrimitivePopup.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -201,10 +202,15 @@
|
||||
<Compile Include="Windows\PrimitiveProperiesWindow\PrimitivePropertiesView.xaml.cs">
|
||||
<DependentUpon>PrimitivePropertiesView.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\Materials\HeadMaterialsViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\PrimitiveProperties\PrimitivePropertiesViewModel.cs" />
|
||||
<Compile Include="Windows\ViewModels\PrimitiveTemplates\RCs\RectangleBeamViewModel.cs" />
|
||||
<Compile Include="Infrastructure\UI\PrimitiveTemplates\TemplateFactory.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Infrastructure\UI\Triggers\MouseEventTriggers\DoubleClickEventTrigger.cs" />
|
||||
@@ -223,6 +229,10 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Infrastructure\UI\Resources\ShapeEditTemplates.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Infrastructure\UI\Styles.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
@@ -271,6 +281,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\PrimitiveTemplates\RCs\RectangleBeam\RectangleBeamView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace StructureHelperLogics.Models.Materials
|
||||
if (MaterialType == MaterialTypes.Concrete)
|
||||
{ return GetConcrete();}
|
||||
else if (MaterialType == MaterialTypes.Reinforcement)
|
||||
{ return GetReinfrocemente();}
|
||||
{ return GetReinfrocement();}
|
||||
else throw new StructureHelperException($"{ErrorStrings.ObjectTypeIsUnknown}: material type = {MaterialType}, code type = {codeType}");
|
||||
}
|
||||
|
||||
|
||||
private LCM.IMaterial GetReinfrocemente()
|
||||
private LCM.IMaterial GetReinfrocement()
|
||||
{
|
||||
materialOptions = new LCMB.ReinforcementOptions();
|
||||
SetMaterialOptions();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Templates.RCs
|
||||
{
|
||||
public interface IRectangleBeamTemplate
|
||||
{
|
||||
IShape Shape { get; }
|
||||
double CoverGap { get; set; }
|
||||
double TopDiameter { get; set; }
|
||||
double BottomDiameter { get; set; }
|
||||
int WidthCount { get; set; }
|
||||
int HeightCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Templates.RCs
|
||||
{
|
||||
public class RectangleBeamTemplate : IRectangleBeamTemplate
|
||||
{
|
||||
public IShape Shape { get; }
|
||||
public double CoverGap { get; set; }
|
||||
public double TopDiameter { get; set; }
|
||||
public double BottomDiameter { get; set; }
|
||||
public int WidthCount { get; set; }
|
||||
public int HeightCount { get; set; }
|
||||
|
||||
public RectangleBeamTemplate()
|
||||
{
|
||||
Shape = new Rectangle() { Width = 0.4d, Height = 0.6d };
|
||||
CoverGap = 0.05d;
|
||||
TopDiameter = 0.016d;
|
||||
BottomDiameter = 0.025d;
|
||||
WidthCount = 2;
|
||||
HeightCount = 2;
|
||||
}
|
||||
|
||||
public RectangleBeamTemplate(double width, double height)
|
||||
{
|
||||
Shape = new Rectangle() { Width = width, Height = height };
|
||||
CoverGap = 0.05d;
|
||||
TopDiameter = 0.016d;
|
||||
BottomDiameter = 0.025d;
|
||||
WidthCount = 2;
|
||||
HeightCount = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,49 +88,5 @@ namespace StructureHelperLogics.NdmCalculations.Triangulations
|
||||
else { throw new StructureHelperException($"{ErrorStrings.ShapeIsNotCorrect} :{nameof(primitive.Shape)}"); }
|
||||
return ndms;
|
||||
}
|
||||
//private static IMaterial GetMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
//{
|
||||
// IMaterial material;
|
||||
// if (primitiveMaterial.MaterialType == MaterialTypes.Concrete) { material = GetConcreteMaterial(primitiveMaterial, options); }
|
||||
// else if (primitiveMaterial.MaterialType == MaterialTypes.Reinforcement) { material = GetReinforcementMaterial(primitiveMaterial, options); }
|
||||
// else { throw new StructureHelperException(ErrorStrings.MaterialTypeIsUnknown); }
|
||||
// return material;
|
||||
//}
|
||||
//private static IMaterial GetConcreteMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
//{
|
||||
// IMaterialOptions materialOptions = new ConcreteOptions();
|
||||
// SetMaterialOptions(materialOptions, primitiveMaterial, options);
|
||||
// IMaterialBuilder builder = new ConcreteBuilder(materialOptions);
|
||||
// IBuilderDirector director = new BuilderDirector(builder);
|
||||
// return director.BuildMaterial();
|
||||
//}
|
||||
//private static IMaterial GetReinforcementMaterial(IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
//{
|
||||
// IMaterialOptions materialOptions = new ReinforcementOptions();
|
||||
// SetMaterialOptions(materialOptions, primitiveMaterial, options);
|
||||
// IMaterialBuilder builder = new ReinforcementBuilder(materialOptions);
|
||||
// IBuilderDirector director = new BuilderDirector(builder);
|
||||
// return director.BuildMaterial();
|
||||
//}
|
||||
//private static void SetMaterialOptions(IMaterialOptions materialOptions, IPrimitiveMaterial primitiveMaterial, ITriangulationOptions options)
|
||||
//{
|
||||
// materialOptions.Strength = primitiveMaterial.Strength;
|
||||
// if (primitiveMaterial.CodeType == CodeTypes.EuroCode_2_1990)
|
||||
// {
|
||||
// materialOptions.CodesType = CodesType.EC2_1990;
|
||||
// }
|
||||
// else if (primitiveMaterial.CodeType == CodeTypes.SP63_13330_2018)
|
||||
// {
|
||||
// materialOptions.CodesType = CodesType.SP63_2018;
|
||||
// }
|
||||
// else { throw new StructureHelperException($"{ErrorStrings.ObjectTypeIsUnknown} : {primitiveMaterial.CodeType}"); }
|
||||
// if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Collapse) { materialOptions.LimitState = LimitStates.Collapse; }
|
||||
// else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.ServiceAbility) { materialOptions.LimitState = LimitStates.ServiceAbility; }
|
||||
// else if (options.LimiteState == Infrastructures.CommonEnums.LimitStates.Special) { materialOptions.LimitState = LimitStates.Special; }
|
||||
// else { throw new StructureHelperException(ErrorStrings.LimitStatesIsNotValid); }
|
||||
// if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.ShortTerm) { materialOptions.IsShortTerm = true; }
|
||||
// else if (options.CalcTerm == Infrastructures.CommonEnums.CalcTerms.LongTerm) { materialOptions.IsShortTerm = false; }
|
||||
// else { throw new StructureHelperException(ErrorStrings.LoadTermIsNotValid); }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using LoaderCalculator;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using LoaderCalculator.Data.SourceData;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||
using LoaderCalculator;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using System;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationsResults;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
|
||||
namespace StructureHelperLogics.Services
|
||||
namespace StructureHelperLogics.Services.NdmCalculations
|
||||
{
|
||||
public class CalculationService
|
||||
{
|
||||
private ICalculationProperty calculationProperty;
|
||||
|
||||
public IStrainMatrix GetPrimitiveStrainMatrix(INdmPrimitive[] ndmPrimitives, double mx, double my, double nz)
|
||||
{
|
||||
//Коллекция для хранения элементарных участков
|
||||
var ndmCollection = new List<INdm>();
|
||||
//Настройки триангуляции, пока опции могут быть только такие
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = LimitStates.Collapse, CalcTerm = CalcTerms.ShortTerm };
|
||||
|
||||
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
|
||||
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
{
|
||||
ConditionRate = 0.01,
|
||||
MaxIterationCount = 100,
|
||||
ConditionRate = calculationProperty.IterationProperty.Accuracy,
|
||||
MaxIterationCount = calculationProperty.IterationProperty.MaxIterationCount,
|
||||
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
|
||||
},
|
||||
NdmCollection = ndmCollection
|
||||
@@ -39,7 +40,7 @@ namespace StructureHelperLogics.Services
|
||||
return calculator.Result.StrainMatrix;
|
||||
}
|
||||
|
||||
public List<ICalculationResult> GetCalculationResults(ICalculationProperty calculationProperty, IEnumerable<INdm> ndms)
|
||||
public List<ICalculationResult> GetCalculationResults(IEnumerable<INdm> ndms)
|
||||
{
|
||||
List<ICalculationResult> results = new List<ICalculationResult>();
|
||||
foreach (var forceCombinations in calculationProperty.ForceCombinations)
|
||||
@@ -67,7 +68,7 @@ namespace StructureHelperLogics.Services
|
||||
var calculator = new Calculator();
|
||||
calculator.Run(loaderData, new CancellationToken());
|
||||
var result = calculator.Result;
|
||||
if (result.AccuracyRate <= accuracyRate) { return new CalculationResult() { IsValid = true, Desctription = "Analisys is done succsefully", LoaderResults=result };}
|
||||
if (result.AccuracyRate <= accuracyRate) { return new CalculationResult() { IsValid = true, Desctription = "Analisys is done succsefully", LoaderResults = result }; }
|
||||
else { return new CalculationResult() { IsValid = false, Desctription = "Required accuracy rate has not achived", LoaderResults = result }; }
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -75,5 +76,14 @@ namespace StructureHelperLogics.Services
|
||||
return new CalculationResult() { IsValid = false, Desctription = $"Error is appeared due to analysis. Error: {ex}" };
|
||||
}
|
||||
}
|
||||
|
||||
public CalculationService(ICalculationProperty property)
|
||||
{
|
||||
calculationProperty = property;
|
||||
}
|
||||
public CalculationService()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,13 +30,15 @@ namespace StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow
|
||||
private void LsCollapse_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var chBox = sender as RadioButton;
|
||||
if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.Collapse; }
|
||||
if (chBox.IsChecked == true & viewModel != null)
|
||||
{ viewModel.LimitState = LimitStates.Collapse; }
|
||||
}
|
||||
|
||||
private void LsServiceability_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var chBox = sender as RadioButton;
|
||||
if (chBox.IsChecked == true & viewModel != null) { viewModel.LimitState = LimitStates.ServiceAbility; }
|
||||
if (chBox.IsChecked == true & viewModel != null)
|
||||
{ viewModel.LimitState = LimitStates.ServiceAbility; }
|
||||
}
|
||||
|
||||
private void ShortLoads_Checked(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -14,6 +14,7 @@ using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials.Factories;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Services;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -48,19 +49,21 @@ namespace StructureHelper.Windows.MainWindow
|
||||
HeadMaterialRepository.LibMaterials = LibMaterialFactory.GetLibMaterials(code);
|
||||
}
|
||||
|
||||
public IStrainMatrix Calculate(double mx, double my, double nz)
|
||||
{
|
||||
var unitSystem = unitSystemService.GetCurrentSystem();
|
||||
return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive(unitSystem)).ToArray(), mx, my, nz);
|
||||
}
|
||||
//public IStrainMatrix Calculate(double mx, double my, double nz)
|
||||
//{
|
||||
// var unitSystem = unitSystemService.GetCurrentSystem();
|
||||
// return calculationService.GetPrimitiveStrainMatrix(primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive(unitSystem)).ToArray(),
|
||||
// mx, my, nz,
|
||||
// CalculationProperty.LimitState, CalculationProperty.CalcTerm);
|
||||
//}
|
||||
|
||||
public IEnumerable<INdm> GetNdms()
|
||||
public IEnumerable<INdm> GetNdms(ICalculationProperty calculationProperty)
|
||||
{
|
||||
var unitSystem = unitSystemService.GetCurrentSystem();
|
||||
var ndmPrimitives = primitiveRepository.Primitives.Select(x => x.GetNdmPrimitive(unitSystem)).ToArray();
|
||||
|
||||
//Настройки триангуляции, пока опции могут быть только такие
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = LimitStates.Collapse, CalcTerm = CalcTerms.ShortTerm };
|
||||
ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
|
||||
|
||||
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
|
||||
List<INdm> ndmCollection = new List<INdm>();
|
||||
@@ -69,21 +72,21 @@ namespace StructureHelper.Windows.MainWindow
|
||||
return ndmCollection;
|
||||
}
|
||||
|
||||
public ILoaderResults CalculateResult(IEnumerable<INdm> ndmCollection, IForceMatrix forceMatrix)
|
||||
{
|
||||
var loaderData = new LoaderOptions
|
||||
{
|
||||
Preconditions = new Preconditions
|
||||
{
|
||||
ConditionRate = 0.01,
|
||||
MaxIterationCount = 100,
|
||||
StartForceMatrix = forceMatrix
|
||||
},
|
||||
NdmCollection = ndmCollection
|
||||
};
|
||||
var calculator = new Calculator();
|
||||
calculator.Run(loaderData, new CancellationToken());
|
||||
return calculator.Result;
|
||||
}
|
||||
//public ILoaderResults CalculateResult(IEnumerable<INdm> ndmCollection, IForceMatrix forceMatrix)
|
||||
//{
|
||||
// var loaderData = new LoaderOptions
|
||||
// {
|
||||
// Preconditions = new Preconditions
|
||||
// {
|
||||
// ConditionRate = 0.01,
|
||||
// MaxIterationCount = 100,
|
||||
// StartForceMatrix = forceMatrix
|
||||
// },
|
||||
// NdmCollection = ndmCollection
|
||||
// };
|
||||
// var calculator = new Calculator();
|
||||
// calculator.Run(loaderData, new CancellationToken());
|
||||
// return calculator.Result;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
xmlns:converters ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:MainViewModel}"
|
||||
Title="StructureHelper" Height="700" Width="1000">
|
||||
Title="StructureHelper" Height="700" Width="1000" MinHeight="400" MinWidth="600">
|
||||
<Window.Resources>
|
||||
<converters:Length x:Key="LengthConverter"/>
|
||||
<converters:Area x:Key="AreaConverter"/>
|
||||
@@ -49,7 +49,9 @@
|
||||
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
|
||||
<Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/>
|
||||
<MenuItem Header="Templates">
|
||||
<Button Content="Concrete beam 400x600" Command="{Binding AddTestCase}"/>
|
||||
<Button Content="Concrete beam" Command="{Binding AddBeamCase}"/>
|
||||
<Button Content="Concrete column" Command="{Binding AddColumnCase}"/>
|
||||
<Button Content="Concrete slab" Command="{Binding AddSlabCase}"/>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Analisys">
|
||||
|
||||
@@ -1,35 +1,32 @@
|
||||
using System;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Infrastructure.UI.PrimitiveTemplates;
|
||||
using StructureHelper.MaterialCatalogWindow;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
|
||||
using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationResult;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using StructureHelperLogics.Services.NdmCalculations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.Extensions;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.MaterialCatalogWindow;
|
||||
using StructureHelper.Services;
|
||||
using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.Models.Materials;
|
||||
using LoaderCalculator.Data.Matrix;
|
||||
using LoaderCalculator.Data.Ndms;
|
||||
using StructureHelper.Services.ResultViewers;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationProperies;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
|
||||
using StructureHelperLogics.Services;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationResult;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperLogics.Models.Materials.Factories;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
@@ -131,7 +128,9 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public ICommand EditCalculationPropertyCommand { get; }
|
||||
public ICommand EditHeadMaterialsCommand { get; }
|
||||
public ICommand EditPrimitive { get; }
|
||||
public ICommand AddTestCase { get; }
|
||||
public ICommand AddBeamCase { get; }
|
||||
public ICommand AddColumnCase { get; }
|
||||
public ICommand AddSlabCase { get; }
|
||||
public ICommand LeftButtonDown { get; }
|
||||
public ICommand LeftButtonUp { get; }
|
||||
public ICommand PreviewMouseMove { get; }
|
||||
@@ -281,14 +280,34 @@ namespace StructureHelper.Windows.MainWindow
|
||||
o => SelectedPrimitive != null
|
||||
);
|
||||
|
||||
AddTestCase = new RelayCommand(o =>
|
||||
AddBeamCase = new RelayCommand(o =>
|
||||
{
|
||||
foreach (var primitive in GetTestCasePrimitives())
|
||||
foreach (var primitive in GetBeamCasePrimitives())
|
||||
{
|
||||
Primitives.Add(primitive);
|
||||
PrimitiveRepository.Add(primitive);
|
||||
}
|
||||
AddTestLoads();
|
||||
AddCaseLoads(50e3d, 50e3d, 0d);
|
||||
});
|
||||
|
||||
AddColumnCase = new RelayCommand(o =>
|
||||
{
|
||||
foreach (var primitive in GetColumnCasePrimitives())
|
||||
{
|
||||
Primitives.Add(primitive);
|
||||
PrimitiveRepository.Add(primitive);
|
||||
}
|
||||
AddCaseLoads(50e3d, 50e3d, -100e3d);
|
||||
});
|
||||
|
||||
AddSlabCase = new RelayCommand(o =>
|
||||
{
|
||||
foreach (var primitive in GetSlabCasePrimitives())
|
||||
{
|
||||
Primitives.Add(primitive);
|
||||
PrimitiveRepository.Add(primitive);
|
||||
}
|
||||
AddCaseLoads(-20e3d, 0d, 0d);
|
||||
});
|
||||
|
||||
Calculate = new RelayCommand(o =>
|
||||
@@ -354,9 +373,9 @@ namespace StructureHelper.Windows.MainWindow
|
||||
}
|
||||
try
|
||||
{
|
||||
IEnumerable<INdm> ndms = Model.GetNdms();
|
||||
CalculationService calculationService = new CalculationService();
|
||||
var loaderResults = calculationService.GetCalculationResults(calculationProperty, ndms);
|
||||
IEnumerable<INdm> ndms = Model.GetNdms(calculationProperty);
|
||||
CalculationService calculationService = new CalculationService(calculationProperty);
|
||||
var loaderResults = calculationService.GetCalculationResults(ndms);
|
||||
var wnd = new CalculationResultView(new CalculationResultViewModel(loaderResults, ndms));
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
@@ -379,52 +398,90 @@ namespace StructureHelper.Windows.MainWindow
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable<PrimitiveBase> GetTestCasePrimitives()
|
||||
private IEnumerable<PrimitiveBase> GetBeamCasePrimitives()
|
||||
{
|
||||
var width = 0.4d;
|
||||
var height = 0.6d;
|
||||
var area1 = Math.PI * 0.012d * 0.012d / 4d;
|
||||
var area2 = Math.PI * 0.025d * 0.025d / 4d;
|
||||
var gap = 0.05d;
|
||||
|
||||
var rectMaterial = new ConcreteDefinition("C40", 0, 40, 0, 1.3, 1.5);
|
||||
var pointMaterial = new RebarDefinition("S400", 2, 400, 400, 1.15, 1.15);
|
||||
|
||||
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete 40"};
|
||||
concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
|
||||
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement 400"};
|
||||
reinforcement.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Reinforcement & x.Name.Contains("400"))).First();
|
||||
headMaterials.Add(concrete);
|
||||
headMaterials.Add(reinforcement);
|
||||
OnPropertyChanged(nameof(headMaterials));
|
||||
|
||||
yield return new Rectangle(width, height, 0, 0, this) { Material = rectMaterial, MaterialName = rectMaterial.MaterialClass, HeadMaterial = concrete };
|
||||
yield return new Point(area1, -width / 2 + gap, -height / 2 + gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass, HeadMaterial = reinforcement };
|
||||
yield return new Point(area1, width / 2 - gap, -height / 2 + gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass, HeadMaterial = reinforcement };
|
||||
yield return new Point(area2, -width / 2 + gap, height / 2 - gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass, HeadMaterial = reinforcement };
|
||||
yield return new Point(area2, width / 2 - gap, height / 2 - gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass, HeadMaterial = reinforcement };
|
||||
var template = new RectangleBeamTemplate();
|
||||
return GetCasePrimitives(template);
|
||||
}
|
||||
|
||||
private IEnumerable<PrimitiveBase> GetColumnCasePrimitives()
|
||||
{
|
||||
var template = new RectangleBeamTemplate(0.5d, 0.5d) { CoverGap = 0.05, WidthCount = 3, HeightCount = 3, TopDiameter = 0.025d, BottomDiameter = 0.025d };
|
||||
return GetCasePrimitives(template);
|
||||
}
|
||||
|
||||
private IEnumerable<PrimitiveBase> GetSlabCasePrimitives()
|
||||
{
|
||||
var template = new RectangleBeamTemplate(1d, 0.2d) { CoverGap = 0.04, WidthCount = 5, HeightCount = 2, TopDiameter = 0.012d, BottomDiameter = 0.012d };
|
||||
return GetCasePrimitives(template);
|
||||
}
|
||||
|
||||
private void EditCalculationProperty()
|
||||
{
|
||||
CalculationPropertyViewModel viewModel = new CalculationPropertyViewModel(calculationProperty);
|
||||
var view = new CalculationPropertyView(viewModel);
|
||||
view.ShowDialog();
|
||||
}
|
||||
private void AddTestLoads()
|
||||
private void AddCaseLoads(double mx, double my, double nz)
|
||||
{
|
||||
calculationProperty.ForceCombinations.Clear();
|
||||
calculationProperty.ForceCombinations.Add(new ForceCombination());
|
||||
calculationProperty.ForceCombinations[0].ForceMatrix.Mx = 40e3d;
|
||||
calculationProperty.ForceCombinations[0].ForceMatrix.My = 20e3d;
|
||||
calculationProperty.ForceCombinations[0].ForceMatrix.Nz = 0d;
|
||||
calculationProperty.ForceCombinations.Add(new ForceCombination());
|
||||
calculationProperty.ForceCombinations[1].ForceMatrix.Mx = 200e3d;
|
||||
calculationProperty.ForceCombinations[1].ForceMatrix.My = 0d;
|
||||
calculationProperty.ForceCombinations[1].ForceMatrix.Nz = 0d;
|
||||
calculationProperty.ForceCombinations.Add(new ForceCombination());
|
||||
calculationProperty.ForceCombinations[2].ForceMatrix.Mx = 50e3d;
|
||||
calculationProperty.ForceCombinations[2].ForceMatrix.My = 50e3d;
|
||||
calculationProperty.ForceCombinations[2].ForceMatrix.Nz = 0d;
|
||||
ForceCombination combination = new ForceCombination();
|
||||
combination.ForceMatrix.Mx = mx;
|
||||
combination.ForceMatrix.My = my;
|
||||
combination.ForceMatrix.Nz = nz;
|
||||
calculationProperty.ForceCombinations.Add(combination);
|
||||
}
|
||||
private IEnumerable<PrimitiveBase> GetCasePrimitives(RectangleBeamTemplate template)
|
||||
{
|
||||
var wnd = new RectangleBeamView(template);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
var rect = template.Shape as StructureHelperCommon.Models.Shapes.Rectangle;
|
||||
var width = rect.Width;
|
||||
var height = rect.Height;
|
||||
var area1 = Math.PI * template.BottomDiameter * template.BottomDiameter / 4d;
|
||||
var area2 = Math.PI * template.TopDiameter * template.TopDiameter / 4d;
|
||||
var gap = template.CoverGap;
|
||||
|
||||
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete 40" };
|
||||
concrete.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Concrete & x.Name.Contains("40"))).First();
|
||||
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement 400" };
|
||||
reinforcement.HelperMaterial = Model.HeadMaterialRepository.LibMaterials.Where(x => (x.MaterialType == MaterialTypes.Reinforcement & x.Name.Contains("400"))).First();
|
||||
headMaterials.Add(concrete);
|
||||
headMaterials.Add(reinforcement);
|
||||
OnPropertyChanged(nameof(headMaterials));
|
||||
|
||||
double[] xs = new double[] { -width / 2 + gap, width / 2 - gap };
|
||||
double[] ys = new double[] { -height / 2 + gap, height / 2 - gap };
|
||||
|
||||
yield return new Rectangle(width, height, 0, 0, this) { HeadMaterial = concrete };
|
||||
yield return new Point(area1, xs[0], ys[0], this) { HeadMaterial = reinforcement };
|
||||
yield return new Point(area1, xs[1], ys[0], this) { HeadMaterial = reinforcement };
|
||||
yield return new Point(area2, xs[0], ys[1], this) { HeadMaterial = reinforcement };
|
||||
yield return new Point(area2, xs[1], ys[1], this) { HeadMaterial = reinforcement };
|
||||
|
||||
if (template.WidthCount > 2)
|
||||
{
|
||||
int count = template.WidthCount - 1;
|
||||
double dist = (xs[1] - xs[0]) / count;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
yield return new Point(area1, xs[0] + dist * i, ys[0], this) { HeadMaterial = reinforcement };
|
||||
yield return new Point(area2, xs[0] + dist * i, ys[1], this) { HeadMaterial = reinforcement };
|
||||
}
|
||||
}
|
||||
|
||||
if (template.HeightCount > 2)
|
||||
{
|
||||
int count = template.HeightCount - 1;
|
||||
double dist = (ys[1] - ys[0]) / count;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
yield return new Point(area1, xs[0], ys[0] + dist * i, this) { HeadMaterial = reinforcement };
|
||||
yield return new Point(area1, xs[1], ys[0] + dist * i, this) { HeadMaterial = reinforcement };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<Window x:Class="StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam.RectangleBeamView"
|
||||
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.PrimitiveTemplates.RCs.RectangleBeam"
|
||||
xmlns:res="clr-namespace:StructureHelper.Infrastructure.UI.PrimitiveTemplates"
|
||||
xmlns:vm ="clr-namespace:StructureHelper.Windows.ViewModels.PrimitiveTemplates.RCs"
|
||||
d:DataContext="{d:DesignInstance vm:RectangleBeamViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Reinforced beam template" Height="220" Width="300" SizeToContent="Height" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel>
|
||||
<ContentControl ContentTemplate="{StaticResource RectangleShapeEdit}" Content="{Binding}"/>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Cover gap"/>
|
||||
<TextBlock Grid.Row="1" Text="Top Diameter"/>
|
||||
<TextBlock Grid.Row="2" Text="Bottom Diameter"/>
|
||||
<TextBlock Grid.Row="3" Text="Width count"/>
|
||||
<TextBlock Grid.Row="4" Text="Height count"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding CoverGap, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding TopDiameter, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding BottomDiameter, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding WidthCount, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding HeightCount, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Width="60" Height="20" Margin="5" Content="Cancel" Command="{Binding CancelCommand}"/>
|
||||
<Button Width="60" Height="20" Margin="5" Content="OK" Command="{Binding OkCommand}"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,37 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.ViewModels.PrimitiveTemplates.RCs;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
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.PrimitiveTemplates.RCs.RectangleBeam
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для RectangleBeamView.xaml
|
||||
/// </summary>
|
||||
public partial class RectangleBeamView : Window
|
||||
{
|
||||
private RectangleBeamViewModel viewModel;
|
||||
|
||||
public IRectangleBeamTemplate ResultModel { get; set; }
|
||||
|
||||
public RectangleBeamView(IRectangleBeamTemplate template)
|
||||
{
|
||||
viewModel = new RectangleBeamViewModel(template);
|
||||
viewModel.ParentWindow = this;
|
||||
this.DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Templates.RCs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.PrimitiveTemplates.RCs
|
||||
{
|
||||
internal class RectangleBeamViewModel : ViewModelBase, IDataErrorInfo
|
||||
{
|
||||
public IRectangleBeamTemplate Model;
|
||||
|
||||
private Rectangle rectangle => (Model.Shape as Rectangle);
|
||||
|
||||
public Window ParentWindow { get; set; }
|
||||
|
||||
public ICommand OkCommand { get; private set; }
|
||||
public ICommand CancelCommand { get; private set; }
|
||||
|
||||
public double Width
|
||||
{
|
||||
get { return rectangle.Width; }
|
||||
set { rectangle.Width = value; }
|
||||
}
|
||||
public double Height
|
||||
{
|
||||
get { return rectangle.Height; }
|
||||
set { rectangle.Height = value; }
|
||||
}
|
||||
public double CoverGap
|
||||
{
|
||||
get { return Model.CoverGap; }
|
||||
set { Model.CoverGap = value; }
|
||||
}
|
||||
public double TopDiameter
|
||||
{
|
||||
get { return Model.TopDiameter; }
|
||||
set { Model.TopDiameter = value; }
|
||||
}
|
||||
public double BottomDiameter
|
||||
{
|
||||
get { return Model.BottomDiameter; }
|
||||
set { Model.BottomDiameter = value; }
|
||||
}
|
||||
public int WidthCount
|
||||
{
|
||||
get { return Model.WidthCount; }
|
||||
set { Model.WidthCount = value; }
|
||||
}
|
||||
public int HeightCount
|
||||
{
|
||||
get { return Model.HeightCount; }
|
||||
set { Model.HeightCount = value; }
|
||||
}
|
||||
|
||||
public string Error => throw new NotImplementedException();
|
||||
|
||||
public string this[string columnName]
|
||||
{
|
||||
get
|
||||
{
|
||||
string error = null;
|
||||
|
||||
if (columnName == nameof(Width)
|
||||
||
|
||||
columnName == nameof(Height))
|
||||
{
|
||||
if (this.Width <= 0 || this.Height <= 0)
|
||||
{
|
||||
error = "Width and Height of rectangle must be greater than zero";
|
||||
}
|
||||
}
|
||||
else if (columnName == nameof(TopDiameter) || columnName == nameof(BottomDiameter))
|
||||
{
|
||||
if (CoverGap <0 )
|
||||
{
|
||||
error = "Diameter must be grater than zero";
|
||||
}
|
||||
}
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
public RectangleBeamViewModel(IRectangleBeamTemplate template)
|
||||
{
|
||||
Model = template;
|
||||
|
||||
OkCommand = new RelayCommand(o => OkAction());
|
||||
CancelCommand = new RelayCommand(o => CancelAction());
|
||||
}
|
||||
|
||||
|
||||
private void CancelAction()
|
||||
{
|
||||
ParentWindow.DialogResult = false;
|
||||
ParentWindow.Close();
|
||||
}
|
||||
|
||||
private void OkAction()
|
||||
{
|
||||
ParentWindow.DialogResult = true;
|
||||
ParentWindow.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user