Better behavior when resizing shape window

This commit is contained in:
Tim Young 2018-03-01 12:29:54 -06:00
parent 6d8553e750
commit 5d373a5e95
3 changed files with 58 additions and 6 deletions

View File

@ -2049,4 +2049,12 @@
<value>Cannot place a tree on top of a tree.</value> <value>Cannot place a tree on top of a tree.</value>
<comment>NB_TreePlacementError = Cannot place a tree on top of a tree.</comment> <comment>NB_TreePlacementError = Cannot place a tree on top of a tree.</comment>
</data> </data>
<data name="SE_MoveToEnd" xml:space="preserve">
<value>Move To End</value>
<comment>SE_MoveToEnd = Move to End</comment>
</data>
<data name="SE_MoveToTop" xml:space="preserve">
<value>Move To Top</value>
<comment>SE_MoveToTop = Move To Top</comment>
</data>
</root> </root>

View File

@ -51,6 +51,9 @@
// //
// lbShapeList // lbShapeList
// //
this.lbShapeList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lbShapeList.FormattingEnabled = true; this.lbShapeList.FormattingEnabled = true;
this.lbShapeList.ItemHeight = 16; this.lbShapeList.ItemHeight = 16;
this.lbShapeList.Location = new System.Drawing.Point(12, 29); this.lbShapeList.Location = new System.Drawing.Point(12, 29);
@ -72,6 +75,7 @@
// //
// btnDone // btnDone
// //
this.btnDone.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnDone.Location = new System.Drawing.Point(201, 244); this.btnDone.Location = new System.Drawing.Point(201, 244);
this.btnDone.Name = "btnDone"; this.btnDone.Name = "btnDone";
this.btnDone.Size = new System.Drawing.Size(75, 23); this.btnDone.Size = new System.Drawing.Size(75, 23);
@ -146,6 +150,7 @@
// //
// panel1 // panel1
// //
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.panel1.Controls.Add(this.lblShape); this.panel1.Controls.Add(this.lblShape);
this.panel1.Controls.Add(this.cbShape); this.panel1.Controls.Add(this.cbShape);
this.panel1.Controls.Add(this.lblLine); this.panel1.Controls.Add(this.lblLine);

View File

@ -42,12 +42,6 @@ namespace EduNetworkBuilder
cbLineColor.Items.Add(one); cbLineColor.Items.Add(one);
} }
lbShapeList.Items.Clear();
foreach(string one in myNet.ShapeDescriptions())
{
lbShapeList.Items.Add(one);
}
cbShape.Items.Clear(); cbShape.Items.Clear();
foreach(NetShapeType one in Enum.GetValues(typeof(NetShapeType))) foreach(NetShapeType one in Enum.GetValues(typeof(NetShapeType)))
{ {
@ -62,6 +56,19 @@ namespace EduNetworkBuilder
cbFillColor.Leave += DataUpdated; cbFillColor.Leave += DataUpdated;
cbLineColor.Leave += DataUpdated; cbLineColor.Leave += DataUpdated;
cbShape.Leave += DataUpdated; cbShape.Leave += DataUpdated;
FillFormItems();
}
void FillFormItems()
{
Network myNet = NB.GetNetwork();
lbShapeList.Items.Clear();
foreach (string one in myNet.ShapeDescriptions())
{
lbShapeList.Items.Add(one);
}
} }
void DataUpdated(object sender, EventArgs e) void DataUpdated(object sender, EventArgs e)
@ -172,8 +179,13 @@ namespace EduNetworkBuilder
{ {
lbShapeList.ContextMenuStrip = new ContextMenuStrip(); lbShapeList.ContextMenuStrip = new ContextMenuStrip();
} }
lbShapeList.ContextMenuStrip.Items.Clear();
lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("_Delete")); lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("_Delete"));
lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_Delete; lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_Delete;
lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("SE_MoveToTop"));
lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_MoveToTop;
lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("SE_MoveToEnd"));
lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_MoveToEnd;
} }
} }
@ -182,7 +194,34 @@ namespace EduNetworkBuilder
void lblShape_Delete(object sender, EventArgs e) void lblShape_Delete(object sender, EventArgs e)
{ {
if(ShapeForEditing != null)
{
Network myNet = NB.GetNetwork();
myNet.RemoveShape(ShapeForEditing);
FillFormItems();
}
}
void lblShape_MoveToTop(object sender, EventArgs e)
{
if (ShapeForEditing != null)
{
Network myNet = NB.GetNetwork();
myNet.RemoveShape(ShapeForEditing);
myNet.Shapes.Insert(0, ShapeForEditing);
FillFormItems();
}
}
void lblShape_MoveToEnd(object sender, EventArgs e)
{
if (ShapeForEditing != null)
{
Network myNet = NB.GetNetwork();
myNet.RemoveShape(ShapeForEditing);
myNet.Shapes.Add(ShapeForEditing);
FillFormItems();
}
} }
private void lbShapeList_MouseDown(object sender, MouseEventArgs e) private void lbShapeList_MouseDown(object sender, MouseEventArgs e)