From 07dc0224c3936fa4e56dc4f35c121fe033f6a01c Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 17 Feb 2018 13:55:22 +0000 Subject: [PATCH] Able to right-click and replace a broken link. --- EduNetworkBuilder/NetworkBuilder.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index f79084b..2a5835a 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -953,6 +953,13 @@ namespace EduNetworkBuilder pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Edit")); pbNetworkView.ContextMenuStrip.Items[index].Tag = LinkReleasedOn; pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_EditNetLink_Click; + + if (LinkReleasedOn.theLinkType == LinkType.broken) + { + pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("NB_Replace")); + pbNetworkView.ContextMenuStrip.Items[index].Tag = LinkReleasedOn; + pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_ReplaceNetLink_Click; + } } pbNetworkView.ContextMenuStrip.Visible = true; pbNetworkView.ContextMenuStrip.Show(Cursor.Position); @@ -1106,6 +1113,28 @@ namespace EduNetworkBuilder UpdateVisuals(); } + private void pbNetworkView_ReplaceNetLink_Click(object sender, EventArgs e) + { + ToolStripItem thing = (ToolStripItem)sender; + if (thing.Tag != null) + { + NetworkLink NL = (NetworkLink)thing.Tag; + //This may delete the old link and make a new one + if (NL.theLinkType != LinkType.wireless) + { + HostNicID source = NL.Src; + HostNicID dest = NL.Dst; + myNetwork.RemoveComponent(NL); + NetworkLink nNL = new NetworkLink(source, dest, LinkType.normal); + myNetwork.AddItem(nNL); + } + } + myNetwork.TestForCompletion(true); + pbNetworkView.Update(); + UpdateVisuals(); + } + + private void pbNetworkView_RemoveNetLink_Click(object sender, EventArgs e) { ToolStripItem thing = (ToolStripItem)sender;