Edition of primitives is changed
This commit is contained in:
116
Windows/PrimitiveProperiesWindow/PrimitivePropertiesView.xaml
Normal file
116
Windows/PrimitiveProperiesWindow/PrimitivePropertiesView.xaml
Normal file
@@ -0,0 +1,116 @@
|
||||
<Window x:Class="StructureHelper.Windows.PrimitiveProperiesWindow.PrimitiveProperties"
|
||||
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.PrimitiveProperiesWindow"
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.PrimitiveProperties"
|
||||
xmlns:converters ="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"/>
|
||||
<DataTemplate x:Key="RectangleProperties">
|
||||
<Expander Header="Rectangle" IsExpanded="True">
|
||||
<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" 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>
|
||||
</Expander>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="PointProperties">
|
||||
<Expander Header="Point" IsExpanded="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Area"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Area, Converter={StaticResource AreaConverter}, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="TriangulationProperties">
|
||||
<Expander Header="Triangulation" IsExpanded="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Minimum element division"/>
|
||||
<TextBlock Grid.Row="1" Text="Maximum element size"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding MinElementDivision, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding MaxElementSize, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</DataTemplate>
|
||||
</Window.Resources>
|
||||
<ScrollViewer>
|
||||
<StackPanel x:Name="StpProperties">
|
||||
<Expander Header="Common properties" IsExpanded="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<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="Name"/>
|
||||
<TextBlock Grid.Row="1" Text="Name of material"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y"/>
|
||||
<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"/>
|
||||
<Button Width="50" Content="...">
|
||||
</Button>
|
||||
</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}"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
<!--<Expander Header="Prestrain" IsExpanded="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
<RowDefinition Height="22"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="k_x"/>
|
||||
<TextBlock Grid.Row="1" Text="k_y"/>
|
||||
<TextBlock Grid.Row="2" Text="epsilon_z"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Text="{Binding Prestrain_kx, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Text="{Binding Prestrain_kx, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Text="{Binding Prestrain_kx, ValidatesOnDataErrors=True}"/>
|
||||
</Grid>
|
||||
</Expander>-->
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Window>
|
||||
@@ -0,0 +1,64 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.Infrastructure.UI.DataContexts;
|
||||
using StructureHelper.Windows.ViewModels.PrimitiveProperties;
|
||||
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;
|
||||
using Point = StructureHelper.Infrastructure.UI.DataContexts.Point;
|
||||
using Rectangle = StructureHelper.Infrastructure.UI.DataContexts.Rectangle;
|
||||
|
||||
namespace StructureHelper.Windows.PrimitiveProperiesWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для PrimitiveProperties.xaml
|
||||
/// </summary>
|
||||
public partial class PrimitiveProperties : Window
|
||||
{
|
||||
PrimitiveBase primitive;
|
||||
private PrimitivePropertiesViewModel viewModel;
|
||||
public PrimitiveProperties(PrimitiveBase primitive)
|
||||
{
|
||||
this.primitive = primitive;
|
||||
viewModel = new PrimitivePropertiesViewModel(this.primitive);
|
||||
this.DataContext = viewModel;
|
||||
InitializeComponent();
|
||||
if (primitive is Rectangle) { AddPrimitiveProperties(PrimitiveType.Rectangle); }
|
||||
else if (primitive is Point) { AddPrimitiveProperties(PrimitiveType.Point); }
|
||||
else { throw new Exception("Type of object is unknown"); }
|
||||
}
|
||||
private void AddPrimitiveProperties(PrimitiveType type)
|
||||
{
|
||||
List<string> names = new List<string>();
|
||||
if (type == PrimitiveType.Rectangle)
|
||||
{
|
||||
names.Add("TriangulationProperties");
|
||||
names.Add("RectangleProperties");
|
||||
}
|
||||
else if (type == PrimitiveType.Point)
|
||||
{
|
||||
names.Add("PointProperties");
|
||||
}
|
||||
else { throw new Exception("Type of object is unknown"); }
|
||||
foreach (var name in names)
|
||||
{
|
||||
ContentControl contentControl = new ContentControl();
|
||||
contentControl.SetResourceReference(ContentControl.ContentTemplateProperty, name);
|
||||
Binding binding = new Binding();
|
||||
binding.Source = viewModel;
|
||||
contentControl.SetBinding(ContentControl.ContentProperty, binding);
|
||||
StpProperties.Children.Add(contentControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user