Circle Primitive Added
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
public enum PrimitiveType
|
||||
{
|
||||
Point,
|
||||
Rectangle
|
||||
Rectangle,
|
||||
Circle
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using StructureHelper.Infrastructure.UI.Converters.Units;
|
||||
using StructureHelperCommon.Infrastructures.Exceptions;
|
||||
using StructureHelperCommon.Infrastructures.Strings;
|
||||
using StructureHelperLogics.NdmCalculations.Primitives;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
{
|
||||
public class CircleViewPrimitive : PrimitiveBase, IHasDivision, IHasCenter
|
||||
{
|
||||
ICirclePrimitive primitive;
|
||||
public double Diameter
|
||||
{ get
|
||||
{
|
||||
return primitive.Diameter;
|
||||
}
|
||||
set
|
||||
{
|
||||
primitive.Diameter = value;
|
||||
RefreshPlacement();
|
||||
}
|
||||
}
|
||||
public int NdmMinDivision { get; set; }
|
||||
public double NdmMaxSize { get; set; }
|
||||
|
||||
public double PrimitiveLeft => DeltaX - Diameter / 2d;
|
||||
public double PrimitiveTop => DeltaY - Diameter / 2d;
|
||||
|
||||
public CircleViewPrimitive(INdmPrimitive primitive) : base(primitive)
|
||||
{
|
||||
if (primitive is not ICirclePrimitive)
|
||||
{
|
||||
throw new StructureHelperException(ErrorStrings.DataIsInCorrect + $"\nExpected: {nameof(ICirclePrimitive)}, But was: {nameof(primitive)}");
|
||||
}
|
||||
this.primitive = primitive as ICirclePrimitive;
|
||||
}
|
||||
|
||||
public override INdmPrimitive GetNdmPrimitive()
|
||||
{
|
||||
return primitive;
|
||||
}
|
||||
|
||||
private void RefreshPlacement()
|
||||
{
|
||||
OnPropertyChanged(nameof(Diameter));
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(PrimitiveLeft));
|
||||
OnPropertyChanged(nameof(PrimitiveTop));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,21 @@ namespace StructureHelper.Infrastructure.UI.DataContexts
|
||||
ObservableCollection<PrimitiveBase> viewItems = new ObservableCollection<PrimitiveBase>();
|
||||
foreach (var item in primitives)
|
||||
{
|
||||
if (item is IPointPrimitive)
|
||||
{
|
||||
var point = item as IPointPrimitive;
|
||||
viewItems.Add(new PointViewPrimitive(point));
|
||||
}
|
||||
else if (item is IRectanglePrimitive)
|
||||
if (item is IRectanglePrimitive)
|
||||
{
|
||||
var rect = item as IRectanglePrimitive;
|
||||
viewItems.Add(new RectangleViewPrimitive(rect));
|
||||
}
|
||||
else if (item is ICirclePrimitive)
|
||||
{
|
||||
var circle = item as ICirclePrimitive;
|
||||
viewItems.Add(new CircleViewPrimitive(circle));
|
||||
}
|
||||
else if (item is IPointPrimitive)
|
||||
{
|
||||
var point = item as IPointPrimitive;
|
||||
viewItems.Add(new PointViewPrimitive(point));
|
||||
}
|
||||
else throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknown);
|
||||
}
|
||||
return viewItems;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
xmlns:userControls="clr-namespace:StructureHelper.Infrastructure.UI.UserControls"
|
||||
mc:Ignorable="d">
|
||||
<StackPanel>
|
||||
<Ellipse Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PointViewPrimitive}">
|
||||
<Ellipse Style="{StaticResource EllipseStyle}" d:DataContext="{d:DesignInstance dataContexts:PointViewPrimitive}" Tag ="{Binding}">
|
||||
<Ellipse.ToolTip>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -43,6 +43,5 @@
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
</Ellipse>
|
||||
<userControls:PrimitivePopup Type="Rectangle" IsOpen="{Binding ParamsPanelVisibilty}" d:DataContext="{d:DesignInstance dataContexts:PrimitiveBase}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -52,6 +52,5 @@
|
||||
</Rectangle.RenderTransform>
|
||||
</Rectangle>
|
||||
</Grid>
|
||||
<userControls:PrimitivePopup IsOpen="{Binding ParamsPanelVisibilty}"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
Reference in New Issue
Block a user