start of context menu

This commit is contained in:
Tim Young 2018-03-01 12:15:53 -06:00
parent 05519891db
commit 0d4dff5e17
2 changed files with 61 additions and 1 deletions

View File

@ -58,6 +58,8 @@
this.lbShapeList.Size = new System.Drawing.Size(120, 212);
this.lbShapeList.TabIndex = 0;
this.lbShapeList.SelectedIndexChanged += new System.EventHandler(this.lbShapeList_SelectedIndexChanged);
this.lbShapeList.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbShapeList_MouseDown);
this.lbShapeList.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lbShapeList_MouseUp);
//
// lblShapes
//

View File

@ -54,9 +54,27 @@ namespace EduNetworkBuilder
if (one != NetShapeType.none)
cbShape.Items.Add(one.ToString());
}
tbHeight.Leave += DataUpdated;
tbWidth.Leave += DataUpdated;
tbX.Leave += DataUpdated;
tbY.Leave += DataUpdated;
cbFillColor.Leave += DataUpdated;
cbLineColor.Leave += DataUpdated;
cbShape.Leave += DataUpdated;
}
void DataUpdated(object sender, EventArgs e)
{
ValuesToShape();
}
private void lbShapeList_SelectedIndexChanged(object sender, EventArgs e)
{
ChangeSelectionTo(lbShapeList.Text);
}
void ChangeSelectionTo(string ToSelect)
{
Network myNet = NB.GetNetwork();
//Fill in the text from the shape
@ -64,7 +82,7 @@ namespace EduNetworkBuilder
ShapeForEditing = null;
foreach (NetShape oneShape in myNet.Shapes)
{
if (oneShape.ToString() == lbShapeList.Text)
if (oneShape.ToString() == ToSelect)
ShapeForEditing = oneShape;
}
FieldsFromShape(ShapeForEditing);
@ -131,5 +149,45 @@ namespace EduNetworkBuilder
{
Close();
}
private void lbShapeList_MouseUp(object sender, MouseEventArgs e)
{
if(lbShapeList.SelectedItem != null)
{
//We have an item that we have clicked on
ChangeSelectionTo(lbShapeList.Text);
}
if (e.Button == MouseButtons.Right)
{
//We should make a context menu here.
// Delete
// Move Up
// Move Down
// Move to top
// Move to bottom
if(ShapeForEditing != null)
{
int index = 0;
if (lbShapeList.ContextMenuStrip == null)
{
lbShapeList.ContextMenuStrip = new ContextMenuStrip();
}
lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("_Delete"));
lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_Delete;
}
}
//If it is a left mouse button, we simply select the item so we can edit it
}
void lblShape_Delete(object sender, EventArgs e)
{
}
private void lbShapeList_MouseDown(object sender, MouseEventArgs e)
{
}
}
}