Some data validation

This commit is contained in:
Tim Young 2018-03-01 12:58:47 -06:00
parent 279fc9b0f3
commit 90843eec0d
1 changed files with 9 additions and 2 deletions

View File

@ -73,15 +73,18 @@ namespace EduNetworkBuilder
lblShapes.Text = NB.Translate("SE_Shapes", OurSettings);
}
void FillFormItems()
void FillFormItems(bool SaveIndex = false)
{
Network myNet = NB.GetNetwork();
int currentindex = lbShapeList.SelectedIndex;
lbShapeList.Items.Clear();
foreach (string one in myNet.ShapeDescriptions())
{
lbShapeList.Items.Add(one);
}
if (SaveIndex && currentindex >= 0) lbShapeList.SelectedIndex = currentindex;
}
void DataUpdated(object sender, EventArgs e)
@ -157,12 +160,16 @@ namespace EduNetworkBuilder
int.TryParse(tbY.Text, out Y);
int.TryParse(tbWidth.Text, out Width);
int.TryParse(tbHeight.Text, out Height);
if (X < 0) X = 0;
if (Y < 0) Y = 0;
if (Height < 0) Height = 0;
if (Width < 0) Width = 0;
ShapeForEditing.InArea = new Rectangle(X, Y, Width, Height);
ShapeForEditing.FillColor = Color.FromName(cbFillColor.Text);
ShapeForEditing.LineColor = Color.FromName(cbLineColor.Text);
ShapeForEditing.MyShape = NB.TryParseEnum<NetShapeType>(cbShape.Text, NetShapeType.rectangle);
}
FillFormItems(true); //Update the listbox
}
private void btnDone_Click(object sender, EventArgs e)