Able to edit links
This commit is contained in:
parent
620ffa1bc2
commit
b72c006915
@ -19,6 +19,7 @@ namespace EduNetworkBuilder
|
||||
NetworkDevice Source=null;
|
||||
NetworkDevice Dest=null;
|
||||
bool processing = false;
|
||||
NetworkLink EditingLink = null;
|
||||
List<string> UsedLinks = new List<string>();
|
||||
|
||||
public LinkEditor(NetworkDevice Src, NetworkDevice Dst)
|
||||
@ -56,6 +57,15 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
}
|
||||
|
||||
public LinkEditor(NetworkLink FromWhat)
|
||||
{
|
||||
InitializeComponent();
|
||||
LanguagifyComponents();
|
||||
|
||||
EditingLink = FromWhat;
|
||||
UpdateFormFromLink(); //read in all the previous values.
|
||||
}
|
||||
|
||||
private void LanguagifyComponents()
|
||||
{
|
||||
Text = NB.Translate("LE_btnLink");
|
||||
@ -118,6 +128,7 @@ namespace EduNetworkBuilder
|
||||
lbSrcNic.Items.Add(tString);
|
||||
}
|
||||
}
|
||||
if (EditingLink != null) lbSrcNic.Items.Add(EditingLink.Src.NicName);
|
||||
|
||||
lbDstHost.Items.Clear();
|
||||
foreach (string tString in dstHostnames)
|
||||
@ -150,6 +161,7 @@ namespace EduNetworkBuilder
|
||||
lbDstNic.Items.Add(tString);
|
||||
}
|
||||
}
|
||||
if (EditingLink != null) lbDstNic.Items.Add(EditingLink.Dst.NicName);
|
||||
|
||||
if (SrcNic != "")
|
||||
{
|
||||
@ -193,7 +205,7 @@ namespace EduNetworkBuilder
|
||||
processing = false;
|
||||
}
|
||||
|
||||
private void btnLink_Click(object sender, EventArgs e)
|
||||
private NetworkLink NewLinkFromSettings()
|
||||
{
|
||||
Network Net = NB.GetNetwork();
|
||||
NetworkDevice Src = Net.DeviceFromName(lbSrcHost.SelectedItem.ToString());
|
||||
@ -206,6 +218,20 @@ namespace EduNetworkBuilder
|
||||
if (sNic.GetNicType == NicType.wport || sNic.GetNicType == NicType.wlan)
|
||||
LT = LinkType.wireless; //We cannot have broken wireless links the same way.
|
||||
NetworkLink newLink = new NetworkLink(sNic.myID, dNic.myID, LT);
|
||||
return newLink;
|
||||
}
|
||||
|
||||
private void btnLink_Click(object sender, EventArgs e)
|
||||
{
|
||||
Network Net = NB.GetNetwork();
|
||||
|
||||
if(EditingLink != null)
|
||||
{
|
||||
Net.RemoveComponent(EditingLink); //get rid of the old one and put the new one in
|
||||
EditingLink = null;
|
||||
}
|
||||
|
||||
NetworkLink newLink = NewLinkFromSettings();
|
||||
Net.AddItem(newLink);
|
||||
Close();
|
||||
}
|
||||
@ -239,6 +265,42 @@ namespace EduNetworkBuilder
|
||||
Close();
|
||||
}
|
||||
|
||||
private void UpdateFormFromLink()
|
||||
{
|
||||
|
||||
Network Net = NB.GetNetwork();
|
||||
NetworkDevice Src = Net.GetDeviceFromID(EditingLink.Src.HostID);
|
||||
NetworkCard sNic = Src.NicFromID(EditingLink.Src.NicID);
|
||||
NetworkDevice Dst = Net.GetDeviceFromID(EditingLink.Dst.HostID);
|
||||
NetworkCard dNic = Dst.NicFromID(EditingLink.Dst.NicID);
|
||||
LinkType LT = EditingLink.theLinkType;
|
||||
|
||||
lbSrcNic.Items.Clear();
|
||||
//List the Nics of the selected host
|
||||
List<string> srcNics = Net.NetworkCardForHostList(Src.hostname, false, true);
|
||||
foreach (string tString in srcNics)
|
||||
{
|
||||
lbSrcNic.Items.Add(tString);
|
||||
}
|
||||
|
||||
lbDstNic.Items.Clear();
|
||||
List<string> dstNics = Net.NetworkCardForHostList(Dst.hostname, false, true, sNic.GetNicType);
|
||||
foreach (string tString in dstNics)
|
||||
{
|
||||
lbDstNic.Items.Add(tString);
|
||||
}
|
||||
|
||||
UpdateDeviceList();
|
||||
|
||||
lbSrcHost.SelectedItem = Src.hostname;
|
||||
lbSrcNic.SelectedItem = sNic.NicName();
|
||||
lbDstHost.SelectedItem = Dst.hostname;
|
||||
lbDstNic.SelectedItem = dNic.NicName();
|
||||
cbLinkType.SelectedItem = LT.ToString();
|
||||
|
||||
UpdateDeviceList();
|
||||
}
|
||||
|
||||
private void LinkEditor_Shown(object sender, EventArgs e)
|
||||
{
|
||||
BuilderWindow BW = NB.GetBuilderWin();
|
||||
|
@ -948,6 +948,10 @@ namespace EduNetworkBuilder
|
||||
pbNetworkView.ContextMenuStrip.Items[index].Tag = LinkReleasedOn;
|
||||
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_RemoveNetLink_Click;
|
||||
|
||||
pbNetworkView.ContextMenuStrip.Items.Add(NB.Translate("_Edit"));
|
||||
pbNetworkView.ContextMenuStrip.Items[index].Tag = LinkReleasedOn;
|
||||
pbNetworkView.ContextMenuStrip.Items[index++].Click += pbNetworkView_EditNetLink_Click;
|
||||
|
||||
pbNetworkView.ContextMenuStrip.Visible = true;
|
||||
pbNetworkView.ContextMenuStrip.Show(Cursor.Position);
|
||||
|
||||
@ -1085,6 +1089,21 @@ namespace EduNetworkBuilder
|
||||
|
||||
}
|
||||
|
||||
private void pbNetworkView_EditNetLink_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
|
||||
LinkEditor LE = new LinkEditor(NL);
|
||||
LE.ShowDialog();
|
||||
}
|
||||
myNetwork.TestForCompletion(true);
|
||||
pbNetworkView.Update();
|
||||
UpdateVisuals();
|
||||
}
|
||||
|
||||
private void pbNetworkView_RemoveNetLink_Click(object sender, EventArgs e)
|
||||
{
|
||||
ToolStripItem thing = (ToolStripItem)sender;
|
||||
|
@ -82,6 +82,11 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
get { return DstNic; }
|
||||
}
|
||||
public void SetSourceDest(HostNicID src, HostNicID dst)
|
||||
{
|
||||
SrcNic = src;
|
||||
DstNic = dst;
|
||||
}
|
||||
public override void Load(XmlNode theNode)
|
||||
{
|
||||
foreach (XmlNode Individual in theNode.ChildNodes)
|
||||
|
Loading…
Reference in New Issue
Block a user