Added ShowNodes virtual function to BaseShape instead of using ShowResizeNodes property

This commit is contained in:
Jaex 2016-08-24 16:59:53 +03:00
parent 5b7cd4063d
commit 25460cb4b9
6 changed files with 26 additions and 23 deletions

View file

@ -75,8 +75,6 @@ public Point EndPosition
public virtual bool IsRegionShape { get; } = false; public virtual bool IsRegionShape { get; } = false;
public virtual bool ShowResizeNodes { get; } = true;
internal ShapeManager Manager { get; set; } internal ShapeManager Manager { get; set; }
protected RegionCaptureOptions Options => Manager.Config; protected RegionCaptureOptions Options => Manager.Config;
@ -90,6 +88,11 @@ public virtual bool Intersects(Point position)
return Rectangle.Contains(position); return Rectangle.Contains(position);
} }
public virtual void ShowNodes()
{
Manager.NodesVisible = true;
}
public void Remove() public void Remove()
{ {
Manager.DeleteShape(this); Manager.DeleteShape(this);

View file

@ -34,15 +34,7 @@ public class FreehandDrawingShape : BaseDrawingShape
{ {
public override ShapeType ShapeType { get; } = ShapeType.DrawingFreehand; public override ShapeType ShapeType { get; } = ShapeType.DrawingFreehand;
public override bool ShowResizeNodes { get; } = false; public override bool IsValidShape => points.Count > 0;
public override bool IsValidShape
{
get
{
return points.Count > 0;
}
}
public Point LastPosition public Point LastPosition
{ {
@ -72,6 +64,10 @@ public override bool Intersects(Point position)
return false; return false;
} }
public override void ShowNodes()
{
}
public override void OnUpdate() public override void OnUpdate()
{ {
if (Manager.IsCreating) if (Manager.IsCreating)

View file

@ -97,7 +97,7 @@ public override void OnCreating()
} }
else else
{ {
Manager.NodesVisible = true; ShowNodes();
} }
} }

View file

@ -36,8 +36,6 @@ public class StepDrawingShape : BaseDrawingShape
public override ShapeType ShapeType { get; } = ShapeType.DrawingStep; public override ShapeType ShapeType { get; } = ShapeType.DrawingStep;
public override bool ShowResizeNodes { get; } = false;
public int Number { get; set; } public int Number { get; set; }
public StepDrawingShape() public StepDrawingShape()
@ -45,6 +43,10 @@ public StepDrawingShape()
Rectangle = new Rectangle(0, 0, DefaultSize, DefaultSize); Rectangle = new Rectangle(0, 0, DefaultSize, DefaultSize);
} }
public override void ShowNodes()
{
}
public override void OnCreating() public override void OnCreating()
{ {
Manager.IsMoving = true; Manager.IsMoving = true;

View file

@ -82,8 +82,7 @@ public override void OnCreating()
else else
{ {
AutoSize(true); AutoSize(true);
ShowNodes();
Manager.NodesVisible = true;
} }
} }

View file

@ -1493,14 +1493,17 @@ public Image RenderOutputImage(Image img)
return bmp; return bmp;
} }
private void SelectShape(BaseShape shape)
{
if (shape != null)
{
shape.ShowNodes();
}
}
private void SelectCurrentShape() private void SelectCurrentShape()
{ {
BaseShape shape = CurrentShape; SelectShape(CurrentShape);
if (shape != null && shape.ShowResizeNodes && !CurrentRectangle.IsEmpty)
{
NodesVisible = true;
}
} }
private void SelectIntersectShape() private void SelectIntersectShape()
@ -1510,7 +1513,7 @@ private void SelectIntersectShape()
if (shape != null) if (shape != null)
{ {
CurrentShape = shape; CurrentShape = shape;
SelectCurrentShape(); SelectShape(shape);
} }
} }