Templates was added
This commit is contained in:
@@ -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