View primitives was fixed
This commit is contained in:
14
Infrastructure/UI/DataContexts/IHasCenter.cs
Normal file
14
Infrastructure/UI/DataContexts/IHasCenter.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
internal interface IHasCenter
|
||||
{
|
||||
double PrimitiveLeft { get; }
|
||||
double PrimitiveTop { get; }
|
||||
}
|
||||
}
|
||||
14
Infrastructure/UI/DataContexts/IHasDivision.cs
Normal file
14
Infrastructure/UI/DataContexts/IHasDivision.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
internal interface IHasDivision
|
||||
{
|
||||
int NdmMinDivision { get; set; }
|
||||
double NdmMaxSize { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,16 +13,15 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
internal class LinePrimitive : PrimitiveBase
|
||||
internal class LineViewPrimitive : PrimitiveBase
|
||||
{
|
||||
private ILineShape lineShape;
|
||||
public LinePrimitive(PrimitiveType type, double x, double y, MainViewModel ownerVM) : base(type, x, y, ownerVM)
|
||||
public LineViewPrimitive(ILinePrimitive primitive) : base(primitive)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
//public LineViewPrimitive(double x, double y, MainViewModel ownerVM) : base(x, y, ownerVM)
|
||||
//{
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
using System;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class Point : PrimitiveBase
|
||||
{
|
||||
private double area;
|
||||
public double Area
|
||||
{ get => area;
|
||||
set
|
||||
{
|
||||
area = value;
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
}
|
||||
}
|
||||
public Point(double area, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Point, x, y, ownerVm)
|
||||
{
|
||||
Name = "New point";
|
||||
Area = area;
|
||||
PreviewMouseMove = new RelayCommand(o =>
|
||||
{
|
||||
if (!(o is Point point)) return;
|
||||
if (point.Captured && !point.ElementLock)
|
||||
{
|
||||
var pointDelta = point.PrimitiveWidth / 2;
|
||||
|
||||
if (point.ShowedX % 10 <= pointDelta || point.ShowedX % 10 >= 10 - pointDelta)
|
||||
point.ShowedX = Math.Round((ownerVm.PanelX - OwnerVm.YX1) / 10) * 10;
|
||||
else
|
||||
point.ShowedX = ownerVm.PanelX - pointDelta - OwnerVm.YX1;
|
||||
|
||||
if (point.ShowedY % 10 <= pointDelta || point.ShowedY % 10 >= 10 - pointDelta)
|
||||
point.ShowedY = -(Math.Round((ownerVm.PanelY - OwnerVm.XY1) / 10) * 10);
|
||||
else
|
||||
point.ShowedY = -(ownerVm.PanelY - pointDelta - OwnerVm.XY1);
|
||||
}
|
||||
});
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
}
|
||||
|
||||
public double Diameter { get => Math.Sqrt(area / Math.PI) * 2; }
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
|
||||
{
|
||||
string materialName = MaterialName;
|
||||
ICenter center = new Center { X = CenterX, Y = CenterY };
|
||||
IShape shape = new StructureHelperCommon.Models.Shapes.PointShape { Area = this.Area };
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial)
|
||||
{ Center = center, Shape = shape,
|
||||
PrestrainKx = PrestrainKx,
|
||||
PrestrainKy = PrestrainKy,
|
||||
PrestrainEpsZ = PrestrainEpsZ
|
||||
};
|
||||
return ndmPrimitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Infrastructure/UI/DataContexts/PointViewPrimitive.cs
Normal file
49
Infrastructure/UI/DataContexts/PointViewPrimitive.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class PointViewPrimitive : PrimitiveBase, IHasCenter
|
||||
{
|
||||
const double lengthUnit = 1000d;
|
||||
|
||||
IPointPrimitive primitive;
|
||||
|
||||
public double Area
|
||||
{ get => primitive.Area;
|
||||
set
|
||||
{
|
||||
primitive.Area = value;
|
||||
OnPropertyChanged(nameof(Area));
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
}
|
||||
}
|
||||
|
||||
public double PrimitiveLeft
|
||||
{
|
||||
get => DeltaX - Diameter / 2d * lengthUnit;
|
||||
}
|
||||
public double PrimitiveTop
|
||||
{
|
||||
get => DeltaY - Diameter / 2d * lengthUnit;
|
||||
}
|
||||
|
||||
public PointViewPrimitive(IPointPrimitive _primitive) : base(_primitive)
|
||||
{
|
||||
primitive = _primitive;
|
||||
}
|
||||
|
||||
public double Diameter { get => Math.Sqrt(primitive.Area / Math.PI) * 2; }
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Services.ColorServices;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
@@ -23,96 +24,84 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
#region Поля
|
||||
private IPrimitiveRepository primitiveRepository;
|
||||
private readonly PrimitiveType type;
|
||||
private string name;
|
||||
private double centerX, centerY;
|
||||
private int minElementDivision;
|
||||
private double maxElementSize;
|
||||
private INdmPrimitive primitive;
|
||||
private bool captured, parameterCaptured, elementLock, paramsPanelVisibilty, popupCanBeClosed = true, borderCaptured;
|
||||
private Brush brush;
|
||||
private bool setMaterialColor;
|
||||
private Color color;
|
||||
private IHeadMaterial headMaterial;
|
||||
private MaterialDefinitionBase material;
|
||||
private double prestrainKx, prestrainKy, prestrainEpsZ;
|
||||
private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight, showedX, showedY;
|
||||
private double opacity = 1, showedOpacity = 0, x, y, xY1, yX1, primitiveWidth, primitiveHeight;
|
||||
protected double delta = 0.5;
|
||||
private double stressValue;
|
||||
private double strainValue;
|
||||
private int showedZIndex = 1, zIndex;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Свойства
|
||||
|
||||
public PrimitiveType Type
|
||||
public INdmPrimitive NdmPrimitive
|
||||
{
|
||||
get => type;
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, type);
|
||||
OnPropertyChanged(nameof(RectangleFieldVisibility));
|
||||
OnPropertyChanged(nameof(PrimitiveDimension));
|
||||
OnPropertyChanged(nameof(HeightRowHeight));
|
||||
}
|
||||
get => primitive;
|
||||
}
|
||||
|
||||
public IPrimitiveRepository PrimitiveRepository => primitiveRepository;
|
||||
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => name;
|
||||
get => primitive.Name;
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref name);
|
||||
primitive.Name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
public double CenterX
|
||||
{
|
||||
get => centerX;
|
||||
get => primitive.CenterX;
|
||||
set
|
||||
{
|
||||
if (this is Rectangle)
|
||||
{
|
||||
ShowedX = value - primitiveWidth / 2d;
|
||||
}
|
||||
else if (this is Point)
|
||||
{
|
||||
Point point = this as Point;
|
||||
ShowedX = value - point.Diameter / 2;
|
||||
}
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
|
||||
OnPropertyChanged(value, ref centerX);
|
||||
primitive.CenterX = value;
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
}
|
||||
}
|
||||
public double CenterY
|
||||
{
|
||||
get => centerY;
|
||||
get => primitive.CenterY;
|
||||
set
|
||||
{
|
||||
if (this is Rectangle)
|
||||
{
|
||||
ShowedY = value - primitiveHeight / 2d;
|
||||
}
|
||||
else if (this is Point)
|
||||
{
|
||||
Point point = this as Point;
|
||||
ShowedY = value - point.Diameter / 2;
|
||||
}
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
|
||||
OnPropertyChanged(value, ref centerY);
|
||||
{
|
||||
primitive.CenterY = value;
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(InvertedCenterY));
|
||||
}
|
||||
}
|
||||
public double InvertedCenterY => - CenterY;
|
||||
public double PrestrainKx
|
||||
{ get => primitive.PrestrainKx;
|
||||
set
|
||||
{
|
||||
primitive.PrestrainKx = value;
|
||||
OnPropertyChanged(nameof(PrestrainKx));
|
||||
}
|
||||
}
|
||||
public double PrestrainKy
|
||||
{ get => primitive.PrestrainKy;
|
||||
set
|
||||
{
|
||||
primitive.PrestrainKy = value;
|
||||
OnPropertyChanged(nameof(PrestrainKy));
|
||||
}
|
||||
}
|
||||
public double PrestrainEpsZ
|
||||
{ get => primitive.PrestrainEpsZ;
|
||||
set
|
||||
{
|
||||
primitive.PrestrainEpsZ = value;
|
||||
OnPropertyChanged(nameof(PrestrainEpsZ));
|
||||
}
|
||||
}
|
||||
public double PrestrainKx { get; set; }
|
||||
public double PrestrainKy { get; set; }
|
||||
public double PrestrainEpsZ { get; set; }
|
||||
|
||||
public IHeadMaterial HeadMaterial
|
||||
{
|
||||
get => headMaterial;
|
||||
get => primitive.HeadMaterial;
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref headMaterial);
|
||||
primitive.HeadMaterial = value;
|
||||
OnPropertyChanged(nameof(HeadMaterial));
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
}
|
||||
@@ -120,27 +109,22 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
public bool SetMaterialColor
|
||||
{
|
||||
get => setMaterialColor;
|
||||
set { OnPropertyChanged(value, ref setMaterialColor);}
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref setMaterialColor);
|
||||
OnPropertyChanged(nameof(Color));
|
||||
}
|
||||
|
||||
}
|
||||
public Color Color
|
||||
{
|
||||
get => ((setMaterialColor == true) & (headMaterial !=null))? headMaterial.Color :color;
|
||||
get => ((setMaterialColor == true) & (primitive.HeadMaterial !=null))? primitive.HeadMaterial.Color : color;
|
||||
set
|
||||
{
|
||||
SetMaterialColor = false;
|
||||
OnPropertyChanged(value, ref color);
|
||||
}
|
||||
}
|
||||
public int MinElementDivision
|
||||
{
|
||||
get => minElementDivision;
|
||||
set { OnPropertyChanged(value, ref minElementDivision); }
|
||||
}
|
||||
public double MaxElementSize
|
||||
{
|
||||
get => maxElementSize;
|
||||
set { OnPropertyChanged(value, ref maxElementSize); }
|
||||
}
|
||||
|
||||
public bool Captured
|
||||
{
|
||||
@@ -162,25 +146,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
get => new SolidColorBrush(Color);
|
||||
set { }
|
||||
}
|
||||
public MaterialDefinitionBase Material
|
||||
{
|
||||
get => material;
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
MaterialName = value.MaterialClass;
|
||||
OnPropertyChanged(value, ref material);
|
||||
OnPropertyChanged(nameof(MaterialName));
|
||||
}
|
||||
}
|
||||
}
|
||||
private string materialName = string.Empty;
|
||||
public string MaterialName
|
||||
{
|
||||
get => materialName;
|
||||
set => OnPropertyChanged(value, ref materialName);
|
||||
}
|
||||
|
||||
public bool ParamsPanelVisibilty
|
||||
{
|
||||
get => paramsPanelVisibilty;
|
||||
@@ -221,16 +187,7 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
get => zIndex;
|
||||
set => OnPropertyChanged(value, ref zIndex);
|
||||
}
|
||||
public double X
|
||||
{
|
||||
get => x;
|
||||
set => OnPropertyChanged(value, ref x);
|
||||
}
|
||||
public double Y
|
||||
{
|
||||
get => y;
|
||||
set => OnPropertyChanged(value, ref y);
|
||||
}
|
||||
|
||||
public double Xy1
|
||||
{
|
||||
get => xY1;
|
||||
@@ -241,62 +198,13 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
get => yX1;
|
||||
set => OnPropertyChanged(value, ref yX1);
|
||||
}
|
||||
public double PrimitiveWidth
|
||||
{
|
||||
get => primitiveWidth;
|
||||
set => OnPropertyChanged(value, ref primitiveWidth);
|
||||
}
|
||||
public double PrimitiveHeight
|
||||
{
|
||||
get => primitiveHeight;
|
||||
set => OnPropertyChanged(value, ref primitiveHeight);
|
||||
}
|
||||
public double StressValue
|
||||
{
|
||||
get { return stressValue; }
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref stressValue);
|
||||
}
|
||||
}
|
||||
public double StrainValue
|
||||
{
|
||||
get { return strainValue; }
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(value, ref strainValue);
|
||||
}
|
||||
}
|
||||
public double ShowedX
|
||||
{
|
||||
get => showedX;
|
||||
set
|
||||
{
|
||||
UpdateCoordinatesX(value);
|
||||
OnPropertyChanged(value, ref showedX);
|
||||
OnPropertyChanged(nameof(X));
|
||||
}
|
||||
}
|
||||
public double ShowedY
|
||||
{
|
||||
get => showedY;
|
||||
set
|
||||
{
|
||||
UpdateCoordinatesY(value);
|
||||
OnPropertyChanged(value, ref showedY);
|
||||
OnPropertyChanged(nameof(Y));
|
||||
}
|
||||
}
|
||||
public virtual double PrimitiveWidth { get; set; }
|
||||
public virtual double PrimitiveHeight { get;set; }
|
||||
public bool BorderCaptured
|
||||
{
|
||||
get => borderCaptured;
|
||||
set => OnPropertyChanged(value, ref borderCaptured);
|
||||
}
|
||||
|
||||
public Visibility RectangleFieldVisibility => Type == PrimitiveType.Rectangle ? Visibility.Visible : Visibility.Hidden;
|
||||
public string PrimitiveDimension => Type == PrimitiveType.Rectangle ? "Ширина" : "Диаметр";
|
||||
public double HeightRowHeight => Type == PrimitiveType.Rectangle ? 40 : 0;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Команды
|
||||
@@ -307,67 +215,33 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
|
||||
#endregion
|
||||
|
||||
protected PrimitiveBase(PrimitiveType type, double x, double y, MainViewModel ownerVM)
|
||||
public PrimitiveBase(INdmPrimitive primitive)
|
||||
{
|
||||
this.type = type;
|
||||
X = ownerVM.YX1 + x;
|
||||
Y = ownerVM.XY1 + y;
|
||||
color = ColorProcessor.GetRandomColor();
|
||||
PrimitiveLeftButtonUp = new RelayCommand(o => Captured = false);
|
||||
PrimitiveLeftButtonDown = new RelayCommand(o => Captured = true);
|
||||
|
||||
PrimitiveDoubleClick = new RelayCommand(o =>
|
||||
{
|
||||
//PopupCanBeClosed = false;
|
||||
//Captured = false;
|
||||
//ParamsPanelVisibilty = true;
|
||||
//ParameterCaptured = true;
|
||||
|
||||
});
|
||||
OwnerVm = ownerVM;
|
||||
SetMaterialColor = true;
|
||||
PrestrainKx = 0;
|
||||
PrestrainKy = 0;
|
||||
PrestrainEpsZ = 0;
|
||||
this.primitive = primitive;
|
||||
}
|
||||
|
||||
protected readonly MainViewModel OwnerVm;
|
||||
|
||||
private void UpdateCoordinatesX(double showedX)
|
||||
public void RegisterDeltas(double dx, double dy)
|
||||
{
|
||||
if (this is Rectangle)
|
||||
{
|
||||
X = showedX + OwnerVm.YX1 / UnitConstatnts.Length;
|
||||
}
|
||||
else if (this is Point)
|
||||
{
|
||||
Point point = this as Point;
|
||||
X = showedX + OwnerVm.YX1 / UnitConstatnts.Length;
|
||||
}
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
|
||||
}
|
||||
private void UpdateCoordinatesY(double showedY)
|
||||
{
|
||||
if (this is Rectangle)
|
||||
{
|
||||
Y = -showedY + OwnerVm.XY1 / UnitConstatnts.Length - PrimitiveHeight;
|
||||
}
|
||||
else if (this is Point)
|
||||
{
|
||||
Point point = this as Point;
|
||||
Y = -showedY + OwnerVm.XY1 / UnitConstatnts.Length - point.Diameter;
|
||||
}
|
||||
else { throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown); }
|
||||
DeltaX = dx;
|
||||
DeltaY = dy;
|
||||
}
|
||||
|
||||
public abstract INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem);
|
||||
public MaterialTypes GetMaterialTypes()
|
||||
public MainViewModel OwnerVM { get; private set; }
|
||||
|
||||
public double DeltaX { get; private set; }
|
||||
public double DeltaY { get; private set; }
|
||||
|
||||
public virtual INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
MaterialTypes materialTypes;
|
||||
if (Material is ConcreteDefinition) { materialTypes = MaterialTypes.Concrete; }
|
||||
else if (Material is RebarDefinition) { materialTypes = MaterialTypes.Reinforcement; }
|
||||
else { throw new StructureHelperException(ErrorStrings.MaterialTypeIsUnknown); }
|
||||
return materialTypes;
|
||||
RefreshNdmPrimitive();
|
||||
return primitive;
|
||||
}
|
||||
|
||||
public virtual void RefreshNdmPrimitive()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class Rectangle : PrimitiveBase
|
||||
{
|
||||
public Rectangle(double primitiveWidth, double primitiveHeight, double x, double y, MainViewModel ownerVm) : base(PrimitiveType.Rectangle, x, y, ownerVm)
|
||||
{
|
||||
Type = PrimitiveType.Rectangle;
|
||||
Name = "New rectangle";
|
||||
PrimitiveWidth = primitiveWidth;
|
||||
PrimitiveHeight = primitiveHeight;
|
||||
PreviewMouseMove = new RelayCommand(o =>
|
||||
{
|
||||
if (!(o is Rectangle rect)) return;
|
||||
if (Captured && !rect.BorderCaptured && !ElementLock)
|
||||
{
|
||||
var deltaX = PrimitiveWidth / 2;
|
||||
var deltaY = PrimitiveHeight / 2;
|
||||
|
||||
if (rect.ShowedX % 10 <= delta || rect.ShowedX % 10 >= 10 - delta)
|
||||
rect.ShowedX = Math.Round((OwnerVm.PanelX - deltaX - OwnerVm.YX1) / 10) * 10;
|
||||
else
|
||||
rect.ShowedX = OwnerVm.PanelX - deltaX - OwnerVm.YX1;
|
||||
|
||||
if (rect.ShowedY % 10 <= delta || rect.ShowedY % 10 >= 10 - delta)
|
||||
rect.ShowedY = -(Math.Round((OwnerVm.PanelY - deltaY - OwnerVm.XY1 + rect.PrimitiveHeight) / 10) * 10);
|
||||
else
|
||||
rect.ShowedY = -(OwnerVm.PanelY - deltaY - OwnerVm.XY1 + rect.PrimitiveHeight);
|
||||
}
|
||||
});
|
||||
CenterX = x;
|
||||
CenterY = y;
|
||||
MinElementDivision = 10;
|
||||
MaxElementSize = Math.Min(Math.Min(PrimitiveWidth, PrimitiveHeight) / MinElementDivision, 0.01);
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive(IUnitSystem unitSystem)
|
||||
{
|
||||
var width = PrimitiveWidth;
|
||||
var height = PrimitiveHeight;
|
||||
double centerX = CenterX;
|
||||
double centerY = CenterY;
|
||||
ICenter center = new Center { X = centerX, Y = centerY };
|
||||
IShape shape = new StructureHelperCommon.Models.Shapes.RectangleShape { Height = height, Width = width, Angle = 0 };
|
||||
INdmPrimitive ndmPrimitive = new NdmPrimitive(HeadMaterial)
|
||||
{ Center = center, Shape = shape,
|
||||
NdmMaxSize = MaxElementSize, NdmMinDivision = MinElementDivision,
|
||||
PrestrainKx = PrestrainKx,
|
||||
PrestrainKy = PrestrainKy,
|
||||
PrestrainEpsZ = PrestrainEpsZ };
|
||||
return ndmPrimitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
Normal file
76
Infrastructure/UI/DataContexts/RectangleViewPrimitive.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using StructureHelper.Infrastructure.Enums;
|
||||
using StructureHelper.UnitSystem.Systems;
|
||||
using StructureHelper.Windows.MainWindow;
|
||||
using StructureHelperLogics.Models.Materials;
|
||||
using StructureHelperCommon.Models.Shapes;
|
||||
using System;
|
||||
using StructureHelperLogics.Models.Primitives;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class RectangleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
|
||||
{
|
||||
const double lengthUnit = 1000d;
|
||||
|
||||
private IRectanglePrimitive primitive;
|
||||
|
||||
public override double PrimitiveWidth
|
||||
{
|
||||
get => primitive.Width;
|
||||
set
|
||||
{
|
||||
primitive.Width = value;
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveWidth));
|
||||
}
|
||||
}
|
||||
public override double PrimitiveHeight
|
||||
{
|
||||
get => primitive.Height;
|
||||
set
|
||||
{
|
||||
primitive.Height = value;
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
OnPropertyChanged(nameof(PrimitiveHeight));
|
||||
}
|
||||
}
|
||||
|
||||
public double PrimitiveLeft
|
||||
{
|
||||
get => DeltaX - primitive.Width / 2 * lengthUnit;
|
||||
}
|
||||
public double PrimitiveTop
|
||||
{
|
||||
get => DeltaY - primitive.Height / 2 * lengthUnit;
|
||||
}
|
||||
public int NdmMinDivision
|
||||
{
|
||||
get => primitive.NdmMinDivision;
|
||||
set
|
||||
{
|
||||
primitive.NdmMinDivision = value;
|
||||
OnPropertyChanged(nameof(NdmMinDivision));
|
||||
}
|
||||
}
|
||||
public double NdmMaxSize
|
||||
{
|
||||
get => primitive.NdmMaxSize;
|
||||
set
|
||||
{
|
||||
primitive.NdmMaxSize = value;
|
||||
OnPropertyChanged(nameof(NdmMaxSize));
|
||||
}
|
||||
}
|
||||
|
||||
public RectangleViewPrimitive(IRectanglePrimitive _primitive) : base(_primitive)
|
||||
{
|
||||
primitive = _primitive;
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,38 @@
|
||||
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel>
|
||||
<Ellipse Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:Point}">
|
||||
<i:Interaction.Triggers>
|
||||
<!--<i:EventTrigger EventName="PreviewMouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseUp">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseMove">
|
||||
<i:InvokeCommandAction Command="{Binding PreviewMouseMove}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>-->
|
||||
<!--<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
|
||||
</mouseEventTriggers:DoubleClickEventTrigger>-->
|
||||
</i:Interaction.Triggers>
|
||||
<Ellipse Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PointViewPrimitive}">
|
||||
<Ellipse.ToolTip>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Name: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Material Name: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X: "/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y: "/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="4" Text="Diameter: "/>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding Diameter, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</Ellipse.ToolTip>
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="{Binding CenterX, Converter={StaticResource LengthConverter}}" Y="{Binding InvertedCenterY, Converter={StaticResource LengthConverter}}"/>
|
||||
<RotateTransform/>
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<userControls:PrimitivePopup Type="Rectangle" IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}"/>
|
||||
</StackPanel>
|
||||
|
||||
@@ -10,40 +10,46 @@
|
||||
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
|
||||
xmlns:dataContexts="clr-namespace:StructureHelper.Infrastructure.UI.DataContexts"
|
||||
mc:Ignorable="d"
|
||||
d:DataContext="{d:DesignInstance dataContexts:Rectangle}">
|
||||
d:DataContext="{d:DesignInstance dataContexts:RectangleViewPrimitive}">
|
||||
<UserControl.Resources>
|
||||
</UserControl.Resources>
|
||||
<StackPanel>
|
||||
<Grid>
|
||||
<Rectangle Style="{StaticResource RectangleStyle}">
|
||||
<i:Interaction.Triggers>
|
||||
<!--<i:EventTrigger EventName="PreviewMouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonDown}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseUp">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveLeftButtonUp}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseMove">
|
||||
<i:InvokeCommandAction Command="{Binding PreviewMouseMove}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>-->
|
||||
<!--<mouseEventTriggers:DoubleClickEventTrigger EventName="MouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding PrimitiveDoubleClick}" CommandParameter="{Binding}"/>
|
||||
</mouseEventTriggers:DoubleClickEventTrigger>-->
|
||||
</i:Interaction.Triggers>
|
||||
</Rectangle>
|
||||
<Rectangle Cursor="SizeNWSE" VerticalAlignment="Bottom" HorizontalAlignment="Right">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="PreviewMouseDown">
|
||||
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonDown}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseUp">
|
||||
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.LeftButtonUp}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
<i:EventTrigger EventName="PreviewMouseMove">
|
||||
<i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.PreviewMouseMove}" CommandParameter="{Binding}"/>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<!--<Rectangle.Fill>
|
||||
<SolidColorBrush Color="{Binding Color}"/>
|
||||
</Rectangle.Fill>-->
|
||||
<Rectangle x:Name="Rect" Style="{StaticResource RectangleStyle}" Tag="{Binding}">
|
||||
<Rectangle.ToolTip>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Name: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Material Name: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X: "/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y: "/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="4" Text="Width: "/>
|
||||
<TextBlock Grid.Row="4" Grid.Column="1" Text="{Binding PrimitiveWidth, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="5" Text="Height: "/>
|
||||
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding PrimitiveHeight, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</Rectangle.ToolTip>
|
||||
<Rectangle.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform X="{Binding CenterX, Converter={StaticResource LengthConverter}}" Y="{Binding InvertedCenterY, Converter={StaticResource LengthConverter}}"/>
|
||||
<RotateTransform/>
|
||||
</TransformGroup>
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<userControls:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}"/>
|
||||
|
||||
27
Infrastructure/UI/Resources/PrimitiveToolTips.xaml
Normal file
27
Infrastructure/UI/Resources/PrimitiveToolTips.xaml
Normal file
@@ -0,0 +1,27 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<DataTemplate x:Key="RectanglePrimitiveToolTip">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
<RowDefinition Height="25"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Name: "/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Name}"/>
|
||||
<TextBlock Grid.Row="1" Text="Material Name: "/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding HeadMaterial.Name}"/>
|
||||
<TextBlock Grid.Row="2" Text="Center X: "/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding CenterX, Converter={StaticResource LengthConverter}}"/>
|
||||
<TextBlock Grid.Row="3" Text="Center Y: "/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Text="{Binding CenterY, Converter={StaticResource LengthConverter}}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -26,35 +26,6 @@
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Opacity" Value="{Binding Opacity, Mode=TwoWay}"/>
|
||||
<!--<Setter Property="ToolTip">
|
||||
<Setter.Value>
|
||||
<ToolTip Background="White" BorderBrush="Black" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата X:"/>
|
||||
<TextBox Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedX}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Координата Y:"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding ShowedY}"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Ширина:"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveWidth}"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Высота:"/>
|
||||
<TextBox Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding PrimitiveHeight}"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="Материал:"/>
|
||||
<TextBox Grid.Row="4" Grid.Column="1" VerticalAlignment="Center" Margin="3" BorderThickness="0" Text="{Binding MaterialName, Mode=TwoWay}"/>
|
||||
</Grid>
|
||||
</ToolTip>
|
||||
</Setter.Value>
|
||||
</Setter>-->
|
||||
</Style>
|
||||
|
||||
<Style x:Key="EllipseStyle" TargetType="Ellipse" BasedOn="{StaticResource ShapeStyle}">
|
||||
@@ -68,4 +39,11 @@
|
||||
<Setter Property="Width" Value="{Binding PrimitiveWidth, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="Height" Value="{Binding PrimitiveHeight, Converter={StaticResource LengthConverter}}"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="LinePrimitiveStyle" TargetType="Line" BasedOn="{StaticResource ShapeStyle}">
|
||||
<Setter Property="X1" Value="{Binding StartPoinX, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="Y1" Value="{Binding StartPoinY, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="X2" Value="{Binding EndPoinX, Converter={StaticResource LengthConverter}}"/>
|
||||
<Setter Property="Y2" Value="{Binding EndPoinY, Converter={StaticResource LengthConverter}}"/>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user