Library material was added
This commit is contained in:
@@ -8,8 +8,11 @@ using StructureHelper.Services;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.UnitSystem;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperLogics.Infrastructures.CommonEnums;
|
||||
using StructureHelperLogics.Models.Calculations.CalculationProperties;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.Models.Materials.Factories;
|
||||
using StructureHelperLogics.NdmCalculations.Triangulations;
|
||||
using StructureHelperLogics.Services;
|
||||
using System.Collections;
|
||||
@@ -21,11 +24,17 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainModel
|
||||
{
|
||||
//const CodeTypes code = CodeTypes.EuroCode_2_1990;
|
||||
const CodeTypes code = CodeTypes.SP63_13330_2018;
|
||||
|
||||
private IPrimitiveRepository primitiveRepository;
|
||||
public IHeadMaterialRepository HeadMaterialRepository { get; }
|
||||
public List<IHeadMaterial> HeadMaterials { get; }
|
||||
private CalculationService calculationService;
|
||||
private UnitSystemService unitSystemService;
|
||||
|
||||
public IPrimitiveRepository PrimitiveRepository => primitiveRepository;
|
||||
|
||||
public ICalculationProperty CalculationProperty { get; private set; }
|
||||
|
||||
public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
|
||||
@@ -36,6 +45,8 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
CalculationProperty = new CalculationProperty();
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
HeadMaterialRepository = new HeadMaterialRepository(this);
|
||||
HeadMaterialRepository.LibMaterials = LibMaterialFactory.GetLibMaterials(code);
|
||||
}
|
||||
|
||||
public IStrainMatrix Calculate(double mx, double my, double nz)
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="20"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="40"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
@@ -49,6 +48,9 @@
|
||||
</MenuItem>
|
||||
<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}"/>
|
||||
</MenuItem>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Analisys">
|
||||
<Button Content="Solve problem" Command="{Binding Path=Calculate}"/>
|
||||
@@ -96,7 +98,7 @@
|
||||
</Rectangle>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
|
||||
|
||||
<!--<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
@@ -177,13 +179,10 @@
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Grid>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal">
|
||||
<!--<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="Справочник" Command="{Binding OpenMaterialCatalog}"/>
|
||||
<Button VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="Units" Command="{Binding OpenUnitsSystemSettings}"/>
|
||||
<Label VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5" Content="{Binding UnitsSystemName}"/>-->
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0.333,0.333,39.667" Grid.RowSpan="2" Width="519">
|
||||
<Button VerticalAlignment="Center" Margin="5" Content="Add test primitives" Command="{Binding AddTestCase}"/>
|
||||
</StackPanel>
|
||||
<StatusBar Grid.Row="2">
|
||||
<StatusBarItem>
|
||||
<TextBlock Text="Structure Helper"/>
|
||||
</StatusBarItem>
|
||||
</StatusBar>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -24,16 +24,20 @@ using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
|
||||
using StructureHelper.Windows.ViewModels.Calculations.CalculationResult;
|
||||
using StructureHelper.Services.Primitives;
|
||||
using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelper.Infrastructure.Exceptions;
|
||||
using StructureHelper.Infrastructure.Strings;
|
||||
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
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
{
|
||||
private List<IHeadMaterial> headMaterials;
|
||||
private readonly double scaleRate = 1.1;
|
||||
|
||||
|
||||
private IPrimitiveRepository PrimitiveRepository { get; }
|
||||
public PrimitiveBase SelectedPrimitive { get; set; }
|
||||
|
||||
@@ -87,7 +91,19 @@ namespace StructureHelper.Windows.MainWindow
|
||||
get => canvasHeight;
|
||||
set => OnPropertyChanged(value, ref canvasHeight);
|
||||
}
|
||||
public List<IHeadMaterial> HeadMaterials { get => Model.HeadMaterials; }
|
||||
|
||||
public ObservableCollection<IHeadMaterial> HeadMaterials
|
||||
{
|
||||
get
|
||||
{
|
||||
var collection = new ObservableCollection<IHeadMaterial>();
|
||||
foreach (var obj in headMaterials)
|
||||
{
|
||||
collection.Add(obj);
|
||||
}
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
public double XX2
|
||||
{
|
||||
@@ -139,6 +155,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
PrimitiveRepository = primitiveRepository;
|
||||
Model = model;
|
||||
headMaterials = Model.HeadMaterialRepository.HeadMaterials;
|
||||
this.unitSystemService = unitSystemService;
|
||||
CanvasWidth = 1500;
|
||||
CanvasHeight = 1000;
|
||||
@@ -148,7 +165,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
YY2 = CanvasHeight;
|
||||
calculationProperty = new CalculationProperty();
|
||||
|
||||
|
||||
LeftButtonUp = new RelayCommand(o =>
|
||||
{
|
||||
if (o is Rectangle rect) rect.BorderCaptured = false;
|
||||
@@ -297,8 +313,10 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
private void EditHeadMaterials()
|
||||
{
|
||||
var wnd = new HeadMaterialsView(HeadMaterials);
|
||||
var wnd = new HeadMaterialsView(Model.HeadMaterialRepository);
|
||||
wnd.ShowDialog();
|
||||
headMaterials = Model.HeadMaterialRepository.HeadMaterials;
|
||||
OnPropertyChanged(nameof(headMaterials));
|
||||
}
|
||||
|
||||
private void DeleteSelectedPrimitive()
|
||||
@@ -319,19 +337,46 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
if (!(SelectedPrimitive is null))
|
||||
{
|
||||
var wnd = new PrimitiveProperties(SelectedPrimitive);
|
||||
var wnd = new PrimitiveProperties(SelectedPrimitive, Model.HeadMaterialRepository);
|
||||
wnd.ShowDialog();
|
||||
OnPropertyChanged(nameof(headMaterials));
|
||||
}
|
||||
else { MessageBox.Show("Selection is changed", "Please, select primitive", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); }
|
||||
}
|
||||
|
||||
private void CalculateResult()
|
||||
{
|
||||
IEnumerable<INdm> ndms = Model.GetNdms();
|
||||
CalculationService calculationService = new CalculationService();
|
||||
var loaderResults = calculationService.GetCalculationResults(calculationProperty, ndms);
|
||||
var wnd = new CalculationResultView(new CalculationResultViewModel(loaderResults, ndms));
|
||||
wnd.ShowDialog();
|
||||
bool check = CheckAnalisysOptions();
|
||||
if (check == false)
|
||||
{
|
||||
MessageBox.Show(ErrorStrings.DataIsInCorrect, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
IEnumerable<INdm> ndms = Model.GetNdms();
|
||||
CalculationService calculationService = new CalculationService();
|
||||
var loaderResults = calculationService.GetCalculationResults(calculationProperty, ndms);
|
||||
var wnd = new CalculationResultView(new CalculationResultViewModel(loaderResults, ndms));
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"{ErrorStrings.UnknownError}: {ex}", "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckAnalisysOptions()
|
||||
{
|
||||
foreach (var item in PrimitiveRepository.Primitives)
|
||||
{
|
||||
if (item.HeadMaterial == null)
|
||||
{
|
||||
MessageBox.Show($"Primitive {item.Name} does not has material", "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable<PrimitiveBase> GetTestCasePrimitives()
|
||||
@@ -345,10 +390,13 @@ namespace StructureHelper.Windows.MainWindow
|
||||
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 C40", Material = rectMaterial };
|
||||
HeadMaterials.Add(concrete);
|
||||
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement S400", Material = pointMaterial };
|
||||
HeadMaterials.Add(reinforcement);
|
||||
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 };
|
||||
|
||||
@@ -13,29 +13,46 @@
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox ItemsSource="{Binding HeadMaterials}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Column="0" Margin="3">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Column="0" Margin="3">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBox Grid.Row="1" Text="{Binding SelectedMaterial.Name}"/>
|
||||
<ComboBox Grid.Row="2" ItemsSource="{Binding LibMaterials}" SelectedItem="{Binding SelectedLibMaterial}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Column="1">
|
||||
<Button Content="New Concrete" Command="{Binding AddHeadMaterial}"/>
|
||||
<Button Content="New Reinforcement" Command="{Binding AddHeadMaterial}"/>
|
||||
<Button Content="Edit" Command="{Binding EditHeadMaterial}"/>
|
||||
<Button Content="Edit" Command="{Binding DeleteHeadMaterial}"/>
|
||||
<Button Content="New Material" Command="{Binding AddNewMaterialCommand}"/>
|
||||
<Button Content="Edit color" Command="{Binding EditColorCommand}"/>
|
||||
<Button Content="Copy" Command="{Binding CopyHeadMaterialCommand}"/>
|
||||
<Button Content="Delete" Command="{Binding DeleteMaterialCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelper.Windows.ViewModels.Materials;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -23,9 +24,9 @@ namespace StructureHelper.Windows.MainWindow.Materials
|
||||
{
|
||||
private HeadMaterialsViewModel viewmodel;
|
||||
|
||||
public HeadMaterialsView(IEnumerable<IHeadMaterial> materials)
|
||||
public HeadMaterialsView(IHeadMaterialRepository headMaterialRepository)
|
||||
{
|
||||
viewmodel = new HeadMaterialsViewModel(materials);
|
||||
viewmodel = new HeadMaterialsViewModel(headMaterialRepository);
|
||||
this.DataContext = viewmodel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user