Compare commits
33 Commits
PrimitiveP
...
MainGraph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd927f6da7 | ||
|
|
decbc10f51 | ||
|
|
776fc4c494 | ||
|
|
9a2cfbb08e | ||
|
|
943f80ad8d | ||
|
|
0829b9c57e | ||
|
|
45dc56a63e | ||
|
|
0a7a696b5f | ||
|
|
27d4ca95c8 | ||
|
|
68a1e62c18 | ||
|
|
e0acca2e36 | ||
|
|
4ec3ef25fb | ||
|
|
ceefe3dbca | ||
|
|
7996bd7a3d | ||
|
|
5712a85f38 | ||
|
|
33820e972b | ||
|
|
7c9bc1856b | ||
|
|
585eb9b86b | ||
|
|
8205dafdbd | ||
|
|
bcea9639f6 | ||
|
|
96b0fbd6a3 | ||
|
|
94387d0d0b | ||
|
|
49d04c7bcc | ||
|
|
2738b1b7b3 | ||
|
|
2a0704fc4f | ||
|
|
8510db1a85 | ||
|
|
11ac7c7c48 | ||
|
|
88ac95af2f | ||
|
|
d8f0d9dd88 | ||
|
|
883dbb189f | ||
|
|
b5ed00341c | ||
|
|
72add44fe7 | ||
|
|
ccc9513416 |
@@ -12,6 +12,7 @@ namespace StructureHelper.Infrastructure.Enums
|
||||
Reinforcement,
|
||||
Elastic,
|
||||
CarbonFiber,
|
||||
GlassFiber
|
||||
GlassFiber,
|
||||
Function,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,14 +142,14 @@
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ButtonCalculatorRectangle">
|
||||
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
||||
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<Rectangle Style="{DynamicResource ButtonRect}" Stroke="{DynamicResource CalculatorFrame}">
|
||||
<Rectangle.Fill>
|
||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
||||
<GradientStop Color="{DynamicResource ButtonLight}" Offset="0.2"/>
|
||||
<GradientStop Color="{DynamicResource CalculatorColor}" Offset="1"/>
|
||||
</LinearGradientBrush>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate x:Key="ButtonResultRectangle">
|
||||
@@ -326,5 +326,25 @@
|
||||
</Canvas.Children>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="AddTable">
|
||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
||||
<Canvas.Children>
|
||||
<Rectangle Height="32" Width="32" Fill="LightGreen"/>
|
||||
<Line X1="2" X2="30" Y1="2" Y2="2" Stroke="Black" StrokeThickness="2"/>
|
||||
<Line X1="2" X2="30" Y1="16" Y2="16" Stroke="Black" StrokeThickness="2"/>
|
||||
<Line X1="2" X2="30" Y1="30" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
||||
<Line X1="2" X2="2" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
||||
<Line X1="16" X2="16" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
||||
<Line X1="30" X2="30" Y1="2" Y2="30" Stroke="Black" StrokeThickness="2"/>
|
||||
</Canvas.Children>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
<DataTemplate x:Key="TestIcon">
|
||||
<Canvas Style="{DynamicResource ButtonResultCanvas}">
|
||||
<Canvas.Children>
|
||||
<TextBlock Text="fx" Width="32" Height="32" Background="LightGreen"/>
|
||||
</Canvas.Children>
|
||||
</Canvas>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
BIN
StructureHelper/Libraries/FunctionParser.dll
Normal file
@@ -27,6 +27,8 @@
|
||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
||||
<None Remove="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
||||
<None Remove="Windows\MainWindow\AddFormula.png" />
|
||||
<None Remove="Windows\MainWindow\AddTable.png" />
|
||||
<None Remove="Windows\MainWindow\Analysis32.png" />
|
||||
<None Remove="Windows\MainWindow\Beam32.png" />
|
||||
<None Remove="Windows\MainWindow\Calculator32.png" />
|
||||
@@ -37,7 +39,11 @@
|
||||
<None Remove="Windows\MainWindow\Delete.png" />
|
||||
<None Remove="Windows\MainWindow\Edit.png" />
|
||||
<None Remove="Windows\MainWindow\ElasticMaterial32.png" />
|
||||
<None Remove="Windows\MainWindow\FunctionMaterial.png" />
|
||||
<None Remove="Windows\MainWindow\GetY.png" />
|
||||
<None Remove="Windows\MainWindow\GlassMaterial32.png" />
|
||||
<None Remove="Windows\MainWindow\LimX.png" />
|
||||
<None Remove="Windows\MainWindow\LimY.png" />
|
||||
<None Remove="Windows\MainWindow\Materials32.png" />
|
||||
<None Remove="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
||||
<None Remove="Windows\MainWindow\Point32.png" />
|
||||
@@ -46,10 +52,13 @@
|
||||
<None Remove="Windows\MainWindow\RectangleColumn32.png" />
|
||||
<None Remove="Windows\MainWindow\RFMaterial32.png" />
|
||||
<None Remove="Windows\MainWindow\Run.png" />
|
||||
<None Remove="Windows\MainWindow\ScaleX.png" />
|
||||
<None Remove="Windows\MainWindow\ScaleY.png" />
|
||||
<None Remove="Windows\MainWindow\Slab32.png" />
|
||||
<None Remove="Windows\MainWindow\ToBackground.png" />
|
||||
<None Remove="Windows\MainWindow\ToForeground.png" />
|
||||
<None Remove="Windows\MainWindow\Tools_Settings.png" />
|
||||
<None Remove="Windows\MainWindow\Tree.png" />
|
||||
<None Remove="Windows\MainWindow\СarbonMaterial32.png" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -94,6 +103,8 @@
|
||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_1.png" />
|
||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_graph_2.png" />
|
||||
<Resource Include="Windows\CalculationWindows\CalculatorsViews\ForceCalculatorViews\32px_interpolation_1_1.png" />
|
||||
<Resource Include="Windows\MainWindow\AddFormula.png" />
|
||||
<Resource Include="Windows\MainWindow\AddTable.png" />
|
||||
<Resource Include="Windows\MainWindow\Analysis32.png" />
|
||||
<Resource Include="Windows\MainWindow\Beam32.png" />
|
||||
<Resource Include="Windows\MainWindow\Calculator32.png" />
|
||||
@@ -104,19 +115,26 @@
|
||||
<Resource Include="Windows\MainWindow\Delete.png" />
|
||||
<Resource Include="Windows\MainWindow\Edit.png" />
|
||||
<Resource Include="Windows\MainWindow\ElasticMaterial32.png" />
|
||||
<Resource Include="Windows\MainWindow\GetY.png" />
|
||||
<Resource Include="Windows\MainWindow\GlassMaterial32.png" />
|
||||
<Resource Include="Windows\MainWindow\LimX.png" />
|
||||
<Resource Include="Windows\MainWindow\LimY.png" />
|
||||
<Resource Include="Windows\MainWindow\Materials32.png" />
|
||||
<Resource Include="Windows\MainWindow\MovePrimitivesToCenter.png" />
|
||||
<Resource Include="Windows\MainWindow\Point32.png" />
|
||||
<Resource Include="Windows\MainWindow\Rebar32.png" />
|
||||
<Resource Include="Windows\MainWindow\Rectangle32.png" />
|
||||
<Resource Include="Windows\MainWindow\RectangleColumn32.png" />
|
||||
<Resource Include="Windows\MainWindow\FunctionMaterial.png" />
|
||||
<Resource Include="Windows\MainWindow\RFMaterial32.png" />
|
||||
<Resource Include="Windows\MainWindow\Run.png" />
|
||||
<Resource Include="Windows\MainWindow\ScaleX.png" />
|
||||
<Resource Include="Windows\MainWindow\ScaleY.png" />
|
||||
<Resource Include="Windows\MainWindow\Slab32.png" />
|
||||
<Resource Include="Windows\MainWindow\ToBackground.png" />
|
||||
<Resource Include="Windows\MainWindow\ToForeground.png" />
|
||||
<Resource Include="Windows\MainWindow\Tools_Settings.png" />
|
||||
<Resource Include="Windows\MainWindow\Tree.png" />
|
||||
<Resource Include="Windows\MainWindow\СarbonMaterial32.png" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -57,6 +57,15 @@
|
||||
<Compile Update="Windows\Graphs\GraphView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\MainGraph\FormulaView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\MainGraph\TableView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\MainGraph\GraphView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\MainWindow\AboutView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -78,6 +87,21 @@
|
||||
<Compile Update="Windows\Services\CopyByParameterView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\TreeGraph\GetValueView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\TreeGraph\LimView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\TreeGraph\RenameView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\TreeGraph\ScaleView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\TreeGraph\TreeGraphView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\UserControls\MultiplyDouble.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -155,6 +179,15 @@
|
||||
<Page Update="Windows\Graphs\GraphView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\MainGraph\FormulaView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\MainGraph\TableView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\MainGraph\GraphView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\MainWindow\AboutView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@@ -176,6 +209,18 @@
|
||||
<Page Update="Windows\Services\CopyByParameterView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\TreeGraph\LimView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\TreeGraph\RenameView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\TreeGraph\ScaleView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\TreeGraph\TreeGraphView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\UserControls\MultiplyDouble.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace StructureHelper.Windows.Graphs
|
||||
lineSeries.LineSmoothness = visualProps.LineSmoothness;
|
||||
lineSeries.PointGeometry = DefaultGeometries.Circle;
|
||||
lineSeries.PointGeometrySize = visualProps.StrokeSize;
|
||||
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.Black;
|
||||
Color lineColor = (lineSeries.Stroke as SolidColorBrush)?.Color ?? Colors.LightGray;
|
||||
//lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||
lineSeries.Fill = new SolidColorBrush(lineColor) { Opacity = visualProps.Opacity };
|
||||
|
||||
|
||||
@@ -131,8 +131,6 @@ namespace StructureHelper.Windows.Graphs
|
||||
VisualProps = new();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void DrawSeries()
|
||||
{
|
||||
SetLines();
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace StructureHelper.Windows.Graphs
|
||||
OnPropertyChanged(nameof(Opacity));
|
||||
}
|
||||
}
|
||||
|
||||
public GraphVisualProps()
|
||||
{
|
||||
MaxLineSmoothness = 1d;
|
||||
|
||||
@@ -7,6 +7,7 @@ using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
206
StructureHelper/Windows/MainGraph/FormulaView.xaml
Normal file
@@ -0,0 +1,206 @@
|
||||
<Window x:Class="StructureHelper.Windows.MainGraph.FormulaView"
|
||||
x:Name="FormulaFunction_win"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
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.MainGraph"
|
||||
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:FormulaViewModel}"
|
||||
Title="FormulaFunction" Height="640" Width="400">
|
||||
<Window.Resources>
|
||||
<ObjectDataProvider x:Key="PurposeEnum" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="ens:FunctionPurpose"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="150"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Formula:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="y(x) ="
|
||||
Margin="5"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding Formula, UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="5"
|
||||
Background="LightYellow"
|
||||
Text="{Binding FormulaText, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Center"
|
||||
FontSize="20"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.ColumnSpan="3"
|
||||
Margin="5"
|
||||
Text="Enter limit bounds:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Text="{Binding X}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Text="{Binding GREATER}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="2"
|
||||
Grid.Row="1"
|
||||
Text="{Binding LeftBound,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
StringFormat=\{0:n\}}"
|
||||
Margin="5"/>
|
||||
<TextBlock Grid.Column="0"
|
||||
Grid.Row="2"
|
||||
Text="{Binding X}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="2"
|
||||
Text="{Binding LESS}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="2"
|
||||
Grid.Row="2"
|
||||
Text="{Binding RightBound,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
StringFormat=\{0:n\}}"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="5"
|
||||
Background="LightYellow"
|
||||
Text="{Binding LimitText, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Center"
|
||||
FontSize="20"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Step:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="1" Text="{Binding Step}" Margin="5"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Name:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Purpose:"
|
||||
VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Row="1"
|
||||
Margin="5"
|
||||
ItemsSource="{Binding Source={StaticResource PurposeEnum}}"
|
||||
SelectedItem="{Binding FunctionPurpose}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="6">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Description:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="1" Text="{Binding Description}" Margin="5"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="7">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Color:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Button Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5,5,5,5"
|
||||
Command="{Binding EditColorCommand}"
|
||||
Content="Press to change color">
|
||||
</Button>
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="5,5,5,5">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<Button Grid.Row="8" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding ElementName=FormulaFunction_win}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
StructureHelper/Windows/MainGraph/FormulaView.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.MainGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FormulaView.xaml
|
||||
/// </summary>
|
||||
public partial class FormulaView : Window
|
||||
{
|
||||
public FormulaView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
205
StructureHelper/Windows/MainGraph/FormulaViewModel.cs
Normal file
@@ -0,0 +1,205 @@
|
||||
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelper.Windows.MainGraph
|
||||
{
|
||||
public class FormulaViewModel : ViewModelBase
|
||||
{
|
||||
private const string ERROR_BOUNDS = "The left bound must be less than the right bound";
|
||||
private const string ERROR_STEP = "The number of steps should not be more than";
|
||||
private const string DEFAULT_NAME = "Put function name here...";
|
||||
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
||||
private const string DEFAULT_FORMULA = "x^2";
|
||||
private const double DEFAULT_LEFT_BOUND = 1;
|
||||
private const double DEFAULT_RIGHT_BOUND = 1000;
|
||||
private const int DEFAULT_STEP = 100;
|
||||
private const int MAX_STEP = 1000;
|
||||
public char GREATER { get; } = '\u2265';
|
||||
public char LESS { get; } = '\u2264';
|
||||
public char X { get; } = 'x';
|
||||
private RelayCommand saveCommand;
|
||||
private RelayCommand editColor;
|
||||
public int Step { get; set; }
|
||||
private double leftBound;
|
||||
public double LeftBound
|
||||
{
|
||||
get => leftBound;
|
||||
set
|
||||
{
|
||||
leftBound = value;
|
||||
LimitText = $"x\u2208[{value};{RightBound}]";
|
||||
OnPropertyChanged(nameof(LeftBound));
|
||||
}
|
||||
}
|
||||
private double rightBound;
|
||||
public double RightBound
|
||||
{
|
||||
get => rightBound;
|
||||
set
|
||||
{
|
||||
rightBound = value;
|
||||
LimitText = $"x\u2208[{LeftBound};{value}]";
|
||||
OnPropertyChanged(nameof(RightBound));
|
||||
}
|
||||
}
|
||||
public ObservableCollection<Color> Colors { get; set; }
|
||||
public ICommand EditColorCommand
|
||||
{
|
||||
get => editColor ??= new RelayCommand(o => EditColor());
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
}
|
||||
private string formula;
|
||||
public string Formula
|
||||
{
|
||||
get => formula;
|
||||
set
|
||||
{
|
||||
formula = value;
|
||||
FormulaText = $"y(x)={Formula}";
|
||||
OnPropertyChanged(nameof(Formula));
|
||||
}
|
||||
}
|
||||
private string formulaText = "y(x)=";
|
||||
public string FormulaText
|
||||
{
|
||||
get => formulaText;
|
||||
set
|
||||
{
|
||||
formulaText = value;
|
||||
OnPropertyChanged(nameof(FormulaText));
|
||||
}
|
||||
}
|
||||
private IOneVariableFunction function;
|
||||
public IOneVariableFunction Function
|
||||
{
|
||||
get => function;
|
||||
set
|
||||
{
|
||||
function = value;
|
||||
}
|
||||
}
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get => name;
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
private FunctionPurpose functionPurpose;
|
||||
public FunctionPurpose FunctionPurpose
|
||||
{
|
||||
get => functionPurpose;
|
||||
set
|
||||
{
|
||||
functionPurpose = value;
|
||||
}
|
||||
}
|
||||
private string description;
|
||||
public string Description
|
||||
{
|
||||
get => description;
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
}
|
||||
}
|
||||
private Color color;
|
||||
public Color Color
|
||||
{
|
||||
get => color;
|
||||
set
|
||||
{
|
||||
color = value;
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
private string limitText;
|
||||
public string LimitText
|
||||
{
|
||||
get => limitText;
|
||||
set
|
||||
{
|
||||
limitText = value;
|
||||
OnPropertyChanged(nameof(LimitText));
|
||||
}
|
||||
}
|
||||
public FormulaViewModel()
|
||||
{
|
||||
Name = DEFAULT_NAME;
|
||||
Description = DEFAULT_DESCRIPTION;
|
||||
Step = DEFAULT_STEP;
|
||||
LeftBound = DEFAULT_LEFT_BOUND;
|
||||
RightBound = DEFAULT_RIGHT_BOUND;
|
||||
LimitText = $"x\u2208[{LeftBound};{RightBound}]";
|
||||
Color = Brushes.Red.Color;
|
||||
}
|
||||
public FormulaViewModel(FormulaFunction formulaFunction)
|
||||
{
|
||||
Function = formulaFunction;
|
||||
Formula = formulaFunction.Formula;
|
||||
Step = formulaFunction.Step;
|
||||
Name = Function.Name;
|
||||
FunctionPurpose = Function.FunctionPurpose;
|
||||
Description = Function.Description;
|
||||
LeftBound = Function.MinArg;
|
||||
RightBound = Function.MaxArg;
|
||||
Color = Function.Color;
|
||||
}
|
||||
private void EditColor()
|
||||
{
|
||||
Color color = new Color();
|
||||
ColorProcessor.EditColor(ref color);
|
||||
Color = color;
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
if (Function is null)
|
||||
{
|
||||
Function = new FormulaFunction(isUser: true);
|
||||
}
|
||||
Function.Name = Name;
|
||||
Function.FullName = Name;
|
||||
Function.Description = Description;
|
||||
Function.IsUser = true;
|
||||
(Function as FormulaFunction).Step = Step;
|
||||
(Function as FormulaFunction).Formula = Formula;
|
||||
Function.Color = Color;
|
||||
Function.MinArg = LeftBound;
|
||||
Function.MaxArg = RightBound;
|
||||
Function.FunctionPurpose = FunctionPurpose;
|
||||
var window = parameter as Window;
|
||||
if (LeftBound > RightBound)
|
||||
{
|
||||
MessageBox.Show($"{ERROR_BOUNDS}");
|
||||
return;
|
||||
}
|
||||
if (Step > MAX_STEP)
|
||||
{
|
||||
MessageBox.Show($"{ERROR_STEP} {MAX_STEP}");
|
||||
return;
|
||||
}
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
183
StructureHelper/Windows/MainGraph/GraphView.xaml
Normal file
@@ -0,0 +1,183 @@
|
||||
<Window x:Class="StructureHelper.Windows.MainGraph.GraphView"
|
||||
x:Name="GraphView_win"
|
||||
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:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.MainGraph"
|
||||
Loaded="Window_Loaded"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:GraphViewModel}"
|
||||
Title="StructureHelper" Height="700"
|
||||
Width="1000"
|
||||
MinHeight="400"
|
||||
MinWidth="600">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="170"/>
|
||||
<RowDefinition Height="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListView Name="FunctionList"
|
||||
Grid.Row="0" Grid.Column="0" Margin="5"
|
||||
ItemsSource="{Binding Functions, UpdateSourceTrigger=PropertyChanged}"
|
||||
SelectedItem="{Binding SelectedFuntion, UpdateSourceTrigger=PropertyChanged}">
|
||||
<ListView.GroupStyle>
|
||||
<GroupStyle>
|
||||
<GroupStyle.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
|
||||
</DataTemplate>
|
||||
</GroupStyle.HeaderTemplate>
|
||||
<GroupStyle.ContainerStyle>
|
||||
<Style TargetType="{x:Type GroupItem}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate>
|
||||
<Expander IsExpanded="True">
|
||||
<Expander.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold"
|
||||
Foreground="DarkSlateBlue"
|
||||
VerticalAlignment="Bottom"/>
|
||||
<TextBlock Text=": " FontWeight="Bold"
|
||||
Foreground="DarkSlateBlue"
|
||||
VerticalAlignment="Bottom"/>
|
||||
<TextBlock Text="{Binding ItemCount}" FontWeight="Bold"
|
||||
Foreground="Gray"
|
||||
VerticalAlignment="Bottom" />
|
||||
</StackPanel>
|
||||
</Expander.Header>
|
||||
<ItemsPresenter/>
|
||||
</Expander>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</GroupStyle.ContainerStyle>
|
||||
</GroupStyle>
|
||||
</ListView.GroupStyle>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Rectangle
|
||||
Margin="1,1,1,1"
|
||||
Height="15"
|
||||
Width="30">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Path=Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
<TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Add table"
|
||||
Command="{Binding AddTableCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/AddTable.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Add formula"
|
||||
Command="{Binding AddFormulaCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Addformula.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Edit"
|
||||
Command="{Binding EditCommand}"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Copy"
|
||||
Command="{Binding CopyCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Delete"
|
||||
Command="{Binding DeleteCommand}"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Tree"
|
||||
Command="{Binding TreeCommand}"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Tree.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</ListView.ContextMenu>
|
||||
</ListView>
|
||||
<ContentControl Grid.Row="1"
|
||||
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
|
||||
Content="{Binding VisualProps}"/>
|
||||
<Grid Grid.Row="2" Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Column="0" Grid.Row="0" Margin="5" Content="Add table"
|
||||
Command="{Binding AddTableCommand}"
|
||||
Background="LightGreen"/>
|
||||
<Button Grid.Column="0" Grid.Row="1" Margin="5" Content="Add formula"
|
||||
Command="{Binding AddFormulaCommand}"
|
||||
Background="LightGreen"/>
|
||||
<Button Grid.Column="1" Grid.Row="0" Margin="5" Content="Edit"
|
||||
Command="{Binding EditCommand}"
|
||||
CommandParameter="{Binding ElementName=GraphView_win}"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="LightYellow"/>
|
||||
<Button Grid.Column="1" Grid.Row="1" Margin="5" Content="Delete"
|
||||
Command="{Binding DeleteCommand}"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||
Background="LightPink"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" Margin="5" Content="Copy"
|
||||
Command="{Binding CopyCommand}"
|
||||
Background="LightBlue"/>
|
||||
<Button Grid.Column="2" Grid.Row="1" Margin="5" Content="Tree"
|
||||
IsEnabled="{Binding SelectedFuntion.IsUser, UpdateSourceTrigger=PropertyChanged}"
|
||||
Command="{Binding TreeCommand}"
|
||||
Background="AntiqueWhite"/>
|
||||
</Grid>
|
||||
<lvc:CartesianChart Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"
|
||||
Series="{Binding SeriesCollection, UpdateSourceTrigger=PropertyChanged}" Margin="5"
|
||||
Zoom="Xy">
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Y"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="X" Labels="{Binding Labels, UpdateSourceTrigger=PropertyChanged}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
</lvc:CartesianChart>
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="70"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" Text="Description:" Margin="5"/>
|
||||
<TextBlock Grid.Row="1"
|
||||
Name="DescriptionTextBlock"
|
||||
Text="{Binding SelectedFuntion.Description}"
|
||||
Margin="5" TextWrapping="Wrap"
|
||||
VerticalAlignment="Center" Height="60"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
50
StructureHelper/Windows/MainGraph/GraphView.xaml.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelper.Windows.ViewModels.Materials;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Graphs;
|
||||
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.MainGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for GraphView.xaml
|
||||
/// </summary>
|
||||
public partial class GraphView : Window
|
||||
{
|
||||
private const string GROUP_FACTOR = "Group";
|
||||
private GraphViewModel viewModel;
|
||||
public GraphView(GraphViewModel viewModel)
|
||||
{
|
||||
this.viewModel = viewModel;
|
||||
DataContext = this.viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
public GraphView() : this(new GraphViewModel())
|
||||
{
|
||||
}
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(FunctionList.ItemsSource);
|
||||
PropertyGroupDescription groupDescription = new PropertyGroupDescription(GROUP_FACTOR);
|
||||
view.GroupDescriptions.Clear();
|
||||
view.GroupDescriptions.Add(groupDescription);
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
FunctionList.Items.Refresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
232
StructureHelper/Windows/MainGraph/GraphViewModel.cs
Normal file
@@ -0,0 +1,232 @@
|
||||
using LiveCharts;
|
||||
using LiveCharts.Wpf;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
using StructureHelper.Windows.TreeGraph;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperLogics.Models.Graphs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelper.Windows.MainGraph
|
||||
{
|
||||
public class GraphViewModel : ViewModelBase
|
||||
{
|
||||
private LineSeries lineSeries;
|
||||
private SeriesCollection seriesCollection;
|
||||
private List<string> labels;
|
||||
private GraphVisualProps visualProps = new();
|
||||
public LineSeries LineSeries
|
||||
{
|
||||
get => lineSeries;
|
||||
set
|
||||
{
|
||||
lineSeries = value;
|
||||
OnPropertyChanged(nameof(lineSeries));
|
||||
}
|
||||
}
|
||||
public SeriesCollection SeriesCollection
|
||||
{
|
||||
get => seriesCollection;
|
||||
set
|
||||
{
|
||||
seriesCollection = value;
|
||||
OnPropertyChanged(nameof(SeriesCollection));
|
||||
}
|
||||
}
|
||||
public List<string> Labels
|
||||
{
|
||||
get => labels;
|
||||
set
|
||||
{
|
||||
labels = value;
|
||||
OnPropertyChanged(nameof(labels));
|
||||
}
|
||||
}
|
||||
public GraphVisualProps VisualProps
|
||||
{
|
||||
get => visualProps;
|
||||
set
|
||||
{
|
||||
visualProps = value;
|
||||
DrawGraph();
|
||||
}
|
||||
}
|
||||
private IOneVariableFunction selectedFunction;
|
||||
public IOneVariableFunction SelectedFuntion
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedFunction;
|
||||
}
|
||||
set
|
||||
{
|
||||
selectedFunction = value;
|
||||
DrawGraph();
|
||||
OnPropertyChanged(nameof(SelectedFuntion));
|
||||
}
|
||||
}
|
||||
private ObservableCollection<IOneVariableFunction> functions;
|
||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||
|
||||
private RelayCommand addTableCommand;
|
||||
private RelayCommand addFormulaCommand;
|
||||
private RelayCommand editCommand;
|
||||
private RelayCommand deleteCommand;
|
||||
private RelayCommand copyCommand;
|
||||
private RelayCommand treeCommand;
|
||||
private RelayCommand drawGraphCommand;
|
||||
private RelayCommand _saveCommand;
|
||||
public ICommand AddTableCommand
|
||||
{
|
||||
get => addTableCommand ??= new RelayCommand(o => AddTable());
|
||||
}
|
||||
public ICommand AddFormulaCommand
|
||||
{
|
||||
get => addFormulaCommand ??= new RelayCommand(o => AddFormula());
|
||||
}
|
||||
public ICommand EditCommand
|
||||
{
|
||||
get => editCommand ??= new RelayCommand(o => Edit(o));
|
||||
}
|
||||
public ICommand DeleteCommand
|
||||
{
|
||||
get => deleteCommand ??= new RelayCommand(o => Delete());
|
||||
}
|
||||
public ICommand CopyCommand
|
||||
{
|
||||
get => copyCommand ??= new RelayCommand(o => Copy());
|
||||
}
|
||||
public ICommand TreeCommand
|
||||
{
|
||||
get => treeCommand ??= new RelayCommand(o => Tree());
|
||||
}
|
||||
public ICommand DrawGraphCommand
|
||||
{
|
||||
get => drawGraphCommand ??= new RelayCommand(o => DrawGraph());
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => _saveCommand ??= new RelayCommand(o => Save());
|
||||
}
|
||||
public GraphViewModel()
|
||||
{
|
||||
Functions = new ObservableCollection<IOneVariableFunction>(ProgramSetting.Functions);
|
||||
}
|
||||
private void AddTable()
|
||||
{
|
||||
var tableViewModel = new TableViewModel();
|
||||
var tableView = new TableView();
|
||||
tableView.DataContext = tableViewModel;
|
||||
if (tableView.ShowDialog() == true)
|
||||
{
|
||||
Functions.Add(tableViewModel.Function);
|
||||
SelectedFuntion = tableViewModel.Function;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void AddFormula()
|
||||
{
|
||||
var formulaViewModel = new FormulaViewModel();
|
||||
var formulaView = new FormulaView();
|
||||
formulaView.DataContext = formulaViewModel;
|
||||
if (formulaView.ShowDialog() == true)
|
||||
{
|
||||
Functions.Add(formulaViewModel.Function);
|
||||
SelectedFuntion = formulaViewModel.Function;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Edit(object parameter)
|
||||
{
|
||||
if (SelectedFuntion is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SelectedFuntion.Type == FunctionType.TableFunction)
|
||||
{
|
||||
var tableViewModel = new TableViewModel(SelectedFuntion as TableFunction);
|
||||
var tableView = new TableView();
|
||||
tableView.DataContext = tableViewModel;
|
||||
tableView.ShowDialog();
|
||||
SelectedFuntion = tableViewModel.Function;
|
||||
}
|
||||
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
||||
{
|
||||
var formulaViewModel = new FormulaViewModel(SelectedFuntion as FormulaFunction);
|
||||
var formulaView = new FormulaView();
|
||||
formulaView.DataContext = formulaViewModel;
|
||||
formulaView.ShowDialog();
|
||||
SelectedFuntion = formulaViewModel.Function;
|
||||
}
|
||||
var graphView = parameter as GraphView;
|
||||
graphView.Refresh();
|
||||
Save();
|
||||
}
|
||||
private void Delete()
|
||||
{
|
||||
if (SelectedFuntion is null)
|
||||
{
|
||||
var lastFunction = Functions[Functions.Count - 1];
|
||||
if (lastFunction.IsUser)
|
||||
{
|
||||
Functions.Remove(lastFunction);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Functions.Remove(SelectedFuntion);
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Copy()
|
||||
{
|
||||
if (SelectedFuntion is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (SelectedFuntion.Type == FunctionType.TableFunction)
|
||||
{
|
||||
Functions.Add(SelectedFuntion.Clone() as TableFunction);
|
||||
}
|
||||
else if (SelectedFuntion.Type == FunctionType.FormulaFunction)
|
||||
{
|
||||
Functions.Add(SelectedFuntion.Clone() as FormulaFunction);
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Tree()
|
||||
{
|
||||
if (SelectedFuntion is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var treeGraphVM = new TreeGraphViewModel(SelectedFuntion);
|
||||
var treeGraph = new TreeGraphView();
|
||||
treeGraph.DataContext = treeGraphVM;
|
||||
treeGraphVM.TreeGraphView_win = treeGraph;
|
||||
treeGraph.ShowDialog();
|
||||
}
|
||||
private void DrawGraph()
|
||||
{
|
||||
var graphSettings = SelectedFuntion.GetGraphSettings();
|
||||
Labels = graphSettings.GetLabels();
|
||||
LineSeries = graphSettings.GetLineSeries();
|
||||
GraphService.SetVisualProps(LineSeries, VisualProps);
|
||||
SeriesCollection = new SeriesCollection();
|
||||
SeriesCollection.Add(LineSeries);
|
||||
Save();
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
ProgramSetting.Functions = new List<IOneVariableFunction>(Functions);
|
||||
}
|
||||
}
|
||||
}
|
||||
168
StructureHelper/Windows/MainGraph/TableView.xaml
Normal file
@@ -0,0 +1,168 @@
|
||||
<Window x:Class="StructureHelper.Windows.MainGraph.TableView"
|
||||
x:Name="TableFunction_win"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
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.MainGraph"
|
||||
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums;assembly=StructureHelperCommon"
|
||||
mc:Ignorable="d"
|
||||
ResizeMode="CanResize"
|
||||
d:DataContext="{d:DesignInstance local:TableViewModel}"
|
||||
Title="TableFunction" Height="620" Width="400"
|
||||
MaxWidth="400"
|
||||
MinWidth="400">
|
||||
<Window.Resources>
|
||||
<ObjectDataProvider x:Key="PurposeEnum" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="ens:FunctionPurpose"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Column="0" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="37"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="150"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle Grid.Column="1"
|
||||
Grid.Row="0"
|
||||
Stroke="Gray"/>
|
||||
<Rectangle Grid.Column="2"
|
||||
Grid.Row="0"
|
||||
Stroke="Gray"/>
|
||||
<TextBlock Grid.Column="0">
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="1"
|
||||
HorizontalAlignment="Center"
|
||||
Text="X">
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="2"
|
||||
HorizontalAlignment="Center"
|
||||
Text="Y">
|
||||
</TextBlock>
|
||||
<TextBlock Grid.Column="3">
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<ListBox Grid.Row="1" Margin="5"
|
||||
ItemsSource="{Binding Table,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
Mode=TwoWay}"
|
||||
SelectedItem="{Binding SelectedPoint}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Width="30"
|
||||
MaxWidth="30">
|
||||
</TextBlock>
|
||||
<TextBox Text="{Binding X}"
|
||||
Width="150"
|
||||
MaxWidth="150">
|
||||
</TextBox>
|
||||
<TextBox Text="{Binding Y}"
|
||||
Width="150"
|
||||
MaxWidth="150">
|
||||
</TextBox>
|
||||
<TextBlock Width="25"
|
||||
MaxWidth="25">
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="1" Margin="5" Content="Add"
|
||||
Background="LightGreen" Command="{Binding AddPointCommand}"/>
|
||||
<Button Grid.Column="2" Margin="5" Content="Delete"
|
||||
Background="LightPink" Command="{Binding DeletePointCommand}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Name:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="1" Text="{Binding Name}" Margin="5"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="4">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Purpose:"
|
||||
VerticalAlignment="Center"/>
|
||||
<ComboBox Grid.Row="1"
|
||||
Margin="5"
|
||||
ItemsSource="{Binding Source={StaticResource PurposeEnum}}"
|
||||
SelectedItem="{Binding FunctionPurpose}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Description:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBox Grid.Row="1" Text="{Binding Description}" Margin="5"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="6">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Color:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Button Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5,5,5,5"
|
||||
Command="{Binding EditColorCommand}"
|
||||
Content="Press to change color">
|
||||
</Button>
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="5,5,5,5">
|
||||
<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Rectangle.Fill>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<Button Grid.Row="7" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding ElementName=TableFunction_win}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
39
StructureHelper/Windows/MainGraph/TableView.xaml.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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.MainGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AddTable.xaml
|
||||
/// </summary>
|
||||
public partial class TableView : Window
|
||||
{
|
||||
private TableViewModel viewModel;
|
||||
|
||||
public TableView(TableViewModel viewModel)
|
||||
{
|
||||
this.viewModel = viewModel;
|
||||
DataContext = this.viewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
/*public AddTable() : this(new AddTableViewModel())
|
||||
{
|
||||
}*/
|
||||
public TableView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
183
StructureHelper/Windows/MainGraph/TableViewModel.cs
Normal file
@@ -0,0 +1,183 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelper.Windows.MainGraph
|
||||
{
|
||||
public class TableViewModel : ViewModelBase
|
||||
{
|
||||
private const string DEFAULT_NAME = "Put function name here...";
|
||||
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
||||
private RelayCommand saveCommand;
|
||||
private RelayCommand addPointCommand;
|
||||
private RelayCommand deletePointCommand;
|
||||
private RelayCommand editColor;
|
||||
public ICommand EditColorCommand
|
||||
{
|
||||
get => editColor ??= new RelayCommand(o => EditColor());
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
}
|
||||
public ICommand AddPointCommand
|
||||
{
|
||||
get => addPointCommand ??= new RelayCommand(o => AddPoint());
|
||||
}
|
||||
public ICommand DeletePointCommand
|
||||
{
|
||||
get => deletePointCommand ??= new RelayCommand(o => DeletePoint());
|
||||
}
|
||||
|
||||
private ObservableCollection<GraphPoint> table;
|
||||
|
||||
public ObservableCollection<GraphPoint> Table
|
||||
{
|
||||
get => table;
|
||||
set
|
||||
{
|
||||
table = value;
|
||||
}
|
||||
}
|
||||
private GraphPoint selectedPoint;
|
||||
public GraphPoint SelectedPoint
|
||||
{
|
||||
get => selectedPoint;
|
||||
set
|
||||
{
|
||||
selectedPoint = value;
|
||||
OnPropertyChanged(nameof(SelectedPoint));
|
||||
}
|
||||
}
|
||||
private IOneVariableFunction function;
|
||||
public IOneVariableFunction Function
|
||||
{
|
||||
get => function;
|
||||
set
|
||||
{
|
||||
function = value;
|
||||
}
|
||||
}
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get => name;
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
private FunctionPurpose functionPurpose;
|
||||
public FunctionPurpose FunctionPurpose
|
||||
{
|
||||
get => functionPurpose;
|
||||
set
|
||||
{
|
||||
functionPurpose = value;
|
||||
}
|
||||
}
|
||||
private string description;
|
||||
public string Description
|
||||
{
|
||||
get => description;
|
||||
set
|
||||
{
|
||||
description = value;
|
||||
}
|
||||
}
|
||||
private Color color;
|
||||
public Color Color
|
||||
{
|
||||
get => color;
|
||||
set
|
||||
{
|
||||
color = value;
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
public TableViewModel()
|
||||
{
|
||||
Table = new ObservableCollection<GraphPoint>()
|
||||
{
|
||||
new GraphPoint(0, 0),
|
||||
new GraphPoint(0, 0),
|
||||
};
|
||||
Name = DEFAULT_NAME;
|
||||
Description = DEFAULT_DESCRIPTION;
|
||||
Color = Brushes.Red.Color;
|
||||
}
|
||||
public TableViewModel(TableFunction tableFunction)
|
||||
{
|
||||
Function = tableFunction;
|
||||
Table = new ObservableCollection<GraphPoint>((Function as TableFunction).Table);
|
||||
Name = Function.Name;
|
||||
FunctionPurpose = Function.FunctionPurpose;
|
||||
Description = Function.Description;
|
||||
Color = Function.Color;
|
||||
}
|
||||
private void EditColor()
|
||||
{
|
||||
Color color = new Color();
|
||||
ColorProcessor.EditColor(ref color);
|
||||
Color = color;
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
if (Function is null)
|
||||
{
|
||||
Function = new TableFunction(isUser: true);
|
||||
}
|
||||
Function.Name = Name;
|
||||
Function.FullName = Name;
|
||||
Function.Description = Description;
|
||||
Function.IsUser = true;
|
||||
(Function as TableFunction).Table = Table.OrderBy(x => x.X).ToList();
|
||||
Function.Color = Color;
|
||||
Function.FunctionPurpose = FunctionPurpose;
|
||||
var window = parameter as Window;
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
private void AddPoint()
|
||||
{
|
||||
var point = new GraphPoint(0, 0);
|
||||
if (SelectedPoint is null)
|
||||
{
|
||||
Table.Add(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
var selectedPointIndex = Table.IndexOf(SelectedPoint);
|
||||
Table.Insert(selectedPointIndex + 1, point);
|
||||
}
|
||||
}
|
||||
private void DeletePoint()
|
||||
{
|
||||
if (Table.Count < 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SelectedPoint is null)
|
||||
{
|
||||
Table.RemoveAt(Table.Count - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Table.Remove(SelectedPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
StructureHelper/Windows/MainWindow/AddFormula.png
Normal file
|
After Width: | Height: | Size: 318 B |
BIN
StructureHelper/Windows/MainWindow/AddTable.png
Normal file
|
After Width: | Height: | Size: 246 B |
@@ -1,8 +1,10 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
using StructureHelper.Windows.MainWindow.Analyses;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Editors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -17,6 +19,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public class AnalysesLogic : ViewModelBase
|
||||
{
|
||||
private RelayCommand? addAnalyisCommand;
|
||||
private RelayCommand? addEditorCommand;
|
||||
private RelayCommand? runCommand;
|
||||
private RelayCommand? editCommand;
|
||||
private RelayCommand? deleteCommand;
|
||||
@@ -35,6 +38,17 @@ namespace StructureHelper.Windows.MainWindow
|
||||
});
|
||||
}
|
||||
}
|
||||
public RelayCommand AddGraphEditorCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return addEditorCommand ??= new RelayCommand(obj =>
|
||||
{
|
||||
AddGraphEditor();
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
public RelayCommand RunCommand
|
||||
{
|
||||
get
|
||||
@@ -124,5 +138,15 @@ namespace StructureHelper.Windows.MainWindow
|
||||
var visualAnalysis = new VisualAnalysis(analysis);
|
||||
ProgramSetting.CurrentProject.VisualAnalyses.Add(visualAnalysis);
|
||||
}
|
||||
private void AddGraphEditor()
|
||||
{
|
||||
var graphView = new MainGraph.GraphView();
|
||||
graphView.ShowDialog();
|
||||
/*var editor = new GraphEditorAnalysis(); //Код, который встраивал графики в "проигрыватель"
|
||||
editor.Name = "New Graph Editor";
|
||||
editor.Tags = "#New group";
|
||||
var visualAnalysis = new VisualAnalysis(editor);
|
||||
ProgramSetting.CurrentProject.VisualAnalyses.Add(visualAnalysis);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelper.Windows.MainGraph;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Graphs;
|
||||
using System;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow.Analyses
|
||||
@@ -35,6 +37,10 @@ namespace StructureHelper.Windows.MainWindow.Analyses
|
||||
{
|
||||
ProcessCrossSection(crossSection);
|
||||
}
|
||||
/*else if (version.AnalysisVersion is IGraph graph)
|
||||
{
|
||||
ProcessEditGraph(graph);
|
||||
}*/
|
||||
else
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(version));
|
||||
@@ -46,6 +52,11 @@ namespace StructureHelper.Windows.MainWindow.Analyses
|
||||
var window = new CrossSectionView(crossSection);
|
||||
window.ShowDialog();
|
||||
}
|
||||
/*private void ProcessEditGraph(IGraph graph)
|
||||
{
|
||||
var window = new GraphView(graph);
|
||||
window.ShowDialog();
|
||||
}*/
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</Button>
|
||||
</ToolBar>
|
||||
<ToolBar ToolTip="Diagrams">
|
||||
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" ToolTip="Diagrams">
|
||||
<Button Style="{StaticResource ToolButton}" Command="{Binding AnalysesLogic.AddGraphEditorCommand}" ToolTip="Diagrams">
|
||||
<Viewbox>
|
||||
<ContentControl ContentTemplate="{DynamicResource Diagrams}"/>
|
||||
</Viewbox>
|
||||
|
||||
@@ -160,6 +160,9 @@
|
||||
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.GlassFiber}" ToolTip="Add Glass Fiber Material">
|
||||
<Image Source="/Windows/MainWindow/GlassMaterial32.png"/>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ToolButton}" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Function}" ToolTip="Add Glass Fiber Material">
|
||||
<Image Source="/Windows/MainWindow/FunctionMaterial.png"/>
|
||||
</Button>
|
||||
<Button Style="{StaticResource ToolButton}" Command="{Binding EditMaterialsCommand}" ToolTip="Show Materials">
|
||||
<Image Source="/Windows/MainWindow/Materials32.png"/>
|
||||
</Button>
|
||||
|
||||
@@ -77,7 +77,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public ICommand LeftButtonDown { get; }
|
||||
public ICommand LeftButtonUp { get; }
|
||||
public ICommand MovePrimitiveToGravityCenterCommand { get; }
|
||||
|
||||
public ICommand ClearSelection { get; }
|
||||
public ICommand OpenMaterialCatalog { get; }
|
||||
public ICommand OpenMaterialCatalogWithSelection { get; }
|
||||
|
||||
BIN
StructureHelper/Windows/MainWindow/FunctionMaterial.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
StructureHelper/Windows/MainWindow/GetY.png
Normal file
|
After Width: | Height: | Size: 234 B |
BIN
StructureHelper/Windows/MainWindow/LimX.png
Normal file
|
After Width: | Height: | Size: 303 B |
BIN
StructureHelper/Windows/MainWindow/LimY.png
Normal file
|
After Width: | Height: | Size: 297 B |
BIN
StructureHelper/Windows/MainWindow/ScaleX.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
StructureHelper/Windows/MainWindow/ScaleY.png
Normal file
|
After Width: | Height: | Size: 321 B |
BIN
StructureHelper/Windows/MainWindow/Tree.png
Normal file
|
After Width: | Height: | Size: 318 B |
52
StructureHelper/Windows/TreeGraph/Database.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public static class Database
|
||||
{
|
||||
public static IOneVariableFunction GetFunctionTree()
|
||||
{
|
||||
return new TableFunction()
|
||||
{
|
||||
Name = "func0",
|
||||
Functions = new List<IOneVariableFunction>()
|
||||
{
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func1.1"
|
||||
},
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func1.2"
|
||||
},
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func1.3",
|
||||
Functions = new List<IOneVariableFunction>()
|
||||
{
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func2.1"
|
||||
},
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "func2.2"
|
||||
},
|
||||
}
|
||||
},
|
||||
new TableFunction()
|
||||
{
|
||||
Name = "func1.4"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
76
StructureHelper/Windows/TreeGraph/GetValueView.xaml
Normal file
@@ -0,0 +1,76 @@
|
||||
<Window x:Class="StructureHelper.Windows.TreeGraph.GetValueView"
|
||||
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.TreeGraph"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:GetValueViewModel}"
|
||||
Title="GetY" Height="300" Width="400"
|
||||
MinWidth="400">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="60"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Enter function argument:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="x ="
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding Argument}"
|
||||
Margin="5"/>
|
||||
<Button Grid.Column="2" Margin="5" Content="Get value"
|
||||
Command="{Binding GetValueCommand}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Row="1" Margin="5" >
|
||||
<TextBlock
|
||||
Background="LightYellow"
|
||||
Text="{Binding Trace, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Left"
|
||||
FontFamily="Cascadia Mono"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
</ScrollViewer>
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Function value:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="y(x) ="
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Background="AliceBlue"
|
||||
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
FontWeight="DemiBold"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
StructureHelper/Windows/TreeGraph/GetValueView.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.TreeGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for GetValueView.xaml
|
||||
/// </summary>
|
||||
public partial class GetValueView : Window
|
||||
{
|
||||
public GetValueView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
62
StructureHelper/Windows/TreeGraph/GetValueViewModel.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class GetValueViewModel : ViewModelBase
|
||||
{
|
||||
public IOneVariableFunction function;
|
||||
private double argument;
|
||||
private double value;
|
||||
private string trace = "Press \"Get value\" to calculation...\n\n\n";
|
||||
public IOneVariableFunction Function
|
||||
{
|
||||
get => function;
|
||||
set => function = value;
|
||||
}
|
||||
public double Argument
|
||||
{
|
||||
get => argument;
|
||||
set => argument = value;
|
||||
}
|
||||
public double Value
|
||||
{
|
||||
get => value;
|
||||
set
|
||||
{
|
||||
this.value = value;
|
||||
OnPropertyChanged(nameof(Value));
|
||||
}
|
||||
}
|
||||
public string Trace
|
||||
{
|
||||
get => trace;
|
||||
set
|
||||
{
|
||||
trace = value;
|
||||
OnPropertyChanged(nameof(Trace));
|
||||
}
|
||||
}
|
||||
private RelayCommand _getValueCommand;
|
||||
public ICommand GetValueCommand
|
||||
{
|
||||
get => _getValueCommand ??= new RelayCommand(o => GetValue());
|
||||
}
|
||||
public GetValueViewModel(IOneVariableFunction function)
|
||||
{
|
||||
Function = function;
|
||||
}
|
||||
private void GetValue()
|
||||
{
|
||||
Value = Function.GetByX(Argument);
|
||||
Trace += Function.GetTrace();
|
||||
Trace += "\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
79
StructureHelper/Windows/TreeGraph/LimView.xaml
Normal file
@@ -0,0 +1,79 @@
|
||||
<Window x:Class="StructureHelper.Windows.TreeGraph.LimView"
|
||||
x:Name="LimView_win"
|
||||
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.TreeGraph"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:LimViewModel}"
|
||||
Title="Limit" Height="230" Width="250"
|
||||
MinWidth="250">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="90"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="10"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Row="0" Grid.ColumnSpan="3"
|
||||
Margin="5"
|
||||
Text="Enter limit bounds:"
|
||||
VerticalAlignment="Center"/>
|
||||
<TextBlock Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Text="{Binding X_or_Y_text}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Text="{Binding GREATER}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="2"
|
||||
Grid.Row="1"
|
||||
Text="{Binding LeftBound,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
StringFormat=\{0:n\}}"
|
||||
Margin="5"/>
|
||||
<TextBlock Grid.Column="0"
|
||||
Grid.Row="2"
|
||||
Text="{Binding X_or_Y_text}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Grid.Row="2"
|
||||
Text="{Binding LESS}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="2"
|
||||
Grid.Row="2"
|
||||
Text="{Binding RightBound,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
StringFormat=\{0:n\}}"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="5"
|
||||
Background="LightYellow"
|
||||
Text="{Binding LimitText, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Center"
|
||||
FontSize="20"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
<Button Grid.Row="4" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding ElementName=LimView_win}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
StructureHelper/Windows/TreeGraph/LimView.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.TreeGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LimView.xaml
|
||||
/// </summary>
|
||||
public partial class LimView : Window
|
||||
{
|
||||
public LimView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
92
StructureHelper/Windows/TreeGraph/LimViewModel.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class LimViewModel : ViewModelBase
|
||||
{
|
||||
private bool isArg = false;
|
||||
public char GREATER { get; } = '\u2265';
|
||||
public char LESS { get; } = '\u2264';
|
||||
public char IN { get; } = '\u2208';
|
||||
public char LEFT_BOUND { get; } = '[';
|
||||
public char RIGHT_BOUND { get; } = ']';
|
||||
public char SEMICOLON { get; } = ';';
|
||||
private const string ERROR_BOUNDS = "The left bound must be less than the right bound";
|
||||
private const string X = "x";
|
||||
private const string Y = "y";
|
||||
private string x_or_y_text;
|
||||
private string limitText;
|
||||
private RelayCommand saveCommand;
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
}
|
||||
public string X_or_Y_text
|
||||
{
|
||||
get => x_or_y_text;
|
||||
set => x_or_y_text = value;
|
||||
}
|
||||
public string LimitText
|
||||
{
|
||||
get => limitText;
|
||||
set
|
||||
{
|
||||
limitText = value;
|
||||
OnPropertyChanged(nameof(LimitText));
|
||||
}
|
||||
}
|
||||
private double leftBound;
|
||||
private double rightBound;
|
||||
public double LeftBound
|
||||
{
|
||||
get => leftBound;
|
||||
set
|
||||
{
|
||||
leftBound = value;
|
||||
LimitText = $"{X_or_Y_text}" + $"{IN}" + $"{LEFT_BOUND}" + $"{value}" + $"{SEMICOLON}" + $"{rightBound}" + $"{RIGHT_BOUND}";
|
||||
OnPropertyChanged(nameof(LeftBound));
|
||||
}
|
||||
}
|
||||
public double RightBound
|
||||
{
|
||||
get => rightBound;
|
||||
set
|
||||
{
|
||||
rightBound = value;
|
||||
LimitText = $"{X_or_Y_text}" + $"{IN}" + $"{LEFT_BOUND}" + $"{LeftBound}" + $"{SEMICOLON}" + $"{value}" + $"{RIGHT_BOUND}";
|
||||
OnPropertyChanged(nameof(RightBound));
|
||||
}
|
||||
}
|
||||
public LimViewModel(bool isArg)
|
||||
{
|
||||
this.isArg = isArg;
|
||||
if (isArg)
|
||||
{
|
||||
X_or_Y_text = X;
|
||||
}
|
||||
else
|
||||
{
|
||||
X_or_Y_text = Y;
|
||||
}
|
||||
LimitText = $"{X_or_Y_text}" + $"{IN}" + $"{LEFT_BOUND}" + $"{LeftBound}" + $"{SEMICOLON}" + $"{rightBound}" + $"{RIGHT_BOUND}";
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
var window = parameter as Window;
|
||||
if (LeftBound > RightBound)
|
||||
{
|
||||
MessageBox.Show($"{ERROR_BOUNDS}");
|
||||
return;
|
||||
}
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
51
StructureHelper/Windows/TreeGraph/RenameView.xaml
Normal file
@@ -0,0 +1,51 @@
|
||||
<Window x:Class="StructureHelper.Windows.TreeGraph.RenameView"
|
||||
x:Name="RenameView_win"
|
||||
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.TreeGraph"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:RenameViewModel}"
|
||||
Title="Scale" Height="200" Width="250"
|
||||
MinWidth="250">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Enter new function name:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column="1" Text="{Binding FunctionName,
|
||||
UpdateSourceTrigger=PropertyChanged}"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="5"
|
||||
Background="LightYellow"
|
||||
Text="{Binding FunctionName,
|
||||
UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Center"
|
||||
FontSize="20"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
<Button Grid.Row="4" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding ElementName=RenameView_win}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
27
StructureHelper/Windows/TreeGraph/RenameView.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.TreeGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for RenameView.xaml
|
||||
/// </summary>
|
||||
public partial class RenameView : Window
|
||||
{
|
||||
public RenameView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
42
StructureHelper/Windows/TreeGraph/RenameViewModel.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class RenameViewModel : ViewModelBase
|
||||
{
|
||||
|
||||
private RelayCommand saveCommand;
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
}
|
||||
private string functionName;
|
||||
public string FunctionName
|
||||
{
|
||||
get => functionName;
|
||||
set
|
||||
{
|
||||
functionName = value;
|
||||
OnPropertyChanged(nameof(FunctionName));
|
||||
}
|
||||
}
|
||||
public RenameViewModel(TreeViewItemViewModel item)
|
||||
{
|
||||
FunctionName = item.Name;
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
var window = parameter as Window;
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
StructureHelper/Windows/TreeGraph/ScaleView.xaml
Normal file
@@ -0,0 +1,55 @@
|
||||
<Window x:Class="StructureHelper.Windows.TreeGraph.ScaleView"
|
||||
x:Name="ScaleView_win"
|
||||
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.TreeGraph"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:ScaleViewModel}"
|
||||
Title="Scale" Height="200" Width="250"
|
||||
MinWidth="250">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0"
|
||||
Margin="5"
|
||||
Text="Enter scale factor:"
|
||||
VerticalAlignment="Center"/>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="0" Text="scale factor ="
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding ScaleFactor,
|
||||
UpdateSourceTrigger=PropertyChanged,
|
||||
StringFormat=\{0:n\}}"
|
||||
Margin="5"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="5"
|
||||
Background="LightYellow"
|
||||
Text="{Binding ScaleText,
|
||||
UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Center"
|
||||
FontSize="20"
|
||||
TextWrapping="Wrap">
|
||||
</TextBlock>
|
||||
<Button Grid.Row="4" Margin="5" Content="Save"
|
||||
Command="{Binding SaveCommand}"
|
||||
CommandParameter="{Binding ElementName=ScaleView_win}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
StructureHelper/Windows/TreeGraph/ScaleView.xaml.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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.TreeGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ScaleView.xaml
|
||||
/// </summary>
|
||||
public partial class ScaleView : Window
|
||||
{
|
||||
public ScaleView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
69
StructureHelper/Windows/TreeGraph/ScaleViewModel.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class ScaleViewModel : ViewModelBase
|
||||
{
|
||||
private bool isArg = false;
|
||||
private double scaleFactor;
|
||||
private string scaleText;
|
||||
private const string X_DEFAULT_SCALE_TEXT = "y=f(sx)";
|
||||
private const string Y_DEFAULT_SCALE_TEXT = "y=sf(x)";
|
||||
private RelayCommand saveCommand;
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => saveCommand ??= new RelayCommand(o => Save(o));
|
||||
}
|
||||
public double ScaleFactor
|
||||
{
|
||||
get => scaleFactor;
|
||||
set
|
||||
{
|
||||
scaleFactor = value;
|
||||
if (isArg)
|
||||
{
|
||||
ScaleText = $"y=f({value}x)";
|
||||
}
|
||||
else
|
||||
{
|
||||
ScaleText = $"y={value}f(x)";
|
||||
}
|
||||
OnPropertyChanged(nameof(ScaleFactor));
|
||||
}
|
||||
}
|
||||
public string ScaleText
|
||||
{
|
||||
get => scaleText;
|
||||
set
|
||||
{
|
||||
scaleText = value;
|
||||
OnPropertyChanged(nameof(ScaleText));
|
||||
}
|
||||
}
|
||||
public ScaleViewModel(bool isArg)
|
||||
{
|
||||
this.isArg = isArg;
|
||||
if (isArg)
|
||||
{
|
||||
ScaleText = $"{X_DEFAULT_SCALE_TEXT}";
|
||||
}
|
||||
else
|
||||
{
|
||||
ScaleText= $"{Y_DEFAULT_SCALE_TEXT}";
|
||||
}
|
||||
}
|
||||
private void Save(object parameter)
|
||||
{
|
||||
var window = parameter as Window;
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
172
StructureHelper/Windows/TreeGraph/TreeGraphView.xaml
Normal file
@@ -0,0 +1,172 @@
|
||||
<Window x:Class="StructureHelper.Windows.TreeGraph.TreeGraphView"
|
||||
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:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.TreeGraph"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance local:TreeGraphViewModel}"
|
||||
Title="StructureHelper" Height="750"
|
||||
Width="1000" MinHeight="400" MinWidth="600">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="170"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TreeView Name="FunctionTreeView"
|
||||
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="5"
|
||||
ItemsSource="{Binding Tree}">
|
||||
<TreeView.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type TreeViewItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
|
||||
<Setter Property="FontWeight" Value="Normal" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TreeView.ItemContainerStyle>
|
||||
<TreeView.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.ItemTemplate>
|
||||
<TreeView.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Get Y"
|
||||
Command="{Binding GetYCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/GetY.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Scale X"
|
||||
Command="{Binding ScaleCommand}"
|
||||
CommandParameter="x">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/ScaleX.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Scale Y"
|
||||
Command="{Binding ScaleCommand}"
|
||||
CommandParameter="y">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/ScaleY.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Lim X"
|
||||
Command="{Binding LimitCommand}"
|
||||
CommandParameter="x">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/LimX.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Lim Y"
|
||||
Command="{Binding LimitCommand}"
|
||||
CommandParameter="y">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/LimY.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Delete"
|
||||
Command="{Binding DeleteCommand}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Tree"
|
||||
Command="{Binding TreeCommand}"
|
||||
CommandParameter="{Binding ElementName=FunctionTreeView}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Tree.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Rename"
|
||||
Command="{Binding RenameCommand}"
|
||||
CommandParameter="{Binding ElementName=FunctionTreeView}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Edit.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</TreeView.ContextMenu>
|
||||
</TreeView>
|
||||
<ContentControl Grid.Row="1"
|
||||
ContentTemplate="{StaticResource ResourceKey=LineVisualProperties}"
|
||||
Content="{Binding VisualProps}"/>
|
||||
<Grid Grid.Row="2" Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Column="0" Margin="5" Content="Get Y"
|
||||
Background="Goldenrod"
|
||||
Command="{Binding GetYCommand}"/>
|
||||
<Button Grid.Column="1" Margin="5" Content="ScaleX"
|
||||
Background="Turquoise"
|
||||
Command="{Binding ScaleCommand}"
|
||||
CommandParameter="x"/>
|
||||
<Button Grid.Column="2" Margin="5" Content="ScaleY"
|
||||
Background="Turquoise"
|
||||
Command="{Binding ScaleCommand}"
|
||||
CommandParameter="y"/>
|
||||
<Button Grid.Column="3" Margin="5" Content="limX"
|
||||
Background="DodgerBlue"
|
||||
Command="{Binding LimitCommand}"
|
||||
CommandParameter="x"/>
|
||||
<Button Grid.Column="4" Margin="5" Content="limY"
|
||||
Background="DodgerBlue"
|
||||
Command="{Binding LimitCommand}"
|
||||
CommandParameter="y"/>
|
||||
<Button Grid.Column="6" Margin="5" Content="Delete"
|
||||
Background="LightPink"
|
||||
Command="{Binding DeleteCommand}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="3" Grid.Column="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Column="0" Margin="5" Content="Tree"
|
||||
Background="AntiqueWhite"
|
||||
Command="{Binding TreeCommand}"
|
||||
CommandParameter="{Binding ElementName=FunctionTreeView}"/>
|
||||
<Button Grid.Column="1" Margin="5" Content="Rename"
|
||||
FontSize="10"
|
||||
Background="HotPink"
|
||||
Command="{Binding RenameCommand}"
|
||||
CommandParameter="{Binding ElementName=FunctionTreeView}"/>
|
||||
</Grid>
|
||||
<lvc:CartesianChart Grid.Row="0" Grid.Column="1" Grid.RowSpan="2"
|
||||
Series="{Binding SeriesCollection}" Margin="5"
|
||||
Zoom="Xy">
|
||||
<lvc:CartesianChart.AxisY>
|
||||
<lvc:Axis Title="Y"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisY>
|
||||
<lvc:CartesianChart.AxisX>
|
||||
<lvc:Axis Title="X" Labels="{Binding Labels}"></lvc:Axis>
|
||||
</lvc:CartesianChart.AxisX>
|
||||
</lvc:CartesianChart>
|
||||
</Grid>
|
||||
</Window>
|
||||
28
StructureHelper/Windows/TreeGraph/TreeGraphView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
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.TreeGraph
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TreeGraph.xaml
|
||||
/// </summary>
|
||||
public partial class TreeGraphView : Window
|
||||
{
|
||||
public TreeGraphView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
340
StructureHelper/Windows/TreeGraph/TreeGraphViewModel.cs
Normal file
@@ -0,0 +1,340 @@
|
||||
using LiveCharts.Wpf;
|
||||
using LiveCharts;
|
||||
using NLog.Common;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using StructureHelperCommon.Models.Functions.Decorator;
|
||||
using System.Windows.Media;
|
||||
using StructureHelper.Windows.Graphs;
|
||||
using System.Windows.Controls;
|
||||
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class TreeGraphViewModel : ViewModelBase
|
||||
{
|
||||
private LineSeries lineSeries;
|
||||
private SeriesCollection seriesCollection;
|
||||
private List<string> labels;
|
||||
private ObservableCollection<TreeViewItemViewModel> _tree;
|
||||
private TreeViewItemViewModel _root;
|
||||
readonly ICommand _searchCommand;
|
||||
private RelayCommand _getYCommand;
|
||||
private RelayCommand _scaleCommand;
|
||||
private RelayCommand _limCommand;
|
||||
private RelayCommand _deleteCommand;
|
||||
private RelayCommand _treeCommand;
|
||||
private RelayCommand _renameCommand;
|
||||
private RelayCommand _saveCommand;
|
||||
private TreeGraphView _treeGraphView_win;
|
||||
private IOneVariableFunction selectedFunction;
|
||||
private IOneVariableFunction rootFunction;
|
||||
public IOneVariableFunction SelectedFuntion
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectedFunction;
|
||||
}
|
||||
set
|
||||
{
|
||||
selectedFunction = value;
|
||||
OnPropertyChanged(nameof(SelectedFuntion));
|
||||
}
|
||||
}
|
||||
public IOneVariableFunction RootFunction
|
||||
{
|
||||
get
|
||||
{
|
||||
return rootFunction;
|
||||
}
|
||||
set
|
||||
{
|
||||
rootFunction = value;
|
||||
OnPropertyChanged(nameof(RootFunction));
|
||||
}
|
||||
}
|
||||
public SeriesCollection SeriesCollection
|
||||
{
|
||||
get => seriesCollection;
|
||||
set
|
||||
{
|
||||
seriesCollection = value;
|
||||
OnPropertyChanged(nameof(SeriesCollection));
|
||||
}
|
||||
}
|
||||
public List<string> Labels
|
||||
{
|
||||
get => labels;
|
||||
set
|
||||
{
|
||||
labels = value;
|
||||
OnPropertyChanged(nameof(labels));
|
||||
}
|
||||
}
|
||||
public LineSeries LineSeries
|
||||
{
|
||||
get => lineSeries;
|
||||
set
|
||||
{
|
||||
lineSeries = value;
|
||||
OnPropertyChanged(nameof(lineSeries));
|
||||
}
|
||||
}
|
||||
public TreeGraphView TreeGraphView_win
|
||||
{
|
||||
get => _treeGraphView_win;
|
||||
set => _treeGraphView_win = value;
|
||||
}
|
||||
public ObservableCollection<TreeViewItemViewModel> Tree
|
||||
{
|
||||
get => _tree;
|
||||
set
|
||||
{
|
||||
_tree = value;
|
||||
OnPropertyChanged(nameof(Tree));
|
||||
}
|
||||
}
|
||||
public GraphVisualProps VisualProps { get; } = new GraphVisualProps();
|
||||
public ICommand GetYCommand
|
||||
{
|
||||
get => _getYCommand ??= new RelayCommand(o => GetY());
|
||||
}
|
||||
public ICommand ScaleCommand
|
||||
{
|
||||
get => _scaleCommand ??= new RelayCommand(o => Scale(o));
|
||||
}
|
||||
public ICommand LimitCommand
|
||||
{
|
||||
get => _limCommand ??= new RelayCommand(o => Limit(o));
|
||||
}
|
||||
public ICommand DeleteCommand
|
||||
{
|
||||
get => _deleteCommand ??= new RelayCommand(o => Delete());
|
||||
}
|
||||
public ICommand TreeCommand
|
||||
{
|
||||
get => _treeCommand ??= new RelayCommand(o => NewTree(o));
|
||||
}
|
||||
public ICommand RenameCommand
|
||||
{
|
||||
get => _renameCommand ??= new RelayCommand(o => Rename(o));
|
||||
}
|
||||
public ICommand SaveCommand
|
||||
{
|
||||
get => _saveCommand ??= new RelayCommand(o => Save());
|
||||
}
|
||||
public TreeGraphViewModel(IOneVariableFunction rootFunction)
|
||||
{
|
||||
RootFunction = rootFunction;
|
||||
RunTreeView(rootFunction);
|
||||
}
|
||||
private void RunTreeView(IOneVariableFunction rootFunction)
|
||||
{
|
||||
_root = new TreeViewItemViewModel(rootFunction, this);
|
||||
Tree = new ObservableCollection<TreeViewItemViewModel>
|
||||
(
|
||||
new ObservableCollection<TreeViewItemViewModel>()
|
||||
{
|
||||
_root,
|
||||
}
|
||||
);
|
||||
}
|
||||
private void GetY()
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedFuntion = selectedTreeViewItem.Function;
|
||||
var vm = new GetValueViewModel(SelectedFuntion);
|
||||
var v = new GetValueView();
|
||||
v.DataContext = vm;
|
||||
v.ShowDialog();
|
||||
}
|
||||
private void Scale(object parameter)
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ScaleViewModel vm = null;
|
||||
var v = new ScaleView();
|
||||
var type = parameter as string;
|
||||
if (type.Equals("x"))
|
||||
{
|
||||
vm = new ScaleViewModel(true);
|
||||
v.DataContext = vm;
|
||||
if (v.ShowDialog() == true)
|
||||
{
|
||||
var newFunction = new ScaleXDecorator(SelectedFuntion, vm.ScaleFactor);
|
||||
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||
selectedTreeViewItem.Children.Add(child);
|
||||
selectedTreeViewItem.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
else if (type.Equals("y"))
|
||||
{
|
||||
vm = new ScaleViewModel(false);
|
||||
v.DataContext = vm;
|
||||
if (v.ShowDialog() == true)
|
||||
{
|
||||
var newFunction = new ScaleYDecorator(SelectedFuntion, vm.ScaleFactor);
|
||||
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||
selectedTreeViewItem.Children.Add(child);
|
||||
selectedTreeViewItem.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Limit(object parameter)
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LimViewModel vm = null;
|
||||
var v = new LimView();
|
||||
var type = parameter as string;
|
||||
if (type.Equals("x"))
|
||||
{
|
||||
vm = new LimViewModel(true);
|
||||
v.DataContext = vm;
|
||||
if (v.ShowDialog() == true)
|
||||
{
|
||||
var newFunction = new LimXDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
||||
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||
selectedTreeViewItem.Children.Add(child);
|
||||
selectedTreeViewItem.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
else if (type.Equals("y"))
|
||||
{
|
||||
vm = new LimViewModel(false);
|
||||
v.DataContext = vm;
|
||||
if (v.ShowDialog() == true)
|
||||
{
|
||||
var newFunction = new LimYDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
||||
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||
selectedTreeViewItem.Children.Add(child);
|
||||
selectedTreeViewItem.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Delete()
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var selectedTreeViewItemParent = selectedTreeViewItem.Parent;
|
||||
if (selectedTreeViewItemParent is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
selectedTreeViewItemParent.Children.Remove(selectedTreeViewItem);
|
||||
Save();
|
||||
}
|
||||
private void Rename(object parameter)
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var selectedTreeViewItemParent = selectedTreeViewItem.Parent;
|
||||
if (selectedTreeViewItemParent is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var renameViewModel = new RenameViewModel(selectedTreeViewItem);
|
||||
var renameView = new RenameView();
|
||||
renameView.DataContext = renameViewModel;
|
||||
if (renameView.ShowDialog() == true)
|
||||
{
|
||||
selectedTreeViewItem.Name = renameViewModel.FunctionName;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void NewTree(object parameter)
|
||||
{
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var selectedTreeViewItemParent = selectedTreeViewItem.Parent;
|
||||
if (selectedTreeViewItemParent is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var treeGraphVM = new TreeGraphViewModel(SelectedFuntion);
|
||||
var treeGraph = new TreeGraphView();
|
||||
treeGraph.DataContext = treeGraphVM;
|
||||
treeGraphVM.TreeGraphView_win = treeGraph;
|
||||
treeGraph.ShowDialog();
|
||||
Save();
|
||||
RunTreeView(RootFunction);
|
||||
}
|
||||
public void DrawGraph()
|
||||
{
|
||||
var labels = new List<string>();
|
||||
var lineSeries = new LineSeries();
|
||||
var seriesCollection = new SeriesCollection();
|
||||
var chartValues = new ChartValues<double>();
|
||||
var selectedTreeViewItem = TreeGraphView_win.FunctionTreeView.SelectedItem as TreeViewItemViewModel;
|
||||
if (selectedTreeViewItem is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedFuntion = selectedTreeViewItem.Function;
|
||||
var graphSettings = SelectedFuntion.GetGraphSettings();
|
||||
Labels = graphSettings.GetLabels();
|
||||
LineSeries = graphSettings.GetLineSeries();
|
||||
GraphService.SetVisualProps(LineSeries, VisualProps);
|
||||
SeriesCollection = new SeriesCollection();
|
||||
SeriesCollection.Add(LineSeries);
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
GetFunctionTree(Tree, RootFunction);
|
||||
}
|
||||
private void GetFunctionTree(ObservableCollection<TreeViewItemViewModel> tree, IOneVariableFunction function)
|
||||
{
|
||||
function.Functions.Clear();
|
||||
foreach (TreeViewItemViewModel item in tree)
|
||||
{
|
||||
if (item.Function is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
function.Functions.Add(item.Function);
|
||||
if (item.Children.Count > 0)
|
||||
{
|
||||
var newTree = item.Children;
|
||||
GetFunctionTree(newTree, item.Function);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
90
StructureHelper/Windows/TreeGraph/TreeViewItemViewModel.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using FieldVisualizer.ViewModels;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
public class TreeViewItemViewModel : ViewModelBase
|
||||
{
|
||||
readonly ObservableCollection<TreeViewItemViewModel> _children;
|
||||
readonly TreeViewItemViewModel _parent;
|
||||
readonly IOneVariableFunction _function;
|
||||
readonly TreeGraphViewModel _treeGraphViewModel;
|
||||
|
||||
bool _isExpanded = true;
|
||||
bool _isSelected;
|
||||
|
||||
public TreeViewItemViewModel(IOneVariableFunction function, TreeGraphViewModel treeGraphViewModel) : this(function, null, treeGraphViewModel)
|
||||
{
|
||||
}
|
||||
public TreeViewItemViewModel(IOneVariableFunction function, TreeViewItemViewModel parent, TreeGraphViewModel treeGraphViewModel)
|
||||
{
|
||||
_function = function;
|
||||
_parent = parent;
|
||||
_treeGraphViewModel = treeGraphViewModel;
|
||||
_children = new ObservableCollection<TreeViewItemViewModel>
|
||||
(
|
||||
_function.Functions
|
||||
.Select(x => new TreeViewItemViewModel(x, this, treeGraphViewModel))
|
||||
.ToList<TreeViewItemViewModel>()
|
||||
);
|
||||
}
|
||||
public IOneVariableFunction Function
|
||||
{
|
||||
get { return _function; }
|
||||
}
|
||||
public ObservableCollection<TreeViewItemViewModel> Children
|
||||
{
|
||||
get { return _children; }
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get { return _function.Name; }
|
||||
set
|
||||
{
|
||||
_function.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
public bool IsExpanded
|
||||
{
|
||||
get { return _isExpanded; }
|
||||
set
|
||||
{
|
||||
if (value != _isExpanded)
|
||||
{
|
||||
_isExpanded = value;
|
||||
OnPropertyChanged(nameof(IsExpanded));
|
||||
}
|
||||
// Expand all the way up to the root.
|
||||
if (_isExpanded && _parent != null)
|
||||
_parent.IsExpanded = true;
|
||||
}
|
||||
}
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return _isSelected; }
|
||||
set
|
||||
{
|
||||
if (value != _isSelected)
|
||||
{
|
||||
_isSelected = value;
|
||||
_treeGraphViewModel.DrawGraph();
|
||||
_treeGraphViewModel.Save();
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
}
|
||||
public TreeViewItemViewModel Parent
|
||||
{
|
||||
get { return _parent; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,13 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
else if (parameterType == MaterialType.Elastic) { AddElastic(); }
|
||||
else if (parameterType == MaterialType.CarbonFiber) { AddCarbonFiber(); }
|
||||
else if (parameterType == MaterialType.GlassFiber) { AddGlassFiber(); }
|
||||
else if (parameterType == MaterialType.Function) { AddFunctionMaterial(); }
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)}, Actual type: {nameof(parameterType)}");
|
||||
GlobalRepository.Materials.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
if (!(NewItem is null))
|
||||
{
|
||||
GlobalRepository.Materials.Create(NewItem);
|
||||
base.AddMethod(parameter);
|
||||
}
|
||||
}
|
||||
public override void DeleteMethod(object parameter)
|
||||
{
|
||||
@@ -118,6 +122,19 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
material.Name = "New Concrete";
|
||||
NewItem = material;
|
||||
}
|
||||
private void AddFunctionMaterial()
|
||||
{
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Function);
|
||||
material.Name = "New Function Material";
|
||||
if ((material as HeadMaterial).SuccessfullyCreated)
|
||||
{
|
||||
NewItem = material;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewItem = null;
|
||||
}
|
||||
}
|
||||
private void CheckParameters(object parameter)
|
||||
{
|
||||
if (parameter is null) { throw new StructureHelperException(ErrorStrings.ParameterIsNull); }
|
||||
|
||||
63
StructureHelperCommon/FunctionDecorator.cd
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="StructureHelperCommon.Models.Functions.TableFunction" BaseTypeListCollapsed="true">
|
||||
<Position X="3.25" Y="8" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAACgEgAAAAgBCIAAAAAQAYAAAAMAAAAAQAAgAAAgBA=</HashCode>
|
||||
<FileName>Models\Functions\TableFunction.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Models.Functions.FormulaFunction" BaseTypeListCollapsed="true">
|
||||
<Position X="1" Y="8" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAACgEgAAAAgBCIAAAAAAAYAAAAIBAAAIQAAgAAAgBA=</HashCode>
|
||||
<FileName>Models\Functions\FormulaFunction.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Models.Functions.Decorator.ScaleYDecorator">
|
||||
<Position X="7.25" Y="5.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAgAAAAARAAAAAAAAAAAAAAIAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Functions\Decorator\ScaleYDecorator.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Models.Functions.Decorator.ScaleXDecorator">
|
||||
<Position X="5.5" Y="5.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAgAAAAARAAAAAAAAAAAAAAIAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Functions\Decorator\ScaleXDecorator.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Models.Functions.Decorator.LimYDecorator">
|
||||
<Position X="9.25" Y="5.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAQgAAAAABAAAAAAAAAAAAAAIAAAAAAAAAAAAAAg=</HashCode>
|
||||
<FileName>Models\Functions\Decorator\LimYDecorator.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Models.Functions.Decorator.LimXDecorator">
|
||||
<Position X="11.5" Y="5.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAgAAgAAAAABAAAAAAAAAAAAAAIAAAAAAAAEAAAAAA=</HashCode>
|
||||
<FileName>Models\Functions\Decorator\LimXDecorator.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="StructureHelperCommon.Infrastructures.Interfaces.FunctionDecorator" Collapsed="true">
|
||||
<Position X="8.25" Y="2.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAACgEgAAAAgBAAAAgAAQAYAAAAIAAAAAQAAgAAAgBA=</HashCode>
|
||||
<FileName>Infrastructures\Interfaces\FunctionDecorator.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" />
|
||||
</Class>
|
||||
<Interface Name="StructureHelperCommon.Infrastructures.Interfaces.IOneVariableFunction">
|
||||
<Position X="2.25" Y="2.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAAAgEgAAAAgBCAAAAAAAAYAAAAIAAAAAQAAgAAAgAA=</HashCode>
|
||||
<FileName>Infrastructures\Interfaces\IOneVariableFunction.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Commands
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action<object> execute;
|
||||
private Func<object, bool> canExecute;
|
||||
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add => CommandManager.RequerySuggested += value;
|
||||
remove => CommandManager.RequerySuggested -= value;
|
||||
}
|
||||
|
||||
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
|
||||
{
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter) => canExecute == null || canExecute(parameter);
|
||||
|
||||
public void Execute(object parameter) => execute(parameter);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Enums
|
||||
{
|
||||
public enum FunctionPurpose
|
||||
{
|
||||
StressStrain,
|
||||
FireProtection
|
||||
}
|
||||
}
|
||||
14
StructureHelperCommon/Infrastructures/Enums/FunctionType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Enums
|
||||
{
|
||||
public enum FunctionType
|
||||
{
|
||||
TableFunction,
|
||||
FormulaFunction
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public abstract class FunctionDecorator : IOneVariableFunction
|
||||
{
|
||||
protected IOneVariableFunction function;
|
||||
public bool IsUser { get; set; }
|
||||
public string Group { get; set; }
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
public double MinArg { get; set; }
|
||||
public double MaxArg { get; set; }
|
||||
public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
|
||||
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string Trace { get; set; }
|
||||
|
||||
public FunctionDecorator(IOneVariableFunction function)
|
||||
{
|
||||
this.function = function;
|
||||
}
|
||||
public virtual bool Check()
|
||||
{
|
||||
return function.Check();
|
||||
}
|
||||
public virtual object Clone()
|
||||
{
|
||||
return function.Clone();
|
||||
}
|
||||
public virtual double GetByX(double xValue)
|
||||
{
|
||||
return function.GetByX(xValue);
|
||||
}
|
||||
public virtual GraphSettings GetGraphSettings()
|
||||
{
|
||||
return function.GetGraphSettings();
|
||||
}
|
||||
public virtual string GetTrace()
|
||||
{
|
||||
return function.GetTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
{
|
||||
public interface IOneVariableFunction : ICloneable, ISaveable, ILogic
|
||||
{
|
||||
public const string GROUP_TYPE_1 = "System function";
|
||||
public const string GROUP_TYPE_2 = "User function";
|
||||
public bool IsUser { get; set; }
|
||||
public string Group { get; set; }
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double MinArg { get; set; }
|
||||
public double MaxArg { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string Trace { get; set; }
|
||||
public List<IOneVariableFunction> Functions { get; set; }
|
||||
|
||||
public bool Check();
|
||||
public double GetByX(double xValue);
|
||||
public GraphSettings GetGraphSettings();
|
||||
public string GetTrace();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Codes;
|
||||
using StructureHelperCommon.Models.Codes.Factories;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Models.Projects;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Linq;
|
||||
using System.Windows.Documents;
|
||||
@@ -39,7 +42,8 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
public static LimitStatesList LimitStatesList => new LimitStatesList();
|
||||
public static CalcTermList CalcTermList => new CalcTermList();
|
||||
public static List<ICodeEntity> CodesList
|
||||
{ get
|
||||
{
|
||||
get
|
||||
{
|
||||
codesList ??= CodeFactory
|
||||
.GetCodeEntities()
|
||||
@@ -90,5 +94,54 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
SubVersionNumber = 0
|
||||
};
|
||||
}
|
||||
public static List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>
|
||||
{
|
||||
new TableFunction()
|
||||
{
|
||||
Name = "Not StressStrain",
|
||||
FullName = "Not StressStrain",
|
||||
FunctionPurpose = FunctionPurpose.FireProtection,
|
||||
Table = new List<GraphPoint>()
|
||||
{
|
||||
new GraphPoint(1, 1),
|
||||
new GraphPoint(2, 2),
|
||||
new GraphPoint(3, 3),
|
||||
new GraphPoint(4, 4),
|
||||
new GraphPoint(5, 5),
|
||||
new GraphPoint(6, 6),
|
||||
},
|
||||
IsUser = false,
|
||||
Description = "Пример описания",
|
||||
},
|
||||
new TableFunction()
|
||||
{
|
||||
Name = "Табличная системная функция",
|
||||
FullName = "Табличная системная функция",
|
||||
FunctionPurpose = FunctionPurpose.StressStrain,
|
||||
Table = new List<GraphPoint>()
|
||||
{
|
||||
new GraphPoint(1, 1),
|
||||
new GraphPoint(2, 2),
|
||||
new GraphPoint(3, 3),
|
||||
new GraphPoint(4, 4),
|
||||
new GraphPoint(5, 5),
|
||||
new GraphPoint(6, 6),
|
||||
},
|
||||
IsUser = false,
|
||||
Description = "Пример описания",
|
||||
},
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "Формульная системная функция",
|
||||
FullName = "Формульная системная функция",
|
||||
FunctionPurpose = FunctionPurpose.StressStrain,
|
||||
Formula = "x^2",
|
||||
Step = 100,
|
||||
MinArg = 1,
|
||||
MaxArg = 1000,
|
||||
IsUser = false,
|
||||
Description = "Пример описания",
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
16
StructureHelperCommon/Models/Analyses/IEditor.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Analyses
|
||||
{
|
||||
public interface IEditor : ISaveable, ICloneable
|
||||
{
|
||||
string Name { get; set; }
|
||||
string Tags { get; set; }
|
||||
IVersionProcessor VersionProcessor { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using FunctionParser;
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class LimXDecorator : FunctionDecorator
|
||||
{
|
||||
private double leftBound;
|
||||
private double rightBound;
|
||||
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
|
||||
{
|
||||
Name = $"x\u2208[{leftBound};{rightBound}]";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
this.leftBound = leftBound;
|
||||
this.rightBound = rightBound;
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
double yValue = 0;
|
||||
if (xValue >= leftBound && xValue <= rightBound)
|
||||
{
|
||||
yValue = base.GetByX(xValue);
|
||||
}
|
||||
Trace = string.Empty;
|
||||
Trace += $"Lim X: {Name}, Input: {xValue}, Output: {xValue};\n";
|
||||
Trace += base.GetTrace();
|
||||
return yValue;
|
||||
}
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
var graphLimitGraphPoint = new List<GraphPoint>();
|
||||
var leftPoint = new GraphPoint(leftBound, GetByX(leftBound));
|
||||
var rightPoint = new GraphPoint(rightBound, GetByX(rightBound));
|
||||
graphLimitGraphPoint.Add(leftPoint);
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
if (point.X > leftBound && point.X < rightBound)
|
||||
{
|
||||
graphLimitGraphPoint.Add(point);
|
||||
}
|
||||
}
|
||||
graphLimitGraphPoint.Add(rightPoint);
|
||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||
return graphSettings;
|
||||
}
|
||||
public override string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class LimYDecorator : FunctionDecorator
|
||||
{
|
||||
private double downBound;
|
||||
private double upBound;
|
||||
public LimYDecorator(IOneVariableFunction function, double downBound, double upBound) : base(function)
|
||||
{
|
||||
Name = $"y\u2208[{downBound};{upBound}]";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
this.downBound = downBound;
|
||||
this.upBound = upBound;
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
double retValue = 0;
|
||||
var y = base.GetByX(xValue);
|
||||
if (y > downBound && y < upBound)
|
||||
{
|
||||
retValue = y;
|
||||
}
|
||||
else if (y <= downBound)
|
||||
{
|
||||
retValue = downBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = upBound;
|
||||
}
|
||||
Trace = string.Empty;
|
||||
Trace += base.GetTrace();
|
||||
Trace += $"Lim Y: {Name}, Input: {y}, Output: {retValue};\n";
|
||||
return retValue;
|
||||
}
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
var graphLimitGraphPoint = new List<GraphPoint>();
|
||||
var downPoint = new GraphPoint(downBound, GetByX(downBound));
|
||||
var upPoint = new GraphPoint(upBound, GetByX(upBound));
|
||||
graphLimitGraphPoint.Add(downPoint);
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
if (point.Y > downBound && point.Y < upBound)
|
||||
{
|
||||
graphLimitGraphPoint.Add(point);
|
||||
}
|
||||
else if (point.Y <= downBound)
|
||||
{
|
||||
graphLimitGraphPoint.Add(new GraphPoint(point.X, downBound));
|
||||
}
|
||||
else
|
||||
{
|
||||
graphLimitGraphPoint.Add(new GraphPoint(point.X, upBound));
|
||||
}
|
||||
}
|
||||
graphLimitGraphPoint.Add(upPoint);
|
||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||
return graphSettings;
|
||||
}
|
||||
public override string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class ScaleXDecorator : FunctionDecorator
|
||||
{
|
||||
private double factor;
|
||||
public ScaleXDecorator(IOneVariableFunction function, double factor) : base(function)
|
||||
{
|
||||
this.factor = factor;
|
||||
Name = $"y=f({factor}x)";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
double yValue = base.GetByX(factor * xValue);
|
||||
Trace = string.Empty;
|
||||
Trace += $"Scale X: {Name}, Input: {xValue}, Output: {factor * xValue};\n";
|
||||
Trace += base.GetTrace();
|
||||
return yValue;
|
||||
|
||||
}
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
foreach(GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
point.Y = GetByX(point.X);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
public override string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class ScaleYDecorator : FunctionDecorator
|
||||
{
|
||||
private double factor;
|
||||
public ScaleYDecorator(IOneVariableFunction function, double factor) : base(function)
|
||||
{
|
||||
this.factor = factor;
|
||||
Name = $"y={factor}f(x)";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
return base.Check();
|
||||
}
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
double functionValue = base.GetByX(xValue);
|
||||
double yValue = factor * functionValue;
|
||||
Trace = string.Empty;
|
||||
Trace += base.GetTrace();
|
||||
Trace += $"Scale Y: {Name}, Input: {functionValue}, Output: {yValue};\n";
|
||||
return yValue;
|
||||
|
||||
}
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
point.Y = GetByX(point.X);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
public override string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
129
StructureHelperCommon/Models/Functions/FormulaFunction.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using LiveCharts;
|
||||
using Microsoft.VisualBasic.ApplicationServices;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
using StructureHelperCommon.Services;
|
||||
using LiveCharts.Wpf;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using FunctionParser;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
public class FormulaFunction : IOneVariableFunction
|
||||
{
|
||||
private double current_xValue;
|
||||
private string formula;
|
||||
private Expression expression;
|
||||
private const string COPY = "copy";
|
||||
public const string GROUP_TYPE_1 = "System function";
|
||||
public const string GROUP_TYPE_2 = "User function";
|
||||
public bool IsUser { get; set; }
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get ; set; }
|
||||
public int Step { get; set; }
|
||||
public string Formula
|
||||
{
|
||||
get
|
||||
{
|
||||
return formula;
|
||||
}
|
||||
set
|
||||
{
|
||||
formula = value;
|
||||
Expression = new Expression(value, new string[] { "x" }, null);
|
||||
}
|
||||
}
|
||||
public Expression Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
expression = value;
|
||||
}
|
||||
}
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
|
||||
public double MinArg { get; set; }
|
||||
public double MaxArg { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string Trace { get; set; }
|
||||
|
||||
public FormulaFunction(bool isUser = false)
|
||||
{
|
||||
Color = ColorProcessor.GetRandomColor();
|
||||
Type = FunctionType.FormulaFunction;
|
||||
if (isUser)
|
||||
{
|
||||
IsUser = true;
|
||||
Group = GROUP_TYPE_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsUser = false;
|
||||
Group = GROUP_TYPE_1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Check()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
var formulaFunction = new FormulaFunction();
|
||||
formulaFunction.Type = Type;
|
||||
formulaFunction.Name = $"{Name} {COPY}";
|
||||
formulaFunction.FullName = formulaFunction.Name;
|
||||
formulaFunction.Description = Description;
|
||||
formulaFunction.Formula = Formula;
|
||||
formulaFunction.IsUser = true;
|
||||
formulaFunction.Group = GROUP_TYPE_2;
|
||||
formulaFunction.Step = Step;
|
||||
formulaFunction.MinArg = MinArg;
|
||||
formulaFunction.MaxArg = MaxArg;
|
||||
formulaFunction.FunctionPurpose = FunctionPurpose;
|
||||
return formulaFunction;
|
||||
}
|
||||
|
||||
public double GetByX(double xValue)
|
||||
{
|
||||
double yValue = 0;
|
||||
current_xValue = xValue;
|
||||
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
||||
Trace = string.Empty;
|
||||
Trace += $"Function: {Formula}, Input: {xValue}, Output: {yValue};\n";
|
||||
return yValue;
|
||||
}
|
||||
public GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = new GraphSettings(Color, Color);
|
||||
var stepLenght = Math.Abs(MaxArg - MinArg) / Step;
|
||||
for (double x = MinArg; x < MaxArg; x += stepLenght)
|
||||
{
|
||||
var graphPoint = new GraphPoint(x, GetByX(x));
|
||||
graphSettings.GraphPoints.Add(graphPoint);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
public string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
StructureHelperCommon/Models/Functions/FunctionStorage.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
public class FunctionStorage
|
||||
{
|
||||
public IOneVariableFunction Func_ST_ULS { get; set; }
|
||||
public IOneVariableFunction Func_ST_SLS { get; set; }
|
||||
public IOneVariableFunction Func_ST_Special { get; set; }
|
||||
public IOneVariableFunction Func_LT_ULS { get; set; }
|
||||
public IOneVariableFunction Func_LT_SLS { get; set; }
|
||||
public IOneVariableFunction Func_LT_Special { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
27
StructureHelperCommon/Models/Functions/GraphPoint.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
public class GraphPoint : ICloneable
|
||||
{
|
||||
public bool Visible { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
|
||||
public GraphPoint(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
Visible = true;
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
var clone = new GraphPoint(X,Y);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
117
StructureHelperCommon/Models/Functions/TableFunction.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Media;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Services;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
public class TableFunction : IOneVariableFunction
|
||||
{
|
||||
private const string COPY = "copy";
|
||||
public const string GROUP_TYPE_1 = "System function";
|
||||
public const string GROUP_TYPE_2 = "User function";
|
||||
|
||||
private string name;
|
||||
|
||||
public bool IsUser { get; set; }
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
public List<IOneVariableFunction> Functions { get; set; } = new List<IOneVariableFunction>();
|
||||
public double MinArg { get; set; }
|
||||
public double MaxArg { get; set; }
|
||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||
public Color Color { get; set; }
|
||||
public string Trace { get; set; }
|
||||
|
||||
public TableFunction(bool isUser = false)
|
||||
{
|
||||
Color = ColorProcessor.GetRandomColor();
|
||||
Type = FunctionType.TableFunction;
|
||||
if (isUser)
|
||||
{
|
||||
IsUser = true;
|
||||
Group = GROUP_TYPE_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsUser = false;
|
||||
Group = GROUP_TYPE_1;
|
||||
}
|
||||
}
|
||||
public bool Check()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
var tableFunction = new TableFunction();
|
||||
tableFunction.Type = Type;
|
||||
tableFunction.Name = $"{Name} {COPY}";
|
||||
tableFunction.FullName = tableFunction.Name;
|
||||
tableFunction.Description = Description;
|
||||
var newTable = new List<GraphPoint>();
|
||||
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
|
||||
tableFunction.Table = newTable;
|
||||
tableFunction.IsUser = true;
|
||||
tableFunction.Group = GROUP_TYPE_2;
|
||||
tableFunction.FunctionPurpose = FunctionPurpose;
|
||||
return tableFunction;
|
||||
}
|
||||
public double GetByX(double xValue)
|
||||
{
|
||||
double yValue = 0;
|
||||
GraphPoint leftBound = null;
|
||||
GraphPoint rightBound = null;
|
||||
for (int i = 0; i < Table.Count - 1; i++)
|
||||
{
|
||||
leftBound = Table[i];
|
||||
rightBound = Table[i + 1];
|
||||
if (xValue == leftBound.X)
|
||||
{
|
||||
yValue = leftBound.Y;
|
||||
}
|
||||
else if (xValue == rightBound.X)
|
||||
{
|
||||
yValue = rightBound.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
yValue = MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y);
|
||||
}
|
||||
}
|
||||
Trace = string.Empty;
|
||||
Trace += $"From table, Input: {xValue}, Output: {yValue};\n";
|
||||
return yValue;
|
||||
}
|
||||
public GraphSettings GetGraphSettings()
|
||||
{
|
||||
var graphSettings = new GraphSettings(Color, Color);
|
||||
foreach (GraphPoint point in Table)
|
||||
{
|
||||
var graphPoint = new GraphPoint(point.X, GetByX(point.X));
|
||||
graphSettings.GraphPoints.Add(graphPoint);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
public string GetTrace()
|
||||
{
|
||||
return Trace;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,12 +19,12 @@ namespace StructureHelperCommon.Models.Materials
|
||||
|
||||
public void SetMaterialOptions(LCMB.IMaterialOptions materialOptions)
|
||||
{
|
||||
materialOptions.InitModulus = options.MaterialEntity.InitModulus;
|
||||
/*materialOptions.InitModulus = options.MaterialEntity.InitModulus;
|
||||
materialOptions.Strength = options.MaterialEntity.MainStrength;
|
||||
ProcessCodeType(materialOptions);
|
||||
ProcessLimitState(materialOptions);
|
||||
ProcessCalcTerm(materialOptions);
|
||||
ProcessExternalFactors(materialOptions);
|
||||
ProcessExternalFactors(materialOptions);*/
|
||||
}
|
||||
|
||||
private void ProcessExternalFactors(IMaterialOptions materialOptions)
|
||||
|
||||
19
StructureHelperCommon/Models/Materials/MaterialSettings.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Models.Materials
|
||||
{
|
||||
public class MaterialSettings
|
||||
{
|
||||
public int Number { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
public LimitStates LimitState { get; set; }
|
||||
public CalcTerms CalcTerm { get; set; }
|
||||
public IOneVariableFunction Function { get; set; }
|
||||
}
|
||||
}
|
||||
48
StructureHelperCommon/Services/GraphSettings.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using LiveCharts;
|
||||
using LiveCharts.Wpf;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelperCommon.Services
|
||||
{
|
||||
public class GraphSettings
|
||||
{
|
||||
private Color _strokeColor;
|
||||
private Color _fillColor;
|
||||
private List<string> _labels = new List<string>();
|
||||
private SeriesCollection _seriesCollection = new SeriesCollection();
|
||||
private LineSeries _lineSeries { get; set; } = new LineSeries();
|
||||
private ChartValues<double> _chartValues { get; set; } = new ChartValues<double>();
|
||||
public List<GraphPoint> GraphPoints { get; set; } = new List<GraphPoint>();
|
||||
public GraphSettings(Color strokeColor, Color fillColor)
|
||||
{
|
||||
_strokeColor = strokeColor;
|
||||
_fillColor = fillColor;
|
||||
}
|
||||
public List<string> GetLabels()
|
||||
{
|
||||
foreach (GraphPoint point in GraphPoints)
|
||||
{
|
||||
_labels.Add(Math.Round(point.X, 2).ToString());
|
||||
}
|
||||
return _labels;
|
||||
}
|
||||
public LineSeries GetLineSeries()
|
||||
{
|
||||
foreach (GraphPoint point in GraphPoints)
|
||||
{
|
||||
_chartValues.Add(Math.Round(point.Y, 2));
|
||||
}
|
||||
_lineSeries.Values = _chartValues;
|
||||
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
||||
_lineSeries.Fill = Brushes.Transparent;
|
||||
return _lineSeries;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
StructureHelperCommon/Services/MathUtils.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperCommon.Services
|
||||
{
|
||||
public static class MathUtils
|
||||
{
|
||||
public static double Interpolation(double x, double x1, double x2, double y1, double y2)
|
||||
{
|
||||
if (Math.Abs(x2 - x1) < 10E-3)
|
||||
{
|
||||
return (y1 + y2) / 2;
|
||||
}
|
||||
var y = (y2 - y1) * (x - x1) / (x2 - x1) + y1;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiveCharts.Wpf" Version="0.9.7" />
|
||||
<PackageReference Include="NLog" Version="5.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="FunctionParser">
|
||||
<HintPath>..\StructureHelper\Libraries\FunctionParser.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="LoaderCalculator">
|
||||
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
14
StructureHelperCommon/StructureHelperCommon.csproj.user
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<ItemGroup>
|
||||
<Compile Update="Windows\FunctionMaterialCreationView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Windows\FunctionMaterialCreationView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
203
StructureHelperCommon/Windows/FunctionMaterialCreationVM.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using FunctionParser;
|
||||
using StructureHelperCommon.Infrastructures.Commands;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Sections.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelperCommon.Windows
|
||||
{
|
||||
public class FunctionMaterialCreationVM
|
||||
{
|
||||
private ObservableCollection<MaterialSettings> materialSettingsList = new()
|
||||
{
|
||||
new MaterialSettings()
|
||||
{
|
||||
Number = 1,
|
||||
IsActive = true,
|
||||
LimitState = Infrastructures.Enums.LimitStates.ULS,
|
||||
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
|
||||
},
|
||||
new MaterialSettings()
|
||||
{
|
||||
Number = 2,
|
||||
IsActive = true,
|
||||
LimitState = Infrastructures.Enums.LimitStates.ULS,
|
||||
CalcTerm = Infrastructures.Enums.CalcTerms.LongTerm,
|
||||
},
|
||||
new MaterialSettings()
|
||||
{
|
||||
Number = 3,
|
||||
IsActive = true,
|
||||
LimitState = Infrastructures.Enums.LimitStates.SLS,
|
||||
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
|
||||
},
|
||||
new MaterialSettings()
|
||||
{
|
||||
Number = 4,
|
||||
IsActive = true,
|
||||
LimitState = Infrastructures.Enums.LimitStates.SLS,
|
||||
CalcTerm = Infrastructures.Enums.CalcTerms.LongTerm,
|
||||
},
|
||||
|
||||
};
|
||||
public string CREATE_MATERIAL { get; } = "Create Function Material";
|
||||
public string MODULUS_OF_ELASTYCITY { get; } = "Modulus =";
|
||||
public string ADD { get; } = "Add";
|
||||
public string DELETE { get; } = "Delete";
|
||||
private const string ERROR_TEXT_1 = "There are no active calculation states. Please activate at least one table row.";
|
||||
private const string ERROR_TEXT_2_1 = "Not all active material states have functions:";
|
||||
private const string ERROR_TEXT_2_2 = "please fill in functions in these rows.";
|
||||
private const string ERROR_TEXT_3_1 = "The material cannot be created because some calculation states are duplicated:";
|
||||
private const string ERROR_TEXT_3_2 = "please remove or disable some duplicated rows, each state must be unique.";
|
||||
private RelayCommand createFunctionMaterialCommand;
|
||||
private RelayCommand addCommand;
|
||||
private RelayCommand deleteCommand;
|
||||
public ICommand CreateFunctionMaterialCommand
|
||||
{
|
||||
get => createFunctionMaterialCommand ??= new RelayCommand(o => CreateFunctionMaterial(o));
|
||||
}
|
||||
public ICommand AddCommand
|
||||
{
|
||||
get => addCommand ??= new RelayCommand(o => Add());
|
||||
}
|
||||
public ICommand DeleteCommand
|
||||
{
|
||||
get => deleteCommand ??= new RelayCommand(o => Delete(o));
|
||||
}
|
||||
public double Modulus { get; set; } = 2e11d;
|
||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
|
||||
public ObservableCollection<MaterialSettings> MaterialSettingsList
|
||||
{
|
||||
get
|
||||
{
|
||||
return materialSettingsList;
|
||||
}
|
||||
set
|
||||
{
|
||||
materialSettingsList = value;
|
||||
}
|
||||
}
|
||||
public FunctionMaterialCreationVM()
|
||||
{
|
||||
var stressStrainFunctions = new List<IOneVariableFunction>
|
||||
(
|
||||
ProgramSetting.Functions
|
||||
.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
|
||||
);
|
||||
GetFunctionsFromTree(stressStrainFunctions);
|
||||
}
|
||||
private void GetFunctionsFromTree(List<IOneVariableFunction> stressStrainFunctions)
|
||||
{
|
||||
foreach (IOneVariableFunction func in stressStrainFunctions)
|
||||
{
|
||||
Functions.Add(func);
|
||||
if (func.Functions.Count > 0)
|
||||
{
|
||||
GetFunctionsFromTree(func.Functions);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Add()
|
||||
{
|
||||
var ms = new MaterialSettings()
|
||||
{
|
||||
Number = MaterialSettingsList.Count + 1,
|
||||
IsActive = true,
|
||||
LimitState = Infrastructures.Enums.LimitStates.ULS,
|
||||
CalcTerm = Infrastructures.Enums.CalcTerms.ShortTerm,
|
||||
};
|
||||
MaterialSettingsList.Add(ms);
|
||||
}
|
||||
private void Delete(object parameter)
|
||||
{
|
||||
var dataGrid = parameter as DataGrid;
|
||||
var items = dataGrid.SelectedItems;
|
||||
var removeList = new List<MaterialSettings>();
|
||||
if (items.Count > 0)
|
||||
{
|
||||
if (items.Count == MaterialSettingsList.Count)
|
||||
{
|
||||
var firstElement = MaterialSettingsList.First();
|
||||
MaterialSettingsList.Clear();
|
||||
MaterialSettingsList.Add(firstElement);
|
||||
}
|
||||
foreach (MaterialSettings item in items)
|
||||
{
|
||||
removeList.Add(item);
|
||||
}
|
||||
foreach (MaterialSettings item in removeList)
|
||||
{
|
||||
MaterialSettingsList.Remove(item);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MaterialSettingsList.Count > 1)
|
||||
{
|
||||
MaterialSettingsList.RemoveAt(MaterialSettingsList.Count - 1);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < MaterialSettingsList.Count; i++)
|
||||
{
|
||||
MaterialSettingsList[i].Number = i + 1;
|
||||
}
|
||||
dataGrid.Items.Refresh();
|
||||
}
|
||||
private void CreateFunctionMaterial(object parameter)
|
||||
{
|
||||
var window = parameter as Window;
|
||||
var activeMaterialSettingsList = MaterialSettingsList.Where(x => x.IsActive == true).ToList();
|
||||
if (activeMaterialSettingsList.Count() < 1)
|
||||
{
|
||||
MessageBox.Show($"{ERROR_TEXT_1}");
|
||||
return;
|
||||
}
|
||||
var emptyFunctions = activeMaterialSettingsList.Where(x => x.Function == null).ToList();
|
||||
if (emptyFunctions.Count > 0)
|
||||
{
|
||||
var errorMessage = String.Empty;
|
||||
foreach (MaterialSettings ms in emptyFunctions)
|
||||
{
|
||||
errorMessage += $"{ms.Number}, ";
|
||||
}
|
||||
MessageBox.Show($"{ERROR_TEXT_2_1}\n{errorMessage}\n{ERROR_TEXT_2_2}");
|
||||
return;
|
||||
}
|
||||
var duplicates = activeMaterialSettingsList
|
||||
.GroupBy(x => new { x.LimitState, x.CalcTerm })
|
||||
.Where(g => g.Count() > 1)
|
||||
.ToList();
|
||||
if (duplicates.Count > 0)
|
||||
{
|
||||
var errorMessage = String.Empty;
|
||||
for (int i = 0; i < duplicates.Count; i++)
|
||||
{
|
||||
var group = duplicates[i];
|
||||
var errorNumbers = String.Empty;
|
||||
foreach (MaterialSettings ms in group)
|
||||
{
|
||||
errorNumbers += $"{ms.Number}, ";
|
||||
}
|
||||
errorMessage += $"{errorNumbers}\n";
|
||||
}
|
||||
MessageBox.Show($"{ERROR_TEXT_3_1}\n{errorMessage}\n{ERROR_TEXT_3_2}");
|
||||
return;
|
||||
}
|
||||
window.DialogResult = true;
|
||||
window.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
111
StructureHelperCommon/Windows/FunctionMaterialCreationView.xaml
Normal file
@@ -0,0 +1,111 @@
|
||||
<Window x:Class="StructureHelperCommon.Windows.FunctionMaterialCreationView"
|
||||
x:Name="FunctionMaterialCreationView_win"
|
||||
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:StructureHelperCommon.Windows"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:ens="clr-namespace:StructureHelperCommon.Infrastructures.Enums"
|
||||
mc:Ignorable="d"
|
||||
Title="FunctionMaterial" Height="250" Width="860"
|
||||
d:DataContext="{d:DesignInstance local:FunctionMaterialCreationVM}"
|
||||
Background="LightYellow">
|
||||
<Window.Resources>
|
||||
<ObjectDataProvider x:Key="LimitStates" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="ens:LimitStates"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
<ObjectDataProvider x:Key="CalcTerms" MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="ens:CalcTerms"/>
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid
|
||||
Name="DataGrid"
|
||||
Grid.ColumnSpan="6"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
Margin="10"
|
||||
ItemsSource="{Binding MaterialSettingsList}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Width="50"
|
||||
Header="№"
|
||||
IsReadOnly="True"
|
||||
Binding="{Binding Number, Mode=TwoWay}">
|
||||
</DataGridTextColumn>
|
||||
<DataGridCheckBoxColumn Width="50"
|
||||
Header="Active"
|
||||
Binding="{Binding IsActive}">
|
||||
</DataGridCheckBoxColumn>
|
||||
<DataGridComboBoxColumn Width="150"
|
||||
Header="Limit state"
|
||||
ItemsSource="{Binding Source={StaticResource LimitStates}}"
|
||||
SelectedItemBinding="{Binding LimitState}">
|
||||
</DataGridComboBoxColumn>
|
||||
<DataGridComboBoxColumn Width="150"
|
||||
Header="Calculation term"
|
||||
ItemsSource="{Binding Source={StaticResource CalcTerms}}"
|
||||
SelectedItemBinding="{Binding CalcTerm}">
|
||||
</DataGridComboBoxColumn>
|
||||
<DataGridComboBoxColumn x:Name="FunctionCB"
|
||||
Width="*"
|
||||
Header="Function"
|
||||
SelectedItemBinding="{Binding Function}">
|
||||
|
||||
</DataGridComboBoxColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<TextBlock Grid.Column="3"
|
||||
Grid.Row="2"
|
||||
Text="{Binding MODULUS_OF_ELASTYCITY}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right">
|
||||
</TextBlock>
|
||||
<TextBox Grid.Column="4"
|
||||
Grid.Row="2"
|
||||
Height="20"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Modulus}"
|
||||
>
|
||||
</TextBox>
|
||||
<Button Grid.Column="5"
|
||||
Grid.Row="3"
|
||||
Margin="10"
|
||||
Content="{Binding CREATE_MATERIAL}"
|
||||
Command="{Binding CreateFunctionMaterialCommand}"
|
||||
CommandParameter="{Binding ElementName=FunctionMaterialCreationView_win}" Click="Button_Click"/>
|
||||
<Button Grid.Column="0"
|
||||
Grid.Row="3"
|
||||
Margin="10"
|
||||
Content="{Binding ADD}"
|
||||
Background="LightGreen"
|
||||
Command="{Binding AddCommand}">
|
||||
</Button>
|
||||
<Button Grid.Column="1"
|
||||
Grid.Row="3"
|
||||
Margin="10"
|
||||
Content="{Binding DELETE}"
|
||||
Background="LightPink"
|
||||
Command="{Binding DeleteCommand}"
|
||||
CommandParameter="{Binding ElementName=DataGrid}">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,39 @@
|
||||
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 StructureHelperCommon.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FunctionMaterialCreationView.xaml
|
||||
/// </summary>
|
||||
public partial class FunctionMaterialCreationView : Window
|
||||
{
|
||||
public FunctionMaterialCreationVM ViewModel { get; set; }
|
||||
public FunctionMaterialCreationView(FunctionMaterialCreationVM viewModel)
|
||||
{
|
||||
this.ViewModel = viewModel;
|
||||
DataContext = this.ViewModel;
|
||||
InitializeComponent();
|
||||
FunctionCB.ItemsSource = viewModel.Functions;
|
||||
FunctionCB.DisplayMemberPath = "FullName";
|
||||
}
|
||||
public FunctionMaterialCreationView() : this(new FunctionMaterialCreationVM())
|
||||
{
|
||||
}
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
37
StructureHelperLogics/Models/Editors/GraphEditorAnalysis.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using StructureHelperCommon.Models.Analyses;
|
||||
using StructureHelperLogic.Models.Analyses;
|
||||
using StructureHelperLogics.Models.Analyses;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelperLogics.Models.Graphs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Editors
|
||||
{
|
||||
public class GraphEditorAnalysis : IAnalysis
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public string Tags { get; set; }
|
||||
public IVersionProcessor VersionProcessor { get; private set; }
|
||||
public GraphEditorAnalysis(Guid Id, IVersionProcessor versionProcessor)
|
||||
{
|
||||
this.Id = Id;
|
||||
VersionProcessor = versionProcessor;
|
||||
}
|
||||
public GraphEditorAnalysis() : this(Guid.NewGuid(), new VersionProcessor())
|
||||
{
|
||||
Graph graph = new Graph();
|
||||
VersionProcessor.AddVersion(graph);
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
GraphEditorAnalysis newAnalysis = new();
|
||||
//updateStrategy.Update(newAnalysis, this);
|
||||
return newAnalysis;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
StructureHelperLogics/Models/Graphs/Graph.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Graphs
|
||||
{
|
||||
internal class Graph : IGraph
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public Graph()
|
||||
{
|
||||
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
StructureHelperLogics/Models/Graphs/IGraph.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Graphs
|
||||
{
|
||||
public interface IGraph : ISaveable, ICloneable
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
using StructureHelper.Models.Materials;
|
||||
using NLog.MessageTemplates;
|
||||
using StructureHelper.Models.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Codes;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperCommon.Windows;
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
@@ -20,7 +22,8 @@ namespace StructureHelperLogics.Models.Materials
|
||||
Reinforecement500,
|
||||
Elastic200,
|
||||
Carbon1400,
|
||||
Glass1200
|
||||
Glass1200,
|
||||
Function,
|
||||
}
|
||||
|
||||
public static class HeadMaterialFactory
|
||||
@@ -37,6 +40,7 @@ namespace StructureHelperLogics.Models.Materials
|
||||
if (type == HeadmaterialType.Elastic200) { return GetElastic200(); }
|
||||
if (type == HeadmaterialType.Carbon1400) { return GetCarbon1400(); }
|
||||
if (type == HeadmaterialType.Glass1200) { return GetGlass1200(); }
|
||||
if (type == HeadmaterialType.Function) { return GetFunction(); }
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + nameof(type));
|
||||
}
|
||||
|
||||
@@ -102,5 +106,23 @@ namespace StructureHelperLogics.Models.Materials
|
||||
material.HelperMaterial = libMat;
|
||||
return material;
|
||||
}
|
||||
private static IHeadMaterial GetFunction()
|
||||
{
|
||||
var functionMaterialCreationView = new FunctionMaterialCreationView();
|
||||
functionMaterialCreationView.ShowDialog();
|
||||
var material = new HeadMaterial();
|
||||
material.HelperMaterial = new FunctionMaterial()
|
||||
{
|
||||
Modulus = functionMaterialCreationView.ViewModel.Modulus,
|
||||
CompressiveStrength = 4e8d,
|
||||
TensileStrength = 4e8d,
|
||||
MaterialSettings = functionMaterialCreationView.ViewModel.MaterialSettingsList.Where(x => x.IsActive).ToList(),
|
||||
};
|
||||
if (functionMaterialCreationView.DialogResult == true)
|
||||
{
|
||||
material.SuccessfullyCreated = true;
|
||||
}
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
53
StructureHelperLogics/Models/Materials/FunctionMaterial.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using StructureHelperLogics.Models.Materials.Logics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
public class FunctionMaterial : IFunctionMaterial
|
||||
{
|
||||
private IFunctionMaterialLogic functionMaterialLogic => new FunctionMaterialLogic();
|
||||
public double Modulus { get; set; }
|
||||
public double CompressiveStrength { get; set; }
|
||||
public double TensileStrength { get; set; }
|
||||
public List<IMaterialSafetyFactor> SafetyFactors { get; } = new();
|
||||
public IOneVariableFunction Function { get; set; }
|
||||
public List<MaterialSettings> MaterialSettings { get; set; }
|
||||
|
||||
public Guid Id { get; }
|
||||
|
||||
public FunctionMaterial(Guid id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public FunctionMaterial() : this(Guid.NewGuid())
|
||||
{
|
||||
}
|
||||
public IMaterial GetLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
var material = functionMaterialLogic.GetLoaderMaterial(this, limitState, calcTerm);
|
||||
return material;
|
||||
}
|
||||
public object Clone()
|
||||
{
|
||||
var newItem = new FunctionMaterial();
|
||||
var updateStrategy = new FunctionUpdateStrategy();
|
||||
updateStrategy.Update(newItem, this);
|
||||
return newItem;
|
||||
}
|
||||
public IMaterial GetCrackedLoaderMaterial(LimitStates limitState, CalcTerms calcTerm)
|
||||
{
|
||||
return GetLoaderMaterial(limitState, calcTerm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace StructureHelper.Models.Materials
|
||||
}
|
||||
}
|
||||
public IHelperMaterial HelperMaterial {get; set;}
|
||||
|
||||
public bool SuccessfullyCreated { get; set; } = false;
|
||||
|
||||
public HeadMaterial(Guid id)
|
||||
{
|
||||
|
||||
@@ -10,20 +10,16 @@ namespace StructureHelperLogics.Models.Materials
|
||||
public class HeadMaterialRepository : IHeadMaterialRepository
|
||||
{
|
||||
public object Parent { get; private set; }
|
||||
|
||||
public List<IHeadMaterial> HeadMaterials { get; set; }
|
||||
|
||||
public HeadMaterialRepository()
|
||||
{
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
}
|
||||
|
||||
public HeadMaterialRepository(object parent)
|
||||
{
|
||||
Parent = parent;
|
||||
HeadMaterials = new List<IHeadMaterial>();
|
||||
}
|
||||
|
||||
public void RegisterParent(object obj)
|
||||
{
|
||||
Parent = obj;
|
||||
|
||||
24
StructureHelperLogics/Models/Materials/IFunctionMaterial.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
using StructureHelperCommon.Models.Materials;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials
|
||||
{
|
||||
internal interface IFunctionMaterial : IHelperMaterial
|
||||
{
|
||||
double Modulus { get; set; }
|
||||
double CompressiveStrength { get; set; }
|
||||
double TensileStrength { get; set; }
|
||||
List<IMaterialSafetyFactor> SafetyFactors { get; }
|
||||
public List<MaterialSettings> MaterialSettings { get; set; }
|
||||
public IOneVariableFunction Function { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
internal class FunctionMaterialLogic : IFunctionMaterialLogic
|
||||
{
|
||||
private List<double> parameters;
|
||||
private IFunctionMaterial functionMaterial;
|
||||
public IMaterial GetLoaderMaterial(IFunctionMaterial functionMaterial, LimitStates limitState, CalcTerms calcTerm, double factor = 1d)
|
||||
{
|
||||
IMaterial material = new Material();
|
||||
material.InitModulus = functionMaterial.Modulus;
|
||||
functionMaterial.Function = functionMaterial.MaterialSettings
|
||||
.Where(
|
||||
x => x.LimitState.Equals(limitState)
|
||||
&&
|
||||
x.CalcTerm.Equals(calcTerm)
|
||||
)
|
||||
.Select(x => x.Function)
|
||||
.First();
|
||||
this.functionMaterial = functionMaterial;
|
||||
material.Diagram = GetStressByStrain;
|
||||
return material;
|
||||
}
|
||||
private double GetStressByStrain(IEnumerable<double> parameters1, double strain)
|
||||
{
|
||||
return functionMaterial.Function.GetByX(strain);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
internal class FunctionUpdateStrategy : IUpdateStrategy<IFunctionMaterial>
|
||||
{
|
||||
public void Update(IFunctionMaterial targetObject, IFunctionMaterial sourceObject)
|
||||
{
|
||||
CheckObject.CompareTypes(targetObject, sourceObject);
|
||||
if (ReferenceEquals(targetObject, sourceObject)) { return; }
|
||||
|
||||
/*targetObject.Modulus = sourceObject.Modulus;
|
||||
targetObject.CompressiveStrength = sourceObject.CompressiveStrength;
|
||||
targetObject.TensileStrength = sourceObject.TensileStrength;*/ //from elastic
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using LoaderCalculator.Data.Materials;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.Models.Materials.Logics
|
||||
{
|
||||
internal interface IFunctionMaterialLogic
|
||||
{
|
||||
IMaterial GetLoaderMaterial(IFunctionMaterial material, LimitStates limitState, CalcTerms calcTerm, double factor = 1d);
|
||||
}
|
||||
}
|
||||
114
StructureHelperLogics/Models/Materials/MaterialDC.cd
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="StructureHelperLogics.Models.Materials.ConcreteLibMaterial" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="9.75" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>BAACAgAQAQEBAAADEQAiBQAAAgQAAgAAAAAACAAAAhA=</HashCode>
|
||||
<FileName>Models\Materials\ConcreteLibMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="StructureHelperLogics.Models.Materials.ElasticMaterial" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="11.5" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAACAAAQgAEBAAAAAQAAAAAQAAAAAAAAAAAAAAAAABA=</HashCode>
|
||||
<FileName>Models\Materials\ElasticMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="StructureHelperLogics.Models.Materials.HeadMaterialRepository" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="9.75" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAEAAAAAIAQAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\HeadMaterialRepository.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="StructureHelperLogics.Models.Materials.LibMaterial" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="11.5" Y="1.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAACAIBQCAMBAQIAAAAABAQAAAAAAgAEAgAEAAAAAhA=</HashCode>
|
||||
<FileName>Models\Materials\LibMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Class Name="StructureHelper.Models.Materials.HeadMaterial" Collapsed="true" BaseTypeListCollapsed="true">
|
||||
<Position X="13.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAACAIAUAAABAAAAEAAAAAQAgAAAAACAAAAAgAAAABA=</HashCode>
|
||||
<FileName>Models\Materials\HeadMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<Lollipop Position="0.2" Collapsed="true" />
|
||||
</Class>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IConcreteLibMaterial" Collapsed="true">
|
||||
<Position X="7.25" Y="5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAQAAAQAAAgAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IConcreteLibMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IElasticMaterial">
|
||||
<Position X="3.25" Y="2" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAgAEAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IElasticMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IHasHeadMaterials" Collapsed="true">
|
||||
<Position X="9.75" Y="2.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IHasHeadMaterials.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IHeadMaterialRepository" Collapsed="true">
|
||||
<Position X="13.25" Y="2.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAEAAAAAIAQAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IHeadMaterialRepository.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IHelperMaterial" Collapsed="true">
|
||||
<Position X="3.25" Y="0.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAQAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IHelperMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.ILibMaterial">
|
||||
<Position X="6" Y="2" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAEAAAAAAAAABAAAAAAAAgAAAAAAAAAAAgA=</HashCode>
|
||||
<FileName>Models\Materials\ILibMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IMaterialOptionLogic" Collapsed="true">
|
||||
<Position X="9.75" Y="3.5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IMaterialOptionLogic.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IReinforcementLibMaterial">
|
||||
<Position X="5" Y="5" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IReinforcementLibMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelper.Models.Materials.IHeadMaterial" Collapsed="true">
|
||||
<Position X="11.5" Y="2.75" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAUAAABAAAAAAAAAAQAAAAAAAAAAAAAgAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IHeadMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Interface Name="StructureHelperLogics.Models.Materials.IFunctionMaterial">
|
||||
<Position X="0.75" Y="2" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAAAAgAEAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>Models\Materials\IFunctionMaterial.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Interface>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
@@ -1,5 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -34,5 +33,4 @@
|
||||
<Folder Include="FunctionalTests\RCs\Anchorage\" />
|
||||
<Folder Include="UnitTests\WindowTests\Calculations\CalculationProperties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,24 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperTests.UnitTests.Interpolation
|
||||
{
|
||||
public class InterpolationTest
|
||||
{
|
||||
[TestCase(1.5, 5.5, 1, 2, 5, 6)] //Interpolation
|
||||
[TestCase(9, 4, 6, 8, 1, 3)] //Extrapolation
|
||||
public void InterpolationTestMethod(double x, double y, double x1, double x2, double y1, double y2)
|
||||
{
|
||||
//Arrange
|
||||
//Act
|
||||
var result = StructureHelperCommon.Services.MathUtils.Interpolation(x, x1, x2, y1, y2);
|
||||
//Assert
|
||||
Assert.AreEqual(result, y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||