Copy To window was added
This commit is contained in:
@@ -22,8 +22,8 @@ namespace StructureHelper
|
||||
builder.RegisterType<PrimitiveRepository>().As<IPrimitiveRepository>().SingleInstance();
|
||||
builder.RegisterType<UnitSystemService>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<CalculationService>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<MainModel>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<MainViewModel>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<CrossSectionModel>().AsSelf().SingleInstance();
|
||||
builder.RegisterType<CrossSectionViewModel>().AsSelf().SingleInstance();
|
||||
|
||||
builder.RegisterType<MainView>().AsSelf();
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
DeltaY = dy;
|
||||
}
|
||||
|
||||
public MainViewModel OwnerVM { get; private set; }
|
||||
public CrossSectionViewModel OwnerVM { get; private set; }
|
||||
|
||||
public double DeltaX { get; private set; }
|
||||
public double DeltaY { get; private set; }
|
||||
|
||||
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2023-02-25T08:37:39.2738786Z;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;</History>
|
||||
<History>True|2024-02-02T07:22:50.1454015Z;True|2023-02-25T13:37:39.2738786+05:00;False|2023-02-25T13:37:24.0284261+05:00;True|2023-02-25T13:34:01.6858860+05:00;True|2023-02-25T13:31:18.8295711+05:00;False|2023-02-25T13:25:21.5807199+05:00;False|2023-02-25T13:24:41.7164398+05:00;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -24,7 +24,7 @@ using System.Threading;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainModel
|
||||
public class CrossSectionModel
|
||||
{
|
||||
public ICrossSection Section { get; private set; }
|
||||
private IPrimitiveRepository primitiveRepository;
|
||||
@@ -37,7 +37,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
|
||||
public ICalculationProperty CalculationProperty { get; private set; }
|
||||
|
||||
public MainModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
|
||||
public CrossSectionModel(IPrimitiveRepository primitiveRepository, CalculationService calculationService, UnitSystemService unitSystemService)
|
||||
{
|
||||
this.primitiveRepository = primitiveRepository;
|
||||
this.calculationService = calculationService;
|
||||
@@ -25,7 +25,7 @@ using System.Windows.Input;
|
||||
|
||||
namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
public class CrossSectionViewModel : ViewModelBase
|
||||
{
|
||||
ICrossSection section;
|
||||
ICrossSectionRepository repository => section.SectionRepository;
|
||||
@@ -44,7 +44,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
public PrimitiveViewModelLogic PrimitiveLogic => primitiveLogic;
|
||||
public HelpLogic HelpLogic => new HelpLogic();
|
||||
|
||||
private MainModel Model { get; }
|
||||
private CrossSectionModel Model { get; }
|
||||
|
||||
private double panelX, panelY, scrollPanelX, scrollPanelY;
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace StructureHelper.Windows.MainWindow
|
||||
private RelayCommand selectPrimitive;
|
||||
private MaterialsViewModel materialsLogic;
|
||||
|
||||
public MainViewModel(MainModel model)
|
||||
public CrossSectionViewModel(CrossSectionModel model)
|
||||
{
|
||||
visualProperty = new CrossSectionViewVisualProperty();
|
||||
Model = model;
|
||||
@@ -54,6 +54,11 @@
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Copy To" Command="{Binding CopyTo}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Copy.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Delete" Command="{Binding Delete}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16" Height="16" Source="/Windows/MainWindow/Delete.png" />
|
||||
|
||||
@@ -8,10 +8,10 @@ namespace StructureHelper.Windows.MainWindow
|
||||
{
|
||||
public partial class MainView : Window
|
||||
{
|
||||
private MainViewModel viewModel;
|
||||
private CrossSectionViewModel viewModel;
|
||||
public IPrimitiveRepository PrimitiveRepository { get; }
|
||||
|
||||
public MainView(IPrimitiveRepository primitiveRepository, MainViewModel viewModel)
|
||||
public MainView(IPrimitiveRepository primitiveRepository, CrossSectionViewModel viewModel)
|
||||
{
|
||||
PrimitiveRepository = primitiveRepository;
|
||||
this.viewModel = viewModel;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
xmlns:local="clr-namespace:StructureHelper.Windows.Services"
|
||||
d:DataContext ="{d:DesignInstance local:CopyByParameterViewModel}"
|
||||
mc:Ignorable="d"
|
||||
Title="Copy To" Height="260" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterOwner">
|
||||
Title="Copy To" Height="300" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
|
||||
<Window.Resources>
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Margin" Value="2"/>
|
||||
@@ -35,11 +35,11 @@
|
||||
<TextBlock Grid.Row="1" Text="Delta Y"/>
|
||||
<TextBlock Grid.Row="2" Text="Angle"/>
|
||||
<TextBlock Grid.Row="3" Text="Distance"/>
|
||||
<TextBox Grid.Column="1" Text=""/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text=""/>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="" IsEnabled="False"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="3" Text="" IsEnabled="False"/>
|
||||
<CheckBox Grid.Row="4" Content="Relative coordinates"/>
|
||||
<TextBox Grid.Column="1" Text="{Binding DeltaX, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding DeltaY, Converter={StaticResource LengthConverter}, ValidatesOnDataErrors=True}"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Angle}" IsEnabled="False"/>
|
||||
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Distance, Converter={StaticResource LengthConverter}}" IsEnabled="False"/>
|
||||
<CheckBox Grid.Row="4" Content="Relative coordinates" Visibility="Hidden"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
<GroupBox Header="Copy count">
|
||||
@@ -52,7 +52,7 @@
|
||||
<RowDefinition Height="27"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox Grid.Column="1" Text=""/>
|
||||
<TextBox Grid.Column="1" Text="{Binding CopyCount, ValidatesOnDataErrors=True}"/>
|
||||
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
@@ -19,9 +19,13 @@ namespace StructureHelper.Windows.Services
|
||||
/// </summary>
|
||||
public partial class CopyByParameterView : Window
|
||||
{
|
||||
public CopyByParameterView()
|
||||
private CopyByParameterViewModel viewModel;
|
||||
public CopyByParameterView(CopyByParameterViewModel viewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.viewModel = viewModel;
|
||||
DataContext = this.viewModel;
|
||||
this.viewModel.ParentWindow = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelper.Windows.ViewModels;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -7,7 +8,85 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Windows.Services
|
||||
{
|
||||
internal class CopyByParameterViewModel : OkCancelViewModelBase
|
||||
public class CopyByParameterViewModel : OkCancelViewModelBase
|
||||
{
|
||||
private double deltaX;
|
||||
private double deltaY;
|
||||
private int copyCount;
|
||||
|
||||
public double DeltaX
|
||||
{
|
||||
get => deltaX; set
|
||||
{
|
||||
deltaX = value;
|
||||
RefreshAngle();
|
||||
OnPropertyChanged(nameof(deltaX));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double DeltaY
|
||||
{
|
||||
get => deltaY; set
|
||||
{
|
||||
deltaY = value;
|
||||
RefreshAngle();
|
||||
OnPropertyChanged(nameof(deltaY));
|
||||
}
|
||||
}
|
||||
public double Angle { get; set; }
|
||||
public double Distance { get; set; }
|
||||
public int CopyCount
|
||||
{
|
||||
get => copyCount; set
|
||||
{
|
||||
int newValue;
|
||||
try
|
||||
{
|
||||
newValue = value;
|
||||
copyCount = newValue;
|
||||
OnPropertyChanged(nameof(CopyCount));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IPoint2D originalCenter;
|
||||
|
||||
public CopyByParameterViewModel(IPoint2D originalCenter)
|
||||
{
|
||||
deltaX = 0.2d;
|
||||
deltaY = 0d;
|
||||
copyCount = 1;
|
||||
this.originalCenter = originalCenter;
|
||||
RefreshAngle();
|
||||
}
|
||||
|
||||
public List<IPoint2D> GetNewItemCenters()
|
||||
{
|
||||
var result = new List<IPoint2D>();
|
||||
for (int i = 1; i <= CopyCount; i++)
|
||||
{
|
||||
var newPoint = new Point2D()
|
||||
{
|
||||
X = originalCenter.X + deltaX * i,
|
||||
Y = originalCenter.Y + deltaY * i,
|
||||
};
|
||||
result.Add(newPoint);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private void RefreshAngle()
|
||||
{
|
||||
Angle = Math.Atan2(deltaX, deltaY) * 180d / Math.PI - 90d;
|
||||
Angle = Math.Round(Angle, 1);
|
||||
Distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
Distance = Math.Round(Distance, 3);
|
||||
OnPropertyChanged(nameof(Angle));
|
||||
OnPropertyChanged(nameof(Distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ using System.Windows.Documents;
|
||||
using StructureHelper.Windows.PrimitiveProperiesWindow;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System.Windows.Input;
|
||||
using StructureHelper.Windows.Services;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
{
|
||||
@@ -32,6 +34,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
private ICommand copyCommand;
|
||||
private ICommand setToFront;
|
||||
private ICommand setToBack;
|
||||
private ICommand copyToCommand;
|
||||
|
||||
public double CanvasWidth { get; set; }
|
||||
public double CanvasHeight { get; set; }
|
||||
@@ -186,15 +189,42 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
return copyCommand ??
|
||||
(
|
||||
copyCommand = new RelayCommand(
|
||||
o => CopySelectedItem(),
|
||||
o => CopySelectedItem(SelectedItem.GetNdmPrimitive()),
|
||||
o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void CopySelectedItem()
|
||||
public ICommand CopyTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return copyToCommand ??
|
||||
(
|
||||
copyToCommand = new RelayCommand(
|
||||
o => CopyToSelectedItem(SelectedItem.GetNdmPrimitive()),
|
||||
o => SelectedItem != null
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyToSelectedItem(INdmPrimitive ndmPrimitive)
|
||||
{
|
||||
var copyByParameterVM = new CopyByParameterViewModel(ndmPrimitive.Center);
|
||||
var wnd = new CopyByParameterView(copyByParameterVM);
|
||||
wnd.ShowDialog();
|
||||
if (wnd.DialogResult != true) { return;}
|
||||
var points = copyByParameterVM.GetNewItemCenters();
|
||||
foreach (var item in points)
|
||||
{
|
||||
var newPrimitive = CopySelectedItem(ndmPrimitive);
|
||||
newPrimitive.CenterX = item.X;
|
||||
newPrimitive.CenterY = item.Y;
|
||||
}
|
||||
}
|
||||
|
||||
private PrimitiveBase CopySelectedItem(INdmPrimitive oldPrimitive)
|
||||
{
|
||||
var oldPrimitive = SelectedItem.GetNdmPrimitive();
|
||||
var newPrimitive = oldPrimitive.Clone() as INdmPrimitive;
|
||||
newPrimitive.Name += " copy";
|
||||
repository.Primitives.Add(newPrimitive);
|
||||
@@ -218,6 +248,7 @@ namespace StructureHelper.Windows.ViewModels.NdmCrossSections
|
||||
Items.Add(primitiveBase);
|
||||
OnPropertyChanged(nameof(Items));
|
||||
OnPropertyChanged(nameof(PrimitivesCount));
|
||||
return primitiveBase;
|
||||
}
|
||||
|
||||
public int PrimitivesCount => repository.Primitives.Count();
|
||||
|
||||
@@ -66,7 +66,9 @@ namespace StructureHelperCommon.Models
|
||||
{
|
||||
var table = new TableLogEntry(6);
|
||||
table.Priority = Priority;
|
||||
table.Table.AddRow(GetForceTupleHeaderRow(new ForceTuple()));
|
||||
//type of force tuple for creating a header is taken by first member
|
||||
var firstMember = forceTuples.First();
|
||||
table.Table.AddRow(GetForceTupleHeaderRow(firstMember));
|
||||
foreach (var forceTuple in forceTuples)
|
||||
{
|
||||
table.Table.AddRow(GetForceTupleRow(forceTuple));
|
||||
|
||||
@@ -33,7 +33,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
var checkResult = CheckInputData();
|
||||
if (checkResult != "")
|
||||
{
|
||||
Result = new ForcesResults() { IsValid = false, Description = checkResult };
|
||||
Result = new ForcesResults()
|
||||
{
|
||||
IsValid = false,
|
||||
Description = checkResult
|
||||
};
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
MaxIterationCount = accuracy.MaxIterationCount,
|
||||
StartForceMatrix = new ForceMatrix { Mx = mx, My = my, Nz = nz }
|
||||
},
|
||||
ActionToOutputResults = ShowResultToConsole,
|
||||
ActionToOutputResults = ShowResultToTrace,
|
||||
NdmCollection = ndmCollection
|
||||
};
|
||||
var calculator = new Calculator();
|
||||
@@ -70,7 +70,7 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
if (calcResult.AccuracyRate <= accuracy.IterationAccuracy)
|
||||
{
|
||||
TraceLogger?.AddMessage($"Analisis is done succsesfully");
|
||||
TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Debug);
|
||||
TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate} has acheived in {calcResult.IterationCounter} iteration", TraceLogStatuses.Debug);
|
||||
return new ForcesTupleResult()
|
||||
{
|
||||
IsValid = true,
|
||||
@@ -82,7 +82,12 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
{
|
||||
TraceLogger?.AddMessage($"Required accuracy rate has not achived", TraceLogStatuses.Error);
|
||||
TraceLogger?.AddMessage($"Current accuracy {calcResult.AccuracyRate}, {calcResult.IterationCounter} iteration has done", TraceLogStatuses.Warning);
|
||||
return new ForcesTupleResult() { IsValid = false, Description = "Required accuracy rate has not achived", LoaderResults = calcResult };
|
||||
return new ForcesTupleResult()
|
||||
{
|
||||
IsValid = false,
|
||||
Description = "Required accuracy rate has not achived",
|
||||
LoaderResults = calcResult
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,5 +121,11 @@ namespace StructureHelperLogics.NdmCalculations.Analyses.ByForces
|
||||
var strain = result.StrainMatrix;
|
||||
//MessageBox.Show($" Текущие результаты в {result.IterationCounter} итерации:");
|
||||
}
|
||||
|
||||
private void ShowResultToTrace(ILoaderResults result)
|
||||
{
|
||||
var strain = result.StrainMatrix;
|
||||
TraceLogger?.AddMessage($"Iteration {result.IterationCounter}, current accuracy rate {result.AccuracyRate}", TraceLogStatuses.Debug,100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,9 +117,9 @@ namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
var crackedStrainTuple = GetStrainTuple(EndTuple);
|
||||
TraceLogger?.AddMessage($"Strains in cracked section from actual (end) force");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(crackedStrainTuple));
|
||||
TraceLogger?.AddMessage($"Average curvatures of cracked part of element");
|
||||
TraceLogger?.AddMessage($"Average strains of cracked part of element");
|
||||
TraceLogger?.AddEntry(new TraceTablesFactory().GetByForceTuple(reducedStrainTuple));
|
||||
TraceLogger?.AddMessage($"Calculating factors of reducing of stifness");
|
||||
TraceLogger?.AddMessage($"Factors of reducing of stiffness");
|
||||
result.FactorOfCrackAppearance = factorOfCrackAppearance;
|
||||
result.IsValid = true;
|
||||
result.IsSectionCracked = true;
|
||||
|
||||
@@ -5,11 +5,6 @@ using StructureHelperCommon.Models;
|
||||
using StructureHelperCommon.Models.Calculators;
|
||||
using StructureHelperCommon.Models.Forces;
|
||||
using StructureHelperLogics.NdmCalculations.Analyses.ByForces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelperLogics.NdmCalculations.Cracking
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user