If image dialog is canceled then remove image shape

This commit is contained in:
Jaex 2016-08-23 16:39:15 +03:00
parent 59f0b43c18
commit f9ec01a2c1
3 changed files with 15 additions and 3 deletions

View file

@ -90,6 +90,11 @@ public virtual bool Intersects(Point position)
return Rectangle.Contains(position); return Rectangle.Contains(position);
} }
public void Remove()
{
Manager.DeleteShape(this);
}
public void AddShapePath(GraphicsPath gp, int sizeOffset = 0) public void AddShapePath(GraphicsPath gp, int sizeOffset = 0)
{ {
Rectangle rect = Rectangle; Rectangle rect = Rectangle;

View file

@ -58,7 +58,7 @@ public void SetImage(Image img, bool centerImage)
} }
} }
public void OpenImageDialog(bool centerImage) public bool OpenImageDialog(bool centerImage)
{ {
Manager.IsMoving = false; Manager.IsMoving = false;
@ -71,8 +71,12 @@ public void OpenImageDialog(bool centerImage)
if (img != null) if (img != null)
{ {
SetImage(img, centerImage); SetImage(img, centerImage);
return true;
} }
} }
return false;
} }
public override void OnDraw(Graphics g) public override void OnDraw(Graphics g)
@ -87,7 +91,10 @@ public override void OnCreating()
{ {
StartPosition = EndPosition = InputManager.MousePosition0Based; StartPosition = EndPosition = InputManager.MousePosition0Based;
OpenImageDialog(true); if (!OpenImageDialog(true))
{
Remove();
}
} }
public override void OnDoubleClicked() public override void OnDoubleClicked()

View file

@ -1526,7 +1526,7 @@ private void DeselectCurrentShape()
DeselectShape(CurrentShape); DeselectShape(CurrentShape);
} }
private void DeleteShape(BaseShape shape) public void DeleteShape(BaseShape shape)
{ {
if (shape != null) if (shape != null)
{ {