Head material was added

This commit is contained in:
Evgeny Redikultsev
2022-10-30 22:20:58 +05:00
parent e1af4d5e07
commit 1cf54603bc
18 changed files with 363 additions and 31 deletions

View File

@@ -26,7 +26,11 @@
<TextBox Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Stretch" Margin="10" Text="{Binding Red}"/>
<Border Grid.Column="3" Grid.RowSpan="3" Margin="10" BorderBrush="Black" BorderThickness="1">
<Rectangle Fill="{Binding SelectedColor}"/>
<Rectangle>
<Rectangle.Fill>
<SolidColorBrush Color="{Binding SelectedColor}"/>
</Rectangle.Fill>
</Rectangle>
</Border>

View File

@@ -27,8 +27,8 @@ namespace StructureHelper.Windows.ColorPickerWindow
set => OnColorItemChanged(value, ref blue);
}
private Brush selectedColor;
public Brush SelectedColor
private Color selectedColor;
public Color SelectedColor
{
get => selectedColor;
set => OnPropertyChanged(value, ref selectedColor);
@@ -38,12 +38,12 @@ namespace StructureHelper.Windows.ColorPickerWindow
{
if (primitive != null)
{
var solidBrush = (SolidColorBrush)primitive.Brush;
Red = solidBrush.Color.R;
Green = solidBrush.Color.G;
Blue = solidBrush.Color.B;
var color = primitive.Color;
Red = color.R;
Green = color.G;
Blue = color.B;
SetColor = new RelayCommand(o => primitive.Brush = SelectedColor);
SetColor = new RelayCommand(o => primitive.Color = SelectedColor);
}
}
private void OnColorItemChanged(int value, ref int colorItem, [CallerMemberName] string propertyName = null)
@@ -58,7 +58,7 @@ namespace StructureHelper.Windows.ColorPickerWindow
private void UpdateSelectedColor()
{
var color = Color.FromRgb((byte)Red, (byte)Green, (byte)Blue);
SelectedColor = new SolidColorBrush(color);
SelectedColor = color;
OnPropertyChanged(nameof(SelectedColor));
}
}

View File

@@ -3,6 +3,7 @@ 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;
@@ -21,6 +22,7 @@ namespace StructureHelper.Windows.MainWindow
public class MainModel
{
private IPrimitiveRepository primitiveRepository;
public List<IHeadMaterial> HeadMaterials { get; }
private CalculationService calculationService;
private UnitSystemService unitSystemService;
@@ -33,6 +35,7 @@ namespace StructureHelper.Windows.MainWindow
this.unitSystemService = unitSystemService;
CalculationProperty = new CalculationProperty();
HeadMaterials = new List<IHeadMaterial>();
}
public IStrainMatrix Calculate(double mx, double my, double nz)

View File

@@ -47,6 +47,7 @@
<Button Content="Edit primitive" Command="{Binding EditPrimitive}"/>
<Button Content="Delete primitive" Command="{Binding DeletePrimitive}"/>
</MenuItem>
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
<Button Content="Calculation properties" Command="{Binding Path=EditCalculationPropertyCommand}"/>
</MenuItem>
<MenuItem Header="Analisys">
@@ -60,7 +61,24 @@
</Grid.ColumnDefinitions>
<StackPanel>
<Expander Header="Materials" ExpandDirection="Down" MinWidth="20" >
<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>
</Expander>
<Expander Header="Geometry" ExpandDirection="Down" MinWidth="20" >
<ListBox ItemsSource="{Binding Primitives}" SelectedItem="{Binding SelectedPrimitive}">
@@ -71,7 +89,11 @@
<ColumnDefinition Width="20"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Rectangle Grid.Column="0" Margin="3" Fill="{Binding Brush}" />
<Rectangle Grid.Column="0" Margin="3">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
</Grid>

View File

@@ -26,6 +26,7 @@ using StructureHelper.Services.Primitives;
using StructureHelper.Windows.PrimitiveProperiesWindow;
using StructureHelper.Infrastructure.Exceptions;
using StructureHelper.Infrastructure.Strings;
using StructureHelper.Windows.MainWindow.Materials;
namespace StructureHelper.Windows.MainWindow
{
@@ -86,6 +87,7 @@ namespace StructureHelper.Windows.MainWindow
get => canvasHeight;
set => OnPropertyChanged(value, ref canvasHeight);
}
public List<IHeadMaterial> HeadMaterials { get => Model.HeadMaterials; }
public double XX2
{
@@ -111,6 +113,7 @@ namespace StructureHelper.Windows.MainWindow
public ICommand Calculate { get; }
public ICommand DeletePrimitive { get; }
public ICommand EditCalculationPropertyCommand { get; }
public ICommand EditHeadMaterialsCommand { get; }
public ICommand EditPrimitive { get; }
public ICommand AddTestCase { get; }
public ICommand LeftButtonDown { get; }
@@ -178,6 +181,7 @@ namespace StructureHelper.Windows.MainWindow
primitive.ParameterCaptured = false;
}
});
EditHeadMaterialsCommand = new RelayCommand(o => EditHeadMaterials());
OpenMaterialCatalog = new RelayCommand(o =>
{
var materialCatalogView = new MaterialCatalogView();
@@ -291,6 +295,12 @@ namespace StructureHelper.Windows.MainWindow
});
}
private void EditHeadMaterials()
{
var wnd = new HeadMaterialsView(HeadMaterials);
wnd.ShowDialog();
}
private void DeleteSelectedPrimitive()
{
if (! (SelectedPrimitive is null))
@@ -331,13 +341,20 @@ namespace StructureHelper.Windows.MainWindow
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);
yield return new Rectangle(width, height, 0, 0, this) { Material = rectMaterial, MaterialName = rectMaterial.MaterialClass };
yield return new Point(area1, -width / 2 + gap, -height / 2 + gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(area1, width / 2 - gap, -height / 2 + gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(area2, -width / 2 + gap, height / 2 - gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
yield return new Point(area2, width / 2 - gap, height / 2 - gap, this) { Material = pointMaterial, MaterialName = pointMaterial.MaterialClass };
IHeadMaterial concrete = new HeadMaterial() { Name = "Concrete C40", Material = rectMaterial };
HeadMaterials.Add(concrete);
IHeadMaterial reinforcement = new HeadMaterial() { Name = "Reinforcement S400", Material = pointMaterial };
HeadMaterials.Add(reinforcement);
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 };
}
private void EditCalculationProperty()
{

View File

@@ -0,0 +1,41 @@
<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="400" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.ColumnDefinitions>
<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>
<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}"/>
</StackPanel>
</Grid>
</Window>

View File

@@ -0,0 +1,40 @@
using StructureHelper.Models.Materials;
using StructureHelper.Windows.ViewModels.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;
namespace StructureHelper.Windows.MainWindow.Materials
{
/// <summary>
/// Логика взаимодействия для HeadMaterials.xaml
/// </summary>
public partial class HeadMaterialsView : Window
{
private HeadMaterialsViewModel viewmodel;
public HeadMaterialsView(IEnumerable<IHeadMaterial> materials)
{
viewmodel = new HeadMaterialsViewModel(materials);
this.DataContext = viewmodel;
InitializeComponent();
}
public HeadMaterialsView(HeadMaterialsViewModel vm)
{
viewmodel = vm;
this.DataContext = viewmodel;
InitializeComponent();
}
}
}

View File

@@ -5,13 +5,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:StructureHelper.Windows.PrimitiveProperiesWindow"
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.PrimitiveProperties"
xmlns:converters ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
xmlns:convertersCommon ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Common"
xmlns:convertersUnits ="clr-namespace:StructureHelper.Infrastructure.UI.Converters.Units"
d:DataContext="{d:DesignInstance vm:PrimitivePropertiesViewModel}"
mc:Ignorable="d"
Title="PrimitiveProperties" Height="450" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Window.Resources>
<converters:Length x:Key="LengthConverter"/>
<converters:Area x:Key="AreaConverter"/>
<convertersCommon:InvertBoolConverter x:Key="InvertBoolConverter"/>
<convertersUnits:Length x:Key="LengthConverter"/>
<convertersUnits:Area x:Key="AreaConverter"/>
<DataTemplate x:Key="RectangleProperties">
<Expander Header="Rectangle" IsExpanded="True">
<Grid>
@@ -73,6 +75,7 @@
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
<RowDefinition Height="22"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
@@ -82,6 +85,7 @@
<TextBlock Grid.Row="1" Text="Name of material"/>
<TextBlock Grid.Row="2" Text="Center X"/>
<TextBlock Grid.Row="3" Text="Center Y"/>
<TextBlock Grid.Row="4" Text="Material color"/>
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Name}"/>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<ComboBox HorizontalAlignment="Left"/>
@@ -90,6 +94,16 @@
</StackPanel>
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
<StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<CheckBox IsChecked="{Binding SetMaterialColor}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,20,0"/>
<Rectangle Width="50" Margin="5,0,10,0">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
</Rectangle>
<Button Width="50" Content="..." Command="{Binding EditColorCommand}"/>
<Button Width="50" Content="..." Click="Button_Click"/>
</StackPanel>
</Grid>
</Expander>
<!--<Expander Header="Prestrain" IsExpanded="True">

View File

@@ -60,5 +60,10 @@ namespace StructureHelper.Windows.PrimitiveProperiesWindow
StpProperties.Children.Add(contentControl);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
viewModel.EditColor();
}
}
}

View File

@@ -0,0 +1,36 @@
using StructureHelper.Infrastructure;
using StructureHelper.Models.Materials;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace StructureHelper.Windows.ViewModels.Materials
{
public class HeadMaterialsViewModel : ViewModelBase
{
IEnumerable<IHeadMaterial> headMaterials;
public ICommand AddHeadMaterial;
public ICommand CopyHeadMaterial;
public ICommand DeleteHeadMaterial;
public ICommand EditHeadMaterial;
public ObservableCollection<IHeadMaterial> HeadMaterials { get; private set; }
public IHeadMaterial SelectedMaterial { get; set; }
public HeadMaterialsViewModel(IEnumerable<IHeadMaterial> materials)
{
headMaterials = materials;
HeadMaterials = new ObservableCollection<IHeadMaterial>();
foreach (var material in headMaterials)
{
HeadMaterials.Add(material);
}
}
}
}

View File

@@ -1,5 +1,6 @@
using StructureHelper.Infrastructure;
using StructureHelper.Infrastructure.UI.DataContexts;
using StructureHelper.Windows.ColorPickerWindow;
using StructureHelperCommon.Models.Shapes;
using System;
using System.Collections.Generic;
@@ -7,6 +8,8 @@ using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Linq;
using Point = StructureHelper.Infrastructure.UI.DataContexts.Point;
using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.Rectangle;
@@ -17,6 +20,8 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
{
private PrimitiveBase primitive;
public ICommand EditColorCommand;
public string Name
{
get => primitive.Name;
@@ -48,7 +53,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
public double CenterY
{
get => primitive.CenterY;
@@ -61,11 +65,6 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
public double Prestrain_Kx
{
get => primitive.Pre
}
public int MinElementDivision
{
get => primitive.MinElementDivision;
@@ -145,6 +144,26 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
}
}
public Color Color
{
get => primitive.Color;
set
{
primitive.Color = value;
OnPropertyChanged(nameof(Color));
}
}
public bool SetMaterialColor
{
get => primitive.SetMaterialColor;
set
{
primitive.SetMaterialColor = value;
OnPropertyChanged(nameof(SetMaterialColor));
}
}
public string this[string columnName]
{
get
@@ -169,6 +188,14 @@ namespace StructureHelper.Windows.ViewModels.PrimitiveProperties
public PrimitivePropertiesViewModel(PrimitiveBase primitive)
{
this.primitive = primitive;
EditColorCommand = new RelayCommand(o => EditColor(), o => !SetMaterialColor);
}
public void EditColor()
{
var wnd = new ColorPickerView(primitive);
wnd.ShowDialog();
OnPropertyChanged(nameof(Color));
}
}
}