Able to add a new shape. Cannot edit existing shapes yet...

This commit is contained in:
Tim Young 2018-02-27 16:03:29 -06:00
parent 4f3f260c48
commit 1d1290c3c2
3 changed files with 34 additions and 8 deletions

View File

@ -19,11 +19,12 @@ namespace EduNetworkBuilder
public Color FillColor = Color.Empty; public Color FillColor = Color.Empty;
int DragSize = 15; int DragSize = 15;
public NetShape(NetShapeType What, Rectangle Where, Color color) public NetShape(NetShapeType What, Rectangle Where, Color fillcolor, Color linecolor)
{ {
MyShape = What; MyShape = What;
InArea = Where; InArea = Where;
FillColor = color; FillColor = fillcolor;
LineColor = linecolor;
} }
public NetShape(XmlNode what) public NetShape(XmlNode what)
{ {

View File

@ -1115,6 +1115,11 @@ namespace EduNetworkBuilder
} }
} }
public void AddShape(NetShape what)
{
Shapes.Add(what);
}
void KillAllExtraWindows(bool EvenRTF=false) void KillAllExtraWindows(bool EvenRTF=false)
{ {
for(int i = Application.OpenForms.Count -1; i >=0; i--) for(int i = Application.OpenForms.Count -1; i >=0; i--)

View File

@ -1481,12 +1481,32 @@ namespace EduNetworkBuilder
Rectangle selectbox = new Rectangle(topCorner.X, topCorner.Y, botCorner.X - topCorner.X, botCorner.Y - topCorner.Y); Rectangle selectbox = new Rectangle(topCorner.X, topCorner.Y, botCorner.X - topCorner.X, botCorner.Y - topCorner.Y);
ItemsSelected.AddRange(myNetwork.DevicesInRectangle(selectbox)); if (!myNetwork.InShapeEditMode)
//Console.WriteLine("Selected " + ItemsSelected.Count + " items"); {
MouseIsDown = false; ItemsSelected.AddRange(myNetwork.DevicesInRectangle(selectbox));
DrawHighlightBoxes(); //Console.WriteLine("Selected " + ItemsSelected.Count + " items");
pbNetworkView.Invalidate(); MouseIsDown = false;
return; DrawHighlightBoxes();
pbNetworkView.Invalidate();
return;
}
else
{
//We just made a shape.
try
{
Color FillColor = Color.FromName(cbFillColor.Text);
Color LineColor = Color.FromName(cbLineColor.Text);
NetShape NS = new NetShape(CurrentShape, selectbox,FillColor,LineColor);
myNetwork.AddShape(NS);
UpdateForm();
}
catch
{
//Nothing to do. Something is wrong with the colors.
}
}
} }
MouseIsDown = false; MouseIsDown = false;
if (selectedButton == "btnLink") if (selectedButton == "btnLink")