Geometry property results have been added
This commit is contained in:
@@ -1,100 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using StructureHelper.Infrastructure.UI.Converters.Units;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters
|
||||
{
|
||||
internal static class CommonOperation
|
||||
{
|
||||
private static IEnumerable<IUnit> units = UnitsFactory.GetUnitCollection();
|
||||
|
||||
public static double ConvertToDoubleChangeComma(string s)
|
||||
{
|
||||
double result;
|
||||
if (!double.TryParse(s, NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
|
||||
!double.TryParse(s, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
|
||||
!double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
|
||||
{
|
||||
throw new StructureHelperException($"{ErrorStrings.IncorrectValue}: {s}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IStringDoublePair DivideIntoStringDoublePair(string s)
|
||||
{
|
||||
s = s.Replace(" ", "");
|
||||
string digitPattern = @"^[-]?[+]?\d+(\.?|\,?)\d*";
|
||||
string textPattern = @"[0-9]|\.|\,";
|
||||
string caracterPattern = "[a-z]+$";
|
||||
string target = "";
|
||||
Regex regexText = new Regex(textPattern);
|
||||
string textString = regexText.Replace(s, target);
|
||||
var textMatch = Regex.Match(textString, caracterPattern, RegexOptions.IgnoreCase);
|
||||
if (textMatch.Success) {textString = textMatch.Value.ToLower();}
|
||||
var match = Regex.Match(s, digitPattern);
|
||||
if (match.Success)
|
||||
{
|
||||
string digitString = match.Value;
|
||||
double digit = ConvertToDoubleChangeComma(digitString);
|
||||
return new StringDoublePair() { Digit = digit, Text = textString };
|
||||
}
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect);
|
||||
}
|
||||
|
||||
public static IUnit GetUnit(UnitTypes unitType, string unitName)
|
||||
{
|
||||
return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single();
|
||||
}
|
||||
|
||||
public static string Convert(IUnit unit, string unitName, object value)
|
||||
{
|
||||
double val;
|
||||
if (value != null) { val = (double)value; }
|
||||
else { throw new Exception($"{unitName} value is null"); }
|
||||
val *= unit.Multiplyer;
|
||||
string strValue = $"{val} {unit.Name}";
|
||||
return strValue;
|
||||
}
|
||||
|
||||
public static double ConvertBack(UnitTypes unitType, IUnit unit, object value)
|
||||
{
|
||||
double val;
|
||||
double multy;
|
||||
double coefficient = unit.Multiplyer;
|
||||
var strVal = value as string;
|
||||
IStringDoublePair pair = DivideIntoStringDoublePair(strVal);
|
||||
try
|
||||
{
|
||||
multy = GetMultiplyer(unitType, pair.Text);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
multy = coefficient;
|
||||
}
|
||||
val = pair.Digit / multy;
|
||||
return val;
|
||||
}
|
||||
|
||||
private static double GetMultiplyer(UnitTypes unitType, string unitName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return units.Where(u => u.UnitType == unitType & u.Name == unitName).Single().Multiplyer;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters
|
||||
{
|
||||
internal interface IStringDoublePair
|
||||
{
|
||||
double Digit { get; }
|
||||
string Text { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.Converters
|
||||
{
|
||||
internal class StringDoublePair : IStringDoublePair
|
||||
{
|
||||
public double Digit { get; set; }
|
||||
public string Text { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Services.Units;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
Binary file not shown.
@@ -9,6 +9,9 @@
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Windows\Errors\ErrorMessage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -35,6 +38,9 @@
|
||||
<Page Update="Infrastructure\UI\Resources\Materials.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\CalculationWindows\CalculatorsViews\GeometryCalculator\GeometryCalculatorResultView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="Windows\Errors\ErrorMessage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<DataGridTextColumn Header="EpsZ" Width="90" Binding="{Binding LoaderResults.ForceStrainPair.StrainMatrix.EpsZ}"/>
|
||||
<DataGridTextColumn Header="Accuracy" Width="90" Binding="{Binding LoaderResults.AccuracyRate}"/>
|
||||
<DataGridTextColumn Header="Max Iteration" Width="90" Binding="{Binding LoaderResults.IterationCounter}"/>
|
||||
<DataGridTextColumn Header="Description" Width="300" Binding="{Binding Desctription}"/>
|
||||
<DataGridTextColumn Header="Description" Width="300" Binding="{Binding Description}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<StackPanel Grid.Column="1">
|
||||
@@ -44,6 +44,7 @@
|
||||
<Button Margin="3" Content="Export" ToolTip="Export results to *.csv" Command="{Binding ExportToCSVCommand}"/>
|
||||
<Button Margin="3" Content="Set Prestrain" ToolTip="Set strains as auto prestrain" Command="{Binding SetPrestrainCommand}"/>
|
||||
<Button Margin="3" Content="Anchorage" ToolTip="Set strains as auto prestrain" Command="{Binding ShowAnchorageCommand}"/>
|
||||
<Button Margin="3" Content="Geometry" ToolTip="Show Geometry Properties" Command="{Binding ShowGeometryResultCommand}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<Window x:Class="StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator.GeometryCalculatorResultView"
|
||||
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.CalculationWindows.CalculatorsViews.GeometryCalculator"
|
||||
xmlns:vm="clr-namespace:StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance vm:GeometryCalculatorResultViewModel}"
|
||||
Title="Geometry Properies" Height="450" Width="850" WindowStartupLocation="CenterScreen">
|
||||
<Grid>
|
||||
<DataGrid x:Name="ResultGrid" IsReadOnly="True" AutoGenerateColumns="False" ItemsSource="{Binding TextParameters}">
|
||||
<DataGrid.RowStyle>
|
||||
<Style TargetType="DataGridRow">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsValid}" Value="false">
|
||||
<Setter Property="Background" Value="Pink"/>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridCheckBoxColumn Header="Valid" Binding="{Binding Path=IsValid}"/>
|
||||
<DataGridTextColumn Header="Name" Width="100" Binding="{Binding Name}"/>
|
||||
<DataGridTextColumn Header="Short" Width="50" Binding="{Binding ShortName}"/>
|
||||
<DataGridTextColumn Header="Unit" Width="100" Binding="{Binding MeasurementUnit}"/>
|
||||
<DataGridTextColumn Header="Value" Width="150" Binding="{Binding Value}"/>
|
||||
<DataGridTextColumn Header="Description" Width="400" Binding="{Binding Description}"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,32 @@
|
||||
using StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
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.CalculationWindows.CalculatorsViews.GeometryCalculator
|
||||
{
|
||||
/// <summary>
|
||||
/// Логика взаимодействия для GeometryCalculatorResultView.xaml
|
||||
/// </summary>
|
||||
public partial class GeometryCalculatorResultView : Window
|
||||
{
|
||||
GeometryCalculatorResultViewModel viewModel;
|
||||
public GeometryCalculatorResultView(List<ITextParameter> textParameters)
|
||||
{
|
||||
viewModel = new GeometryCalculatorResultViewModel(textParameters);
|
||||
InitializeComponent();
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,13 +98,25 @@
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Expander>
|
||||
<Expander Header="Materials" MinWidth="20">
|
||||
<Expander Header="Materials" MinWidth="20" DataContext="{Binding MaterialsLogic}">
|
||||
<Expander.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Materials" Command="{Binding EditHeadMaterialsCommand}"/>
|
||||
<Button Content="Materials" Command="{Binding EditMaterialsCommand}"/>
|
||||
<MenuItem Header="Add">
|
||||
<Button Content="Concrete" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Concrete}"/>
|
||||
<Button Content="Reinforcement" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Reinforcement}"/>
|
||||
<Button Content="Elastic" Command="{Binding Add}" CommandParameter="{x:Static enums:MaterialType.Elastic}"/>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</Expander.ContextMenu>
|
||||
<ListBox ItemsSource="{Binding HeadMaterials}" ItemTemplate="{StaticResource ColoredItemTemplate}">
|
||||
<ListBox ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" ItemTemplate="{StaticResource ColoredItemTemplate}">
|
||||
<ListBox.ContextMenu>
|
||||
<ContextMenu>
|
||||
<Button Content="Edit" Command="{Binding Edit}"/>
|
||||
<Button Content="Copy" Command="{Binding Copy}"/>
|
||||
<Button Content="Delete" Command="{Binding Delete}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.ContextMenu>
|
||||
</ListBox>
|
||||
</Expander>
|
||||
<Expander Header="Geometry" MinWidth="20" DataContext="{Binding PrimitiveLogic}">
|
||||
|
||||
@@ -6,7 +6,9 @@ using StructureHelper.Windows.ColorPickerWindow;
|
||||
using StructureHelper.Windows.MainWindow.Materials;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.Beams;
|
||||
using StructureHelper.Windows.PrimitiveTemplates.RCs.RectangleBeam;
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelper.Windows.ViewModels.Forces;
|
||||
using StructureHelper.Windows.ViewModels.Materials;
|
||||
using StructureHelper.Windows.ViewModels.NdmCrossSections;
|
||||
using StructureHelperCommon.Infrastructures.Enums;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
@@ -40,6 +42,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
private readonly AnalysisVewModelLogic calculatorsLogic;
|
||||
public AnalysisVewModelLogic CalculatorsLogic { get => calculatorsLogic;}
|
||||
public ActionsViewModel CombinationsLogic { get => combinationsLogic; }
|
||||
public MaterialsViewModel MaterialsLogic { get => materialsLogic; }
|
||||
public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
|
||||
public HelpLogic HelpLogic => new HelpLogic();
|
||||
|
||||
@@ -153,11 +156,13 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public ICommand EditCalculationPropertyCommand { get; }
|
||||
public ICommand EditHeadMaterialsCommand { get; }
|
||||
public ICommand AddRCCircleCase
|
||||
{ get
|
||||
{
|
||||
get
|
||||
{
|
||||
return new RelayCommand(o =>
|
||||
{
|
||||
PrimitiveLogic.AddItems(GetRCCirclePrimitives());
|
||||
materialsLogic.Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -215,6 +220,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
private PrimitiveViewModelLogic primitiveLogic;
|
||||
private RelayCommand showVisualProperty;
|
||||
private RelayCommand selectPrimitive;
|
||||
private MaterialsViewModel materialsLogic;
|
||||
|
||||
public MainViewModel(MainModel model)
|
||||
{
|
||||
@@ -222,6 +228,8 @@ namespace StructureHelper.Windows.MainWindow
|
||||
Model = model;
|
||||
section = model.Section;
|
||||
combinationsLogic = new ActionsViewModel(repository);
|
||||
materialsLogic = new MaterialsViewModel(repository);
|
||||
materialsLogic.AfterItemsEdit += afterMaterialEdit;
|
||||
calculatorsLogic = new AnalysisVewModelLogic(repository);
|
||||
primitiveLogic = new PrimitiveViewModelLogic(section) { CanvasWidth = CanvasWidth, CanvasHeight = CanvasHeight };
|
||||
XX2 = CanvasWidth;
|
||||
@@ -253,7 +261,6 @@ namespace StructureHelper.Windows.MainWindow
|
||||
rect.PrimitiveHeight = PanelY - rect.PrimitiveTop + 10d;
|
||||
}
|
||||
});
|
||||
EditHeadMaterialsCommand = new RelayCommand(o => EditHeadMaterials());
|
||||
|
||||
SetColor = new RelayCommand(o =>
|
||||
{
|
||||
@@ -279,16 +286,19 @@ namespace StructureHelper.Windows.MainWindow
|
||||
AddBeamCase = new RelayCommand(o =>
|
||||
{
|
||||
PrimitiveLogic.AddItems(GetBeamCasePrimitives());
|
||||
materialsLogic.Refresh();
|
||||
});
|
||||
|
||||
AddColumnCase = new RelayCommand(o =>
|
||||
{
|
||||
PrimitiveLogic.AddItems(GetColumnCasePrimitives());
|
||||
materialsLogic.Refresh();
|
||||
});
|
||||
|
||||
AddSlabCase = new RelayCommand(o =>
|
||||
{
|
||||
PrimitiveLogic.AddItems(GetSlabCasePrimitives());
|
||||
materialsLogic.Refresh();
|
||||
});
|
||||
|
||||
MovePrimitiveToGravityCenterCommand = new RelayCommand(o =>
|
||||
@@ -318,11 +328,8 @@ namespace StructureHelper.Windows.MainWindow
|
||||
});
|
||||
}
|
||||
|
||||
private void EditHeadMaterials()
|
||||
private void afterMaterialEdit(CRUDViewModelBase<IHeadMaterial> sender, CRUDVMEventArgs e)
|
||||
{
|
||||
var wnd = new HeadMaterialsView(repository);
|
||||
wnd.ShowDialog();
|
||||
OnPropertyChanged(nameof(HeadMaterials));
|
||||
foreach (var primitive in primitiveLogic.Items)
|
||||
{
|
||||
primitive.RefreshColor();
|
||||
|
||||
@@ -10,10 +10,16 @@
|
||||
Title="Select Primitives" Height="250" Width="250" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="35"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox ItemsSource="{Binding Items.CollectionItems}" SelectedItem="Items.SelectedItem">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Content="Select All" Command="{Binding Items.SelectAllCommand}"/>
|
||||
<Button Content="Unselect All" Command="{Binding Items.UnSelectAllCommand}"/>
|
||||
<Button Content="Invert Selection" Command="{Binding Items.InvertSelectionCommand}"/>
|
||||
</StackPanel>
|
||||
<ListBox Grid.Row="1" ItemsSource="{Binding Items.CollectionItems}" SelectedItem="Items.SelectedItem">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
@@ -27,7 +33,7 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Style="{StaticResource CancelButton}"/>
|
||||
<Button Style="{StaticResource OkButton}" Click="Button_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
12
StructureHelper/Windows/ViewModels/CRUDVMEventArgs.cs
Normal file
12
StructureHelper/Windows/ViewModels/CRUDVMEventArgs.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public class CRUDVMEventArgs
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using Microsoft.VisualBasic;
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Materials.Libraries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,7 +14,6 @@ namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public abstract class CRUDViewModelBase<TItem> : ViewModelBase, ICRUDViewModel<TItem> where TItem : class
|
||||
{
|
||||
|
||||
private ICommand addCommand;
|
||||
private ICommand deleteCommand;
|
||||
private ICommand copyCommand;
|
||||
@@ -83,6 +83,7 @@ namespace StructureHelper.Windows.ViewModels
|
||||
Items.Add(item);
|
||||
}
|
||||
OnPropertyChanged(nameof(Items));
|
||||
AfterItemsEdit?.Invoke(this, new CRUDVMEventArgs());
|
||||
}
|
||||
|
||||
public ICommand Copy
|
||||
@@ -113,15 +114,19 @@ namespace StructureHelper.Windows.ViewModels
|
||||
Items.Add(item);
|
||||
}
|
||||
}
|
||||
public CRUDViewModelBase()
|
||||
{
|
||||
Items = new ObservableCollection<TItem>();
|
||||
}
|
||||
|
||||
public CRUDViewModelBase(List<TItem> collection)
|
||||
{
|
||||
Collection = collection;
|
||||
Items = new ObservableCollection<TItem>(collection);
|
||||
Refresh();
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
Items = new ObservableCollection<TItem>(Collection);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
AfterItemsEdit?.Invoke(this, new CRUDVMEventArgs());
|
||||
}
|
||||
public delegate void CRUDHandler(CRUDViewModelBase<TItem> sender, CRUDVMEventArgs e);
|
||||
public event CRUDHandler? AfterItemsEdit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using StructureHelper.Services.Reports.CalculationReports;
|
||||
using StructureHelper.Services.ResultViewers;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.ForceCalculatorViews;
|
||||
using StructureHelper.Windows.CalculationWindows.CalculatorsViews.GeometryCalculator;
|
||||
using StructureHelper.Windows.Errors;
|
||||
using StructureHelper.Windows.Forces;
|
||||
using StructureHelper.Windows.PrimitivePropertiesWindow;
|
||||
@@ -50,6 +51,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
private RelayCommand interpolateCommand;
|
||||
private RelayCommand setPrestrainCommand;
|
||||
private ICommand showAnchorageCommand;
|
||||
private ICommand showGeometryResultCommand;
|
||||
|
||||
public IForcesResults ForcesResults
|
||||
{
|
||||
@@ -63,13 +65,8 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
return showIsoFieldCommand ??
|
||||
(showIsoFieldCommand = new RelayCommand(o =>
|
||||
{
|
||||
var vm = new SelectPrimitivesViewModel(ndmPrimitives);
|
||||
var wnd = new SelectPrimitivesView(vm);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
if (SelectPrimitives() == true)
|
||||
{
|
||||
selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
|
||||
GetNdms();
|
||||
ShowIsoField();
|
||||
}
|
||||
}, o => (SelectedResult != null) && SelectedResult.IsValid));
|
||||
@@ -169,7 +166,7 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
var result = calculator.Result;
|
||||
if (result is null || result.IsValid == false)
|
||||
{
|
||||
MessageBox.Show(result.Desctription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -215,11 +212,10 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
(showAnchorageCommand = new RelayCommand(o =>
|
||||
{
|
||||
showAnchorage();
|
||||
}, o => SelectedResult != null
|
||||
}, o => SelectedResult != null && SelectedResult.IsValid
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void showAnchorage()
|
||||
{
|
||||
try
|
||||
@@ -239,7 +235,33 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
DetailText = $"{ex}"};
|
||||
new ErrorMessage(vm).ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand ShowGeometryResultCommand =>
|
||||
showGeometryResultCommand ??= new RelayCommand(o =>
|
||||
showGeometryResult(), o => SelectedResult != null && SelectedResult.IsValid);
|
||||
private void showGeometryResult()
|
||||
{
|
||||
if (SelectPrimitives() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strainMatrix = SelectedResult.LoaderResults.ForceStrainPair.StrainMatrix;
|
||||
var textParametrsLogic = new TextParametersLogic(ndms, strainMatrix);
|
||||
var textParameters = textParametrsLogic.GetTextParameters();
|
||||
var wnd = new GeometryCalculatorResultView(textParameters);
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var vm = new ErrorProcessor()
|
||||
{
|
||||
ShortText = "Errors apearred during showing isofield, see detailed information",
|
||||
DetailText = $"{ex}"
|
||||
};
|
||||
new ErrorMessage(vm).ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ForcesResultsViewModel(IForceCalculator forceCalculator)
|
||||
@@ -269,7 +291,6 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GetNdms()
|
||||
{
|
||||
var limitState = SelectedResult.DesignForceTuple.LimitState;
|
||||
@@ -293,5 +314,19 @@ namespace StructureHelper.Windows.ViewModels.Calculations.Calculators
|
||||
}
|
||||
ndms = ndmRange;
|
||||
}
|
||||
|
||||
private bool SelectPrimitives()
|
||||
{
|
||||
var vm = new SelectPrimitivesViewModel(ndmPrimitives);
|
||||
var wnd = new SelectPrimitivesView(vm);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
selectedNdmPrimitives = vm.Items.CollectionItems.Where(x => x.IsSelected == true).Select(x => x.Item.GetNdmPrimitive());
|
||||
GetNdms();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using StructureHelper.Infrastructure;
|
||||
using StructureHelperCommon.Models.Parameters;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Calculations.Calculators.GeometryCalculator
|
||||
{
|
||||
internal class GeometryCalculatorResultViewModel : ViewModelBase
|
||||
{
|
||||
private List<ITextParameter> textParameters;
|
||||
|
||||
public List<ITextParameter> TextParameters
|
||||
{ get => textParameters;
|
||||
|
||||
}
|
||||
public GeometryCalculatorResultViewModel(List<ITextParameter> textParameters)
|
||||
{
|
||||
this.textParameters = textParameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,40 @@ using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
|
||||
using System.Windows.Forms;
|
||||
using StructureHelperLogics.Models.CrossSections;
|
||||
using StructureHelper.Infrastructure;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.Materials
|
||||
{
|
||||
internal class MaterialsViewModel : CRUDViewModelBase<IHeadMaterial>
|
||||
public class MaterialsViewModel : CRUDViewModelBase<IHeadMaterial>
|
||||
{
|
||||
ICrossSectionRepository repository;
|
||||
private ICommand editMaterialsCommand;
|
||||
|
||||
public ICommand EditMaterialsCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return editMaterialsCommand ??
|
||||
(
|
||||
editMaterialsCommand = new RelayCommand(o => EditHeadMaterials())
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
public MaterialsViewModel(ICrossSectionRepository repository) : base(repository.HeadMaterials)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
public override void AddMethod(object parameter)
|
||||
{
|
||||
CheckParameters(parameter);
|
||||
@@ -28,9 +52,19 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
}
|
||||
public override void DeleteMethod(object parameter)
|
||||
{
|
||||
#error
|
||||
//to do delete method
|
||||
base.DeleteMethod(parameter);
|
||||
var primitives = repository.Primitives;
|
||||
var primitivesWithMaterial = primitives.Where(x => x.HeadMaterial == SelectedItem);
|
||||
int primitivesCount = primitivesWithMaterial.Count();
|
||||
if (primitivesCount > 0)
|
||||
{
|
||||
MessageBox.Show("Some primitives reference to this material", "Material can not be deleted", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
var dialogResult = MessageBox.Show("Delete material?", "Please, confirm deleting", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
{
|
||||
base.DeleteMethod(parameter);
|
||||
}
|
||||
}
|
||||
public override void EditMethod(object parameter)
|
||||
{
|
||||
@@ -38,7 +72,6 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
wnd.ShowDialog();
|
||||
base.EditMethod(parameter);
|
||||
}
|
||||
|
||||
private void AddElastic()
|
||||
{
|
||||
var material = HeadMaterialFactory.GetHeadMaterial(HeadmaterialType.Elastic200, ProgramSetting.CodeType);
|
||||
@@ -62,5 +95,11 @@ namespace StructureHelper.Windows.ViewModels.Materials
|
||||
if (parameter is null) { throw new StructureHelperException(ErrorStrings.ParameterIsNull); }
|
||||
if (parameter is not MaterialType) { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown + $". Expected: {typeof(MaterialType)} . Actual type: {nameof(parameter)}"); }
|
||||
}
|
||||
private void EditHeadMaterials()
|
||||
{
|
||||
var wnd = new HeadMaterialsView(repository);
|
||||
wnd.ShowDialog();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
var result = SelectedItem.Result;
|
||||
if (result.IsValid == false)
|
||||
{
|
||||
MessageBox.Show(result.Desctription, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
MessageBox.Show(result.Description, "Check data for analisys", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,19 +1,37 @@
|
||||
using System;
|
||||
using StructureHelper.Infrastructure;
|
||||
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.Input;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels
|
||||
{
|
||||
public class SelectItemsViewModel<TItem>
|
||||
public class SelectItemsViewModel<TItem> : ViewModelBase
|
||||
where TItem : class
|
||||
{
|
||||
public class CollectionItem
|
||||
private ICommand? selectAllCommand;
|
||||
private ICommand? unSelectAllCommand;
|
||||
private ICommand? invertSelectionCommand;
|
||||
|
||||
public class CollectionItem : ViewModelBase
|
||||
{
|
||||
public bool IsSelected { get; set; }
|
||||
bool isSelected;
|
||||
public bool IsSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
return isSelected;
|
||||
}
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
public TItem Item { get; set; }
|
||||
}
|
||||
|
||||
@@ -21,6 +39,45 @@ namespace StructureHelper.Windows.ViewModels
|
||||
|
||||
public ObservableCollection<CollectionItem> CollectionItems { get; }
|
||||
|
||||
public ICommand SelectAllCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return selectAllCommand ??= new RelayCommand(o => setIsSelected(true));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand UnSelectAllCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return unSelectAllCommand ??= new RelayCommand(o => setIsSelected(false));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand InvertSelectionCommand
|
||||
{
|
||||
get
|
||||
{
|
||||
return invertSelectionCommand ??= new RelayCommand(o =>
|
||||
{
|
||||
foreach (var item in CollectionItems)
|
||||
{
|
||||
item.IsSelected = !item.IsSelected;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void setIsSelected(bool isSelected)
|
||||
{
|
||||
foreach (var item in CollectionItems)
|
||||
{
|
||||
item.IsSelected = isSelected;
|
||||
}
|
||||
}
|
||||
|
||||
public SelectItemsViewModel(IEnumerable<TItem> items)
|
||||
{
|
||||
CollectionItems = new ObservableCollection<CollectionItem>();
|
||||
|
||||
Reference in New Issue
Block a user