SH: recovery

This commit is contained in:
NickAppLab
2023-02-12 23:38:24 +05:00
parent f013ddae13
commit 784d3d3a5f
416 changed files with 5188 additions and 1338 deletions

View File

@@ -0,0 +1,65 @@
using LoaderCalculator;
using LoaderCalculator.Data.Matrix;
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Data.ResultData;
using LoaderCalculator.Data.SourceData;
using StructureHelper.Models.Materials;
using StructureHelper.Services;
using StructureHelper.Services.Primitives;
using StructureHelper.UnitSystem;
using StructureHelper.UnitSystem.Systems;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Services.Units;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Materials;
using StructureHelperLogics.NdmCalculations.Triangulations;
using StructureHelperLogics.Services;
using StructureHelperLogics.Services.NdmCalculations;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace StructureHelper.Windows.MainWindow
{
public class MainModel
{
public ICrossSection Section { get; private set; }
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)
{
this.primitiveRepository = primitiveRepository;
this.calculationService = calculationService;
this.unitSystemService = unitSystemService;
Section = new CrossSection();
CalculationProperty = new CalculationProperty();
HeadMaterials = new List<IHeadMaterial>();
HeadMaterialRepository = new HeadMaterialRepository(this);
}
public IEnumerable<INdm> GetNdms(ICalculationProperty calculationProperty)
{
var ndmPrimitives = Section.SectionRepository.Primitives;
//Настройки триангуляции, пока опции могут быть только такие
ITriangulationOptions options = new TriangulationOptions { LimiteState = calculationProperty.LimitState, CalcTerm = calculationProperty.CalcTerm };
//Формируем коллекцию элементарных участков для расчета в библитеке (т.е. выполняем триангуляцию)
List<INdm> ndmCollection = new List<INdm>();
ndmCollection.AddRange(Triangulation.GetNdms(ndmPrimitives, options));
return ndmCollection;
}
}
}

View File

@@ -0,0 +1,221 @@
<Window x:Class="StructureHelper.Windows.MainWindow.MainView"
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:infrastructure="clr-namespace:StructureHelper.Infrastructure"
xmlns:dataTemplates="clr-namespace:StructureHelper.Infrastructure.UI.DataTemplates"
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
xmlns:vm="clr-namespace:StructureHelper.Windows.MainWindow"
xmlns:mouseEventTriggers="clr-namespace:StructureHelper.Infrastructure.UI.Triggers.MouseEventTriggers"
xmlns:local="clr-namespace:StructureHelper.Windows.MainWindow"
xmlns:enums="clr-namespace:StructureHelper.Infrastructure.Enums"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance local:MainViewModel}"
Title="StructureHelper" Height="700" Width="1000" MinHeight="400" MinWidth="600">
<Window.Resources>
<DataTemplate DataType="{x:Type dataContexts:RectangleViewPrimitive}">
<dataTemplates:RectangleTemplate/>
</DataTemplate>
<DataTemplate DataType="{x:Type dataContexts:PointViewPrimitive}">
<dataTemplates:EllipseTemplate/>
</DataTemplate>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Menu x:Name="menu">
<MenuItem Header="File">
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Primitives">
<MenuItem Header="Add">
<Button Content="Add Rectangle" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Add Point" Command="{Binding AddPrimitive}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
<Button Content="Edit primitive" Command="{Binding EditPrimitive}"/>
<Button Content="Delete primitive" Command="{Binding DeletePrimitive}"/>
</MenuItem>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
<Button Content="Move primitives to center" Command="{Binding Path=MovePrimitiveToGravityCenterCommand}"/>
<MenuItem Header="Templates">
<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="Tools">
<Button Content="Settings" Command="{Binding ShowVisualProperty}"/>
</MenuItem>
<!--<MenuItem Header="Help">
</MenuItem>-->
</Menu>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<Expander Header="Actions" MinWidth="20" DataContext="{Binding CombinationsLogic}">
<Expander.ContextMenu>
<ContextMenu>
<Button Content="Add Force Combination" Command="{Binding Add}"/>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
<ListBox.ContextMenu>
<ContextMenu>
<Button Content="Edit" Command="{Binding Edit}"/>
<Button Content="Copy" Command="{Binding Copy}"/>
<Button Content="Delete" Command="{Binding Delete}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Expander>
<Expander Header="Materials" MinWidth="20">
<Expander.ContextMenu>
<ContextMenu>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding HeadMaterials}" ItemTemplate="{StaticResource ColoredItemTemplate}">
</ListBox>
</Expander>
<Expander Header="Geometry" MinWidth="20" DataContext="{Binding PrimitiveLogic}">
<Expander.ContextMenu>
<ContextMenu>
<MenuItem Header="Add">
<Button Content="Add Rectangle" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Rectangle}"/>
<Button Content="Add Point" Command="{Binding Add}" CommandParameter="{x:Static enums:PrimitiveType.Point}"/>
</MenuItem>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ItemTemplate="{StaticResource ColoredItemTemplate}">
<ListBox.ContextMenu>
<ContextMenu>
<Button Content="Edit" Command="{Binding Edit}"/>
<Button Content="Copy" Command="{Binding Copy}"/>
<Button Content="Delete" Command="{Binding Delete}"/>
<Button Content="To Foreground" Command="{Binding SetToFront}"/>
<Button Content="To Background" Command="{Binding SetToBack}"/>
</ContextMenu>
</ListBox.ContextMenu>
</ListBox>
</Expander>
<Expander Header="Analyses" MinWidth="20" DataContext="{Binding CalculatorsLogic}">
<Expander.ContextMenu>
<ContextMenu>
<Button Content="Add Calculator" Command="{Binding Add}"/>
</ContextMenu>
</Expander.ContextMenu>
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}">
<ListBox.ContextMenu>
<ContextMenu>
<Button Content="Run" Command="{Binding Run}"/>
<Button Content="Edit" Command="{Binding Edit}"/>
<Button Content="Copy" Command="{Binding Copy}"/>
<Button Content="Delete" Command="{Binding Delete}"/>
</ContextMenu>
</ListBox.ContextMenu>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Name}"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Expander>
</StackPanel>
<Border BorderBrush="Black" Background="White" BorderThickness="1" Margin="5" Grid.Column="1">
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseDown">
<i:InvokeCommandAction Command="{Binding ClearSelection}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible">
<Canvas Name="WorkPlane" ClipToBounds="True" Width="{Binding CanvasWidth}" Height="{Binding CanvasHeight}">
<i:Interaction.Behaviors>
<infrastructure:MouseBehaviour MouseX="{Binding PanelX, Mode=OneWayToSource}" MouseY="{Binding PanelY, Mode=OneWayToSource}"/>
</i:Interaction.Behaviors>
<i:Interaction.Triggers>
<mouseEventTriggers:MouseWheelDownEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasDown}"/>
</mouseEventTriggers:MouseWheelDownEventTrigger>
<mouseEventTriggers:MouseWheelUpEventTrigger EventName="PreviewMouseWheel">
<i:InvokeCommandAction Command="{Binding ScaleCanvasUp}"/>
</mouseEventTriggers:MouseWheelUpEventTrigger>
</i:Interaction.Triggers>
<Canvas.LayoutTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding ScaleValue}" ScaleY="{Binding ScaleValue}"
CenterX="{Binding ScrollPanelX}" CenterY="{Binding ScrollPanelY}"/>
</TransformGroup>
</Canvas.LayoutTransform>
<Canvas.Background>
<VisualBrush TileMode="Tile"
Viewport="{Binding CanvasViewportSize}" ViewportUnits="Absolute"
Viewbox="{Binding CanvasViewportSize}" ViewboxUnits="Absolute">
<VisualBrush.Visual>
<Rectangle StrokeThickness="{Binding GridLineThickness}" Height="{Binding GridSize}" Width="{Binding GridSize}" Stroke="Darkgray"/>
</VisualBrush.Visual>
</VisualBrush>
</Canvas.Background>
<Line X1="0" X2="{Binding XX2}" Y1="{Binding XY1}" Y2="{Binding XY1}" Stroke="Red" StrokeThickness="{Binding AxisLineThickness}"/>
<Line X1="{Binding YX1}" X2="{Binding YX1}" Y1="0" Y2="{Binding YY2}" Stroke="ForestGreen" StrokeThickness="{Binding AxisLineThickness}"/>
<ItemsControl ItemsSource="{Binding PrimitiveLogic.Items}" d:DataContext="{d:DesignInstance vm:MainViewModel}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Setter Property="Canvas.ZIndex" Value="{Binding ZIndex}"/>
<Setter Property="Canvas.Left" Value="{Binding PrimitiveLeft}"/>
<Setter Property="Canvas.Top" Value="{Binding PrimitiveTop}"/>
<Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Canvas>
</ScrollViewer>
</Border>
</Grid>
<StatusBar Grid.Row="2">
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Zoom: "/>
<TextBlock Text="{Binding ScaleValue}"/>
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Number of primitives: "/>
<TextBlock Text="{Binding PrimitiveLogic.PrimitivesCount}"/>
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Grid size: "/>
<TextBlock Text="{Binding GridSize, Converter={StaticResource LengthConverter}}"/>
</StackPanel>
</StatusBarItem>
</StatusBar>
</Grid>
</Window>

View File

@@ -0,0 +1,18 @@
using System.Windows;
using StructureHelper.Services;
using StructureHelper.Services.Primitives;
namespace StructureHelper.Windows.MainWindow
{
public partial class MainView : Window
{
public IPrimitiveRepository PrimitiveRepository { get; }
public MainView(IPrimitiveRepository primitiveRepository, MainViewModel viewModel)
{
PrimitiveRepository = primitiveRepository;
DataContext = viewModel;
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,383 @@
using LoaderCalculator.Data.Ndms;
using LoaderCalculator.Logics.Geometry;
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.MaterialCatalogWindow;
using StructureHelper.Models.Materials;
using StructureHelper.Windows.CalculationWindows.CalculationPropertyWindow;
using StructureHelper.Windows.CalculationWindows.CalculationResultWindow;
using StructureHelper.Windows.ColorPickerWindow;
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.Enums;
using StructureHelperCommon.Infrastructures.Strings;
using StructureHelperCommon.Models.Forces;
using StructureHelperLogics.Models.Calculations.CalculationProperties;
using StructureHelperLogics.Models.CrossSections;
using StructureHelperLogics.Models.Templates.CrossSections.RCs;
using StructureHelperLogics.Models.Templates.RCs;
using StructureHelperLogics.Services.NdmCalculations;
using StructureHelperLogics.Services.NdmPrimitives;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Forms;
using System.Windows.Input;
namespace StructureHelper.Windows.MainWindow
{
public class MainViewModel : ViewModelBase
{
ICrossSection section;
ICrossSectionRepository repository => section.SectionRepository;
private CrossSectionViewVisualProperty visualProperty;
private readonly double scaleRate = 1.1d;
public PrimitiveBase SelectedPrimitive { get; set; }
public IForceCombinationList SelectedForceCombinationList { get; set; }
private readonly AnalysisVewModelLogic calculatorsLogic;
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
public IPrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
private MainModel Model { get; }
private double panelX, panelY, scrollPanelX, scrollPanelY;
public double PanelX
{
get => panelX;
set => OnPropertyChanged(value, ref panelX);
}
public double PanelY
{
get => panelY;
set => OnPropertyChanged(value, ref panelY);
}
public double ScrollPanelX
{
get => scrollPanelX;
set => OnPropertyChanged(value, ref scrollPanelX);
}
public double ScrollPanelY
{
get => scrollPanelY;
set => OnPropertyChanged(value, ref scrollPanelY);
}
private double scaleValue;
public double ScaleValue
{
get => Math.Round(scaleValue);
set
{
OnPropertyChanged(value, ref scaleValue);
OnPropertyChanged(nameof(AxisLineThickness));
OnPropertyChanged(nameof(GridLineThickness));
}
}
public double AxisLineThickness
{
get => visualProperty.AxisLineThickness / scaleValue;
}
public double GridLineThickness
{
get => visualProperty.GridLineThickness / scaleValue;
}
private double xX2, xY1, yX1, yY2;
public double CanvasWidth
{
get => visualProperty.WorkPlainWidth;
}
public double CanvasHeight
{
get => visualProperty.WorkPlainHeight;
}
public string CanvasViewportSize
{
get
{
string s = visualProperty.GridSize.ToString();
s = s.Replace(',', '.');
return $"0,0,{s},{s}";
}
}
public double GridSize { get => visualProperty.GridSize; }
public ObservableCollection<IHeadMaterial> HeadMaterials
{
get
{
var collection = new ObservableCollection<IHeadMaterial>();
foreach (var obj in Model.Section.SectionRepository.HeadMaterials)
{
collection.Add(obj);
}
return collection;
}
}
public double XX2
{
get => xX2;
set => OnPropertyChanged(value, ref xX2);
}
public double XY1
{
get => xY1;
set => OnPropertyChanged(value, ref xY1);
}
public double YX1
{
get => yX1;
set => OnPropertyChanged(value, ref yX1);
}
public double YY2
{
get => yY2;
set => OnPropertyChanged(value, ref yY2);
}
public ICommand Calculate { get; }
public ICommand EditCalculationPropertyCommand { get; }
public ICommand EditHeadMaterialsCommand { get; }
public ICommand AddBeamCase { get; }
public ICommand AddColumnCase { get; }
public ICommand AddSlabCase { get; }
public ICommand LeftButtonDown { get; }
public ICommand LeftButtonUp { get; }
public ICommand MovePrimitiveToGravityCenterCommand { get; }
public ICommand PreviewMouseMove { get; }
public ICommand ClearSelection { get; }
public ICommand OpenMaterialCatalog { get; }
public ICommand OpenMaterialCatalogWithSelection { get; }
public ICommand OpenUnitsSystemSettings { get; }
public ICommand SetColor { get; }
public ICommand SetInFrontOfAll { get; }
public ICommand SetInBackOfAll { get; }
public ICommand ScaleCanvasDown { get; }
public ICommand ScaleCanvasUp { get; }
public ICommand SetPopupCanBeClosedTrue { get; }
public ICommand SetPopupCanBeClosedFalse { get; }
public RelayCommand ShowVisualProperty
{
get
{
return showVisualProperty ??
(showVisualProperty = new RelayCommand(o=>
{
var wnd = new VisualPropertyView(visualProperty);
wnd.ShowDialog();
OnPropertyChanged(nameof(AxisLineThickness));
OnPropertyChanged(nameof(CanvasViewportSize));
OnPropertyChanged(nameof(GridSize));
}));
}
}
private double delta = 0.0005;
private ActionsViewModel combinationsLogic;
private IPrimitiveViewModelLogic primitiveLogic;
private RelayCommand showVisualProperty;
public MainViewModel(MainModel model)
{
visualProperty = new CrossSectionViewVisualProperty();
Model = model;
section = model.Section;
combinationsLogic = new ActionsViewModel(repository);
calculatorsLogic = new AnalysisVewModelLogic(repository);
primitiveLogic = new PrimitiveViewModelLogic(repository) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
XX2 = CanvasWidth;
XY1 = CanvasHeight / 2d;
YX1 = CanvasWidth / 2d;
YY2 = CanvasHeight;
scaleValue = 400d;
LeftButtonUp = new RelayCommand(o =>
{
if (o is RectangleViewPrimitive rect) rect.BorderCaptured = false;
});
LeftButtonDown = new RelayCommand(o =>
{
if (o is RectangleViewPrimitive rect) rect.BorderCaptured = true;
});
PreviewMouseMove = new RelayCommand(o =>
{
if (o is RectangleViewPrimitive rect && rect.BorderCaptured && !rect.ElementLock)
{
if (rect.PrimitiveWidth % 10d < delta || rect.PrimitiveWidth % 10d >= delta)
rect.PrimitiveWidth = Math.Round(PanelX / 10d) * 10d - rect.PrimitiveLeft + 10d;
else
rect.PrimitiveWidth = PanelX - rect.PrimitiveLeft + 10d;
if (rect.PrimitiveHeight % 10d < delta || rect.PrimitiveHeight % 10d >= delta)
rect.PrimitiveHeight = Math.Round(PanelY / 10d) * 10d - rect.PrimitiveTop + 10d;
else
rect.PrimitiveHeight = PanelY - rect.PrimitiveTop + 10d;
}
});
EditHeadMaterialsCommand = new RelayCommand(o => EditHeadMaterials());
OpenMaterialCatalog = new RelayCommand(o =>
{
var materialCatalogView = new MaterialCatalogView();
materialCatalogView.ShowDialog();
});
OpenMaterialCatalogWithSelection = new RelayCommand(o =>
{
var primitive = o as PrimitiveBase;
var materialCatalogView = new MaterialCatalogView(true, primitive);
materialCatalogView.ShowDialog();
});
SetColor = new RelayCommand(o =>
{
var primitive = o as PrimitiveBase;
var colorPickerView = new ColorPickerView(primitive);
colorPickerView.ShowDialog();
});
ScaleCanvasDown = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
ScrollPanelY = PanelY;
ScaleValue *= scaleRate;
});
ScaleCanvasUp = new RelayCommand(o =>
{
ScrollPanelX = PanelX;
ScrollPanelY = PanelY;
ScaleValue /= scaleRate;
});
AddBeamCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetBeamCasePrimitives());
//OnPropertyChanged(nameof(PrimitivesCount));
});
AddColumnCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetColumnCasePrimitives());
});
AddSlabCase = new RelayCommand(o =>
{
PrimitiveLogic.AddItems(GetSlabCasePrimitives());
});
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
{
if (CheckMaterials() == false) { return;}
var ndms = NdmPrimitivesService.GetNdms(repository.Primitives, LimitStates.SLS, CalcTerms.ShortTerm);
var center = GeometryOperations.GetGravityCenter(ndms);
foreach (var item in PrimitiveLogic.Items)
{
item.CenterX -= center.CenterX;
item.CenterY -= center.CenterY;
}
},
o => repository.Primitives.Count() > 0
);
SetPopupCanBeClosedTrue = new RelayCommand(o =>
{
if (!(o is PrimitiveBase primitive)) return;
primitive.PopupCanBeClosed = true;
});
SetPopupCanBeClosedFalse = new RelayCommand(o =>
{
if (!(o is PrimitiveBase primitive)) return;
primitive.PopupCanBeClosed = false;
});
}
private void EditHeadMaterials()
{
var wnd = new HeadMaterialsView(repository);
wnd.ShowDialog();
OnPropertyChanged(nameof(HeadMaterials));
foreach (var primitive in primitiveLogic.Items)
{
primitive.RefreshColor();
}
}
private bool CheckAnalisysOptions()
{
if (CheckMaterials() == false) { return false; }
return true;
}
private bool CheckMaterials()
{
foreach (var item in primitiveLogic.Items)
{
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> GetBeamCasePrimitives()
{
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 IEnumerable<PrimitiveBase> GetCasePrimitives(RectangleBeamTemplate template)
{
var wnd = new RectangleBeamView(template);
wnd.ShowDialog();
if (wnd.DialogResult == true)
{
var newSection = new SectionTemplate(new RectGeometryLogic(template)).GetCrossSection();
var newRepository = newSection.SectionRepository;
repository.HeadMaterials.AddRange(newRepository.HeadMaterials);
repository.Primitives.AddRange(newRepository.Primitives);
repository.ForceCombinationLists.AddRange(newRepository.ForceCombinationLists);
repository.CalculatorsList.AddRange(newRepository.CalculatorsList);
OnPropertyChanged(nameof(HeadMaterials));
CombinationsLogic.AddItems(newRepository.ForceCombinationLists);
CalculatorsLogic.AddItems(newRepository.CalculatorsList);
var primitives = PrimitiveOperations.ConvertNdmPrimitivesToPrimitiveBase(newRepository.Primitives);
foreach (var item in primitives)
{
item.RegisterDeltas(CanvasWidth / 2, CanvasHeight / 2);
}
PrimitiveLogic.Refresh();
return primitives;
}
return new List<PrimitiveBase>();
}
}
}

View File

@@ -0,0 +1,115 @@
<Window x:Class="StructureHelper.Windows.MainWindow.Materials.HeadMaterialsView"
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"
d:DataContext="{d:DesignInstance vm:HeadMaterialsViewModel}"
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 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 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">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
<RowDefinition Height="28"/>
</Grid.RowDefinitions>
<TextBlock Text="Elastic material"/>
<TextBlock Grid.Row="1" Text="Young's modulus"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Modulus, Converter={StaticResource StressConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="2" Text="Compressive strength"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding CompressiveStrength, Converter={StaticResource StressConverter}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="3" Text="Tensile strength"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding TensileStrength, Converter={StaticResource StressConverter}, ValidatesOnExceptions=True}"/>
</Grid>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="280"/>
</Grid.ColumnDefinitions>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<ListBox ItemsSource="{Binding HeadMaterials}" SelectedItem="{Binding SelectedMaterial}" SelectionChanged="ListBox_SelectionChanged">
<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>
</Grid>
<StackPanel Grid.Column="1">
<Button Content="New Concrete" Command="{Binding AddNewConcreteMaterialCommand}"/>
<Button Content="New Reinforcement" Command="{Binding AddNewReinforcementMaterialCommand}"/>
<Button Content="New Elastic Material" Command="{Binding AddElasticMaterialCommand}"/>
<Button Content="Edit color" Command="{Binding EditColorCommand}"/>
<Button Content="Copy" Command="{Binding CopyHeadMaterialCommand}"/>
<Button Content="Delete" Command="{Binding DeleteMaterialCommand}"/>
</StackPanel>
<StackPanel Grid.Column="2">
<TextBlock Text="Name"/>
<TextBox Text="{Binding SelectedMaterial.Name}"/>
<StackPanel x:Name="StpMaterialProperties"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,69 @@
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels.Materials;
using StructureHelperLogics.Models.Materials;
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;
using System.Xml.Linq;
namespace StructureHelper.Windows.MainWindow.Materials
{
/// <summary>
/// Логика взаимодействия для HeadMaterials.xaml
/// </summary>
public partial class HeadMaterialsView : Window
{
private HeadMaterialsViewModel viewModel;
//public HeadMaterialsView(List<IHeadMaterial> headMaterials) : this(new HeadMaterialsViewModel(headMaterials)) {}
public HeadMaterialsView(IHasHeadMaterials hasHeadMaterials) : this(new HeadMaterialsViewModel(hasHeadMaterials)) { }
public HeadMaterialsView(HeadMaterialsViewModel vm)
{
viewModel = vm;
this.DataContext = viewModel;
InitializeComponent();
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
StpMaterialProperties.Children.Clear();
var selectedMaterial = viewModel.SelectedMaterial;
if (selectedMaterial == null) { return; }
var helperMaterial = selectedMaterial.HelperMaterial;
string dataTemplateName = string.Empty;
Binding binding = new Binding();
if (helperMaterial is IConcreteLibMaterial)
{
dataTemplateName = "ConcreteLibMaterial";
binding.Source = viewModel;
}
else if (helperMaterial is IReinforcementLibMaterial)
{
dataTemplateName = "ReinforcementLibMaterial";
binding.Source = viewModel;
}
else if (helperMaterial is IElasticMaterial)
{
dataTemplateName = "ElasticMaterial";
binding.Source = viewModel.SelectedMaterial.HelperMaterial;
}
if (dataTemplateName != string.Empty)
{
ContentControl contentControl = new ContentControl();
contentControl.SetResourceReference(ContentTemplateProperty, dataTemplateName);
contentControl.SetBinding(ContentProperty, binding);
StpMaterialProperties.Children.Add(contentControl);
}
}
}
}

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,24 @@
<Window x:Class="StructureHelper.Windows.MainWindow.VisualPropertyView"
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"
mc:Ignorable="d"
Title="Grid properies" Height="200" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="130"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Axis grid thickness"/>
<TextBox Grid.Column="1" Text="{Binding AxisLineThickness, Converter={StaticResource PlainDouble}, ValidatesOnExceptions=True}"/>
<TextBlock Grid.Row="1" Text="Mesh size"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding GridSize, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
</Grid>
</Window>

View File

@@ -0,0 +1,29 @@
using StructureHelper.Windows.ViewModels.NdmCrossSections;
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
{
/// <summary>
/// Логика взаимодействия для VisualPropertyView.xaml
/// </summary>
public partial class VisualPropertyView : Window
{
public VisualPropertyView(CrossSectionViewVisualProperty vm)
{
InitializeComponent();
DataContext = vm;
}
}
}