Able to right-click and delete shapes
This commit is contained in:
parent
e3fe80ea42
commit
9f2974cf6b
@ -1139,12 +1139,19 @@ namespace EduNetworkBuilder
|
||||
Shapes.Add(what);
|
||||
}
|
||||
|
||||
public void RemoveShape(NetShape What)
|
||||
{
|
||||
Shapes.Remove(What);
|
||||
}
|
||||
|
||||
public NetShape ShapeAtPoint(Point location)
|
||||
{
|
||||
foreach(NetShape shape in Shapes)
|
||||
{
|
||||
if (shape.CornersAreClickedOn(location))
|
||||
return shape;
|
||||
if (shape.CenterIsClickedOn(location))
|
||||
return shape;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -831,6 +831,13 @@ namespace EduNetworkBuilder
|
||||
if (ReleasedOn != null) PoweredOff = ReleasedOn.PowerOff;
|
||||
pbNetworkView.ContextMenuStrip.Items.Clear();
|
||||
|
||||
if(myNetwork.InShapeEditMode && ShapeForEditing != null)
|
||||
{
|
||||
//context menu for shape
|
||||
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Delete"));
|
||||
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_DeleteShape_Click;
|
||||
}
|
||||
|
||||
if (ItemsSelected.Count > 0)
|
||||
{
|
||||
//We do not want to do the normal menu...
|
||||
@ -995,7 +1002,7 @@ namespace EduNetworkBuilder
|
||||
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Orange"), null, pbNetworkView_Color_Click);
|
||||
(pbNetworkView.ContextMenuStrip.Items[MenuIndex] as ToolStripMenuItem).DropDownItems.Add(NB.Translate("NB_Cyan"), null, pbNetworkView_Color_Click);
|
||||
}
|
||||
if (ReleasedOn == null && ItemsSelected.Count == 0)
|
||||
if ((!myNetwork.InShapeEditMode && ReleasedOn == null && ItemsSelected.Count == 0) || (myNetwork.InShapeEditMode && ShapeForEditing == null))
|
||||
{
|
||||
pbNetworkView.ContextMenuStrip.Visible = false;
|
||||
}
|
||||
@ -1283,6 +1290,17 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
private void pbNetworkView_DeleteShape_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(ShapeForEditing != null)
|
||||
{
|
||||
myNetwork.RemoveShape(ShapeForEditing);
|
||||
ShapeForEditing = null;
|
||||
UpdateForm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void pbNetworkView_Delete_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(ItemsSelected.Count ==0)
|
||||
@ -1402,7 +1420,7 @@ namespace EduNetworkBuilder
|
||||
Point ClickLocation = myNetwork.clickedPos(e.Location);
|
||||
NetworkDevice ReleasedOn = myNetwork.ItemAtPosition(ClickLocation);
|
||||
NetworkLink ReleasedOnLink = null;
|
||||
if(ReleasedOn == null)
|
||||
if(ReleasedOn == null && !myNetwork.InShapeEditMode)
|
||||
ReleasedOnLink = myNetwork.LinkAtPosition(ClickLocation);
|
||||
|
||||
LastBackgroundImage = null;
|
||||
@ -1660,7 +1678,7 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
ItemClickedOn = null;
|
||||
ShapeForEditing = myNetwork.ShapeAtPoint(location);
|
||||
if(ShapeForEditing != null)
|
||||
if(ShapeForEditing != null && e.Button == MouseButtons.Left)
|
||||
{
|
||||
//we set the drag-point for the opposite corner
|
||||
ClickedLocation = ShapeForEditing.OppositePoint(location);
|
||||
@ -1670,6 +1688,10 @@ namespace EduNetworkBuilder
|
||||
cbLineColor.Text = ShapeForEditing.LineColor.Name;
|
||||
btnUpdateShape(); //Change the shape to what we are editing
|
||||
}
|
||||
else if(ShapeForEditing != null && e.Button == MouseButtons.Right)
|
||||
{
|
||||
//Right-clicking the shape. Context menu to come at button release!
|
||||
}
|
||||
}
|
||||
if(e.Button == MouseButtons.Left)
|
||||
MouseIsDown = true;
|
||||
|
Loading…
Reference in New Issue
Block a user