From 279fc9b0f3dd0ac00c67be8d03377b349753101c Mon Sep 17 00:00:00 2001 From: Tim Young Date: Thu, 1 Mar 2018 12:50:30 -0600 Subject: [PATCH] Get move up / move down working for shape editor --- .../Resources/languages/edustrings.resx | 8 +++++ EduNetworkBuilder/ShapeEditor.cs | 31 +++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 8cc51b3..adaa011 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -2061,6 +2061,10 @@ Line SE_Line = Line + + Move Down + SE_MoveDown = Move Down + Move To End SE_MoveToEnd = Move to End @@ -2069,6 +2073,10 @@ Move To Top SE_MoveToTop = Move To Top + + Move Up + SE_MoveUp = Move Up + Shape SE_Shape = Shape diff --git a/EduNetworkBuilder/ShapeEditor.cs b/EduNetworkBuilder/ShapeEditor.cs index 4767271..9df20dc 100644 --- a/EduNetworkBuilder/ShapeEditor.cs +++ b/EduNetworkBuilder/ShapeEditor.cs @@ -197,8 +197,12 @@ namespace EduNetworkBuilder 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; + lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("SE_MoveUp")); + lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_MoveUp; + lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("SE_MoveDown")); + lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_MoveDown; + lbShapeList.ContextMenuStrip.Items.Add(NB.Translate("SE_MoveToTop")); + lbShapeList.ContextMenuStrip.Items[index++].Click += lblShape_MoveToTop; lbShapeList.ContextMenuStrip.Visible = true; lbShapeList.ContextMenuStrip.Show(Cursor.Position); @@ -228,6 +232,29 @@ namespace EduNetworkBuilder } } + void lblShapeMove(int delta) + { + if (delta == 0) return; + if (ShapeForEditing == null) return; + + Network myNet = NB.GetNetwork(); + int index = myNet.Shapes.IndexOf(ShapeForEditing); + int newindex = index + delta; + myNet.Shapes.Remove(ShapeForEditing); + if (newindex < 0) newindex = 0; + if (newindex >= myNet.Shapes.Count) myNet.Shapes.Add(ShapeForEditing); + else myNet.Shapes.Insert(newindex, ShapeForEditing); + FillFormItems(); + } + + void lblShape_MoveUp(object sender, EventArgs e) + { + lblShapeMove(-1); + } + void lblShape_MoveDown(object sender, EventArgs e) + { + lblShapeMove(1); + } void lblShape_MoveToEnd(object sender, EventArgs e) { if (ShapeForEditing != null)