Converter error was fixed
This commit is contained in:
@@ -33,7 +33,7 @@ namespace StructureHelper.Infrastructure.UI.Converters
|
||||
public static IStringDoublePair DivideIntoStringDoublePair(string s)
|
||||
{
|
||||
s = s.Replace(" ", "");
|
||||
string digitPattern = @"\d+(\.?|\,?)\d+";
|
||||
string digitPattern = @"\d+(\.?|\,?)\d*";
|
||||
string textPattern = @"[0-9]|\.|\,";
|
||||
string caracterPattern = "[a-z]+$";
|
||||
string target = "";
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Area : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Area; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "mm2"); }
|
||||
public override string unitName { get => "Area"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Area; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm2"); }
|
||||
public override string UnitName { get => "Area"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Curvature : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Curvature; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "1/mm"); }
|
||||
public override string unitName { get => "Curvature"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Curvature; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "1/mm"); }
|
||||
public override string UnitName { get => "Curvature"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Force : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Force; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "kN"); }
|
||||
public override string unitName { get => "Force"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Force; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kN"); }
|
||||
public override string UnitName { get => "Force"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Length : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Length; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "mm"); }
|
||||
public override string unitName { get => "Length"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Length; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "mm"); }
|
||||
public override string UnitName { get => "Length"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Moment : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Moment; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "kNm"); }
|
||||
public override string unitName { get => "Moment"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Moment; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "kNm"); }
|
||||
public override string UnitName { get => "Moment"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal class Stress : UnitBase
|
||||
{
|
||||
public override UnitTypes unitType { get => UnitTypes.Stress; }
|
||||
public override IUnit currentUnit { get => CommonOperation.GetUnit(unitType, "MPa"); }
|
||||
public override string unitName { get => "Stress"; }
|
||||
public override UnitTypes UnitType { get => UnitTypes.Stress; }
|
||||
public override IUnit CurrentUnit { get => CommonOperation.GetUnit(UnitType, "MPa"); }
|
||||
public override string UnitName { get => "Stress"; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,22 +7,33 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters.Units
|
||||
{
|
||||
internal abstract class UnitBase : IValueConverter
|
||||
{
|
||||
public abstract UnitTypes unitType { get; }
|
||||
public abstract IUnit currentUnit { get; }
|
||||
public abstract string unitName { get;}
|
||||
public abstract UnitTypes UnitType { get; }
|
||||
public abstract IUnit CurrentUnit { get; }
|
||||
public abstract string UnitName { get;}
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return CommonOperation.Convert(currentUnit, unitName, value);
|
||||
return CommonOperation.Convert(CurrentUnit, UnitName, value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return CommonOperation.ConvertBack(unitType, currentUnit, value);
|
||||
try
|
||||
{
|
||||
return CommonOperation.ConvertBack(UnitType, CurrentUnit, value);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show($"Value of {UnitName}={(string)value} is not correct", "Error of conversion", MessageBoxButtons.OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
set
|
||||
{
|
||||
primitive.Area = value;
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
RefreshPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,5 +42,15 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
|
||||
private void RefreshPlacement()
|
||||
{
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
59
Models/Forces/ForceTupleViewObject.cs
Normal file
59
Models/Forces/ForceTupleViewObject.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Models.Forces
|
||||
{
|
||||
internal class ForceTupleViewObject
|
||||
{
|
||||
IForceTuple forceTuple;
|
||||
|
||||
private double mx;
|
||||
|
||||
public double Mx
|
||||
{
|
||||
get { return mx; }
|
||||
set { mx = value; }
|
||||
}
|
||||
private double my;
|
||||
|
||||
public double My
|
||||
{
|
||||
get { return my; }
|
||||
set { my = value; }
|
||||
}
|
||||
private double nz;
|
||||
|
||||
public double Nz
|
||||
{
|
||||
get { return nz; }
|
||||
set { nz = value; }
|
||||
}
|
||||
private double qx;
|
||||
|
||||
public double Qx
|
||||
{
|
||||
get { return qx; }
|
||||
set { qx = value; }
|
||||
}
|
||||
private double qy;
|
||||
|
||||
public double Qy
|
||||
{
|
||||
get { return qy; }
|
||||
set { qy = value; }
|
||||
}
|
||||
private double mz;
|
||||
|
||||
public double Mz
|
||||
{
|
||||
get { return mz; }
|
||||
set { mz = value; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,7 @@
|
||||
<Compile Include="Infrastructure\UI\UserControls\PrimitivePopup.xaml.cs">
|
||||
<DependentUpon>PrimitivePopup.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Forces\ForceTupleViewObject.cs" />
|
||||
<Compile Include="Models\Primitives\Factories\PrimitiveFactory.cs" />
|
||||
<Compile Include="Services\Primitives\PrimitiveRepository.cs" />
|
||||
<Compile Include="Services\Primitives\IPrimitiveRepository.cs" />
|
||||
@@ -201,6 +202,12 @@
|
||||
<Compile Include="Infrastructure\UI\DataTemplates\EllipseTemplate.xaml.cs">
|
||||
<DependentUpon>EllipseTemplate.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Forces\ForceCombinationView.xaml.cs">
|
||||
<DependentUpon>ForceCombinationView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Forces\ForceTupleControl.xaml.cs">
|
||||
<DependentUpon>ForceTupleControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\MainWindow\MainModel.cs" />
|
||||
<Compile Include="Windows\MainWindow\MainView.xaml.cs" />
|
||||
<Compile Include="Windows\MainWindow\MainViewModel.cs" />
|
||||
@@ -286,6 +293,14 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\Forces\ForceCombinationView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\Forces\ForceTupleControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\MainWindow\MainView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -336,5 +351,6 @@
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -39,9 +39,9 @@
|
||||
SelectedItem="{Binding Path=SelectedCombination}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="Active" Binding="{Binding Path=TakeInCalculate}"/>
|
||||
<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding Path=ForceMatrix.Mx, Converter={StaticResource MomentConverter}}"/>
|
||||
<DataGridTextColumn Header="Moment My" Width="90" Binding="{Binding Path=ForceMatrix.My, Converter={StaticResource MomentConverter}}"/>
|
||||
<DataGridTextColumn Header="Force Nz" Width="90" Binding="{Binding Path=ForceMatrix.Nz, Converter={StaticResource ForceConverter}}"/>
|
||||
<DataGridTextColumn Header="Moment Mx" Width="90" Binding="{Binding Path=ForceMatrix.Mx, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Moment My" Width="90" Binding="{Binding Path=ForceMatrix.My, Converter={StaticResource MomentConverter}, ValidatesOnExceptions=True}"/>
|
||||
<DataGridTextColumn Header="Force Nz" Width="90" Binding="{Binding Path=ForceMatrix.Nz, Converter={StaticResource ForceConverter}, ValidatesOnExceptions=True}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Column="1">
|
||||
|
||||
40
Windows/Forces/ForceCombinationView.xaml
Normal file
40
Windows/Forces/ForceCombinationView.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<Window x:Class="StructureHelper.Windows.Forces.ForceCombinationView"
|
||||
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.Forces"
|
||||
mc:Ignorable="d"
|
||||
Title="Force Combination" Height="250" Width="450" MinHeight="300" MinWidth="400">
|
||||
<TabControl>
|
||||
<TabItem Header="Forces">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" MinHeight="25"/>
|
||||
<RowDefinition Height="Auto" MinHeight="25"/>
|
||||
<RowDefinition Height="Auto" MinHeight="25"/>
|
||||
<RowDefinition Height="Auto" MinHeight="25"/>
|
||||
<RowDefinition Height="Auto" MinHeight="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.RowSpan="2" Text="Ultimate limit state"/>
|
||||
<TextBlock Grid.Column="1" Text="Short term"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="Long term"/>
|
||||
<TextBlock Grid.Row="2" Grid.RowSpan="2" Text="Ultimate limit state"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="Short term"/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="Long term"/>
|
||||
<local:ForceTupleControl Grid.Column="2"/>
|
||||
<local:ForceTupleControl Grid.Row="1" Grid.Column="2"/>
|
||||
<local:ForceTupleControl Grid.Row="2" Grid.Column="2"/>
|
||||
<local:ForceTupleControl Grid.Row="3" Grid.Column="2"/>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="Additional">
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
27
Windows/Forces/ForceCombinationView.xaml.cs
Normal file
27
Windows/Forces/ForceCombinationView.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.Forces
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ForceCombinationView.xaml
|
||||
/// </summary>
|
||||
public partial class ForceCombinationView : Window
|
||||
{
|
||||
public ForceCombinationView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Windows/Forces/ForceTupleControl.xaml
Normal file
26
Windows/Forces/ForceTupleControl.xaml
Normal file
@@ -0,0 +1,26 @@
|
||||
<UserControl x:Class="StructureHelper.Windows.Forces.ForceTupleControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.Forces"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="70"/>
|
||||
<ColumnDefinition Width="Auto" MinWidth="70"/>
|
||||
<ColumnDefinition Width="Auto" MinWidth="70"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" MinHeight="20"/>
|
||||
<RowDefinition Height="Auto" MinHeight="20"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock HorizontalAlignment="Center" Text="Mx"/>
|
||||
<TextBlock HorizontalAlignment="Center" Grid.Column="1" Text="My"/>
|
||||
<TextBlock HorizontalAlignment="Center" Grid.Column="2" Text="Nz"/>
|
||||
<TextBox Grid.Row="1" Text=""/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text=""/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Text=""/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
28
Windows/Forces/ForceTupleControl.xaml.cs
Normal file
28
Windows/Forces/ForceTupleControl.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace StructureHelper.Windows.Forces
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для ForceTupleControl.xaml
|
||||
/// </summary>
|
||||
public partial class ForceTupleControl : UserControl
|
||||
{
|
||||
public ForceTupleControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,11 @@
|
||||
<TextBlock Grid.Row="2" Text="Bottom Diameter"/>
|
||||
<TextBlock Grid.Row="3" Text="Width count"/>
|
||||
<TextBlock Grid.Row="4" Text="Height count"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding CoverGap, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding TopDiameter, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding BottomDiameter, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding WidthCount, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding HeightCount, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding CoverGap, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding TopDiameter, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding BottomDiameter, Converter={StaticResource LengthConverter}, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding WidthCount, ValidatesOnExceptions=True}"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Margin="1" Style="{StaticResource ValidatedError}" Text="{Binding HeightCount, ValidatesOnExceptions=True}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
|
||||
Reference in New Issue
Block a user