Update link images if we change the device the link is connecting from / to

This commit is contained in:
Tim Young 2023-08-17 10:35:18 -07:00
parent 2f4cf36011
commit dca858ff46

View File

@ -88,11 +88,12 @@ namespace EduNetworkBuilder
if (lbDstHost.SelectedItem != null) if (lbDstHost.SelectedItem != null)
DstHost = lbDstHost.SelectedItem.ToString(); DstHost = lbDstHost.SelectedItem.ToString();
string SrcNic = ""; string SrcNic = "";
NetworkDevice Src = null;
if (lbSrcNic.SelectedItem != null) if (lbSrcNic.SelectedItem != null)
{ {
Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
SrcNic = lbSrcNic.SelectedItem.ToString(); SrcNic = lbSrcNic.SelectedItem.ToString();
int sNicIndex = lbSrcNic.SelectedIndex; int sNicIndex = lbSrcNic.SelectedIndex;
NetworkDevice Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
NetworkCard sNic = null; NetworkCard sNic = null;
if(Src != null) sNic = Src.NicFromName(lbSrcNic.SelectedItem.ToString()); if(Src != null) sNic = Src.NicFromName(lbSrcNic.SelectedItem.ToString());
if(sNic != null) srcNicType = sNic.GetNicType; if(sNic != null) srcNicType = sNic.GetNicType;
@ -178,7 +179,34 @@ namespace EduNetworkBuilder
lbDstNic.SelectedIndex = tint; lbDstNic.SelectedIndex = tint;
} }
if(lbDstNic.SelectedIndex > -1 && lbSrcNic.SelectedIndex > -1) if (lbSrcHost.SelectedItem != null)
{
Src = myNet.DeviceFromName(lbSrcHost.SelectedItem.ToString());
pbSource.Image = Src.GetImage();
pbSource.Invalidate();
}
else
{
pbSource.Image = null;
pbSource.Invalidate();
}
if (lbDstHost.SelectedItem != null)
{
NetworkDevice Dest = myNet.DeviceFromName(lbDstHost.SelectedItem.ToString());
if (Dest != null)
{
pbDest.Image = Dest.GetImage();
pbDest.Invalidate();
}
}
else
{
pbDest.Image = null;
pbDest.Invalidate();
}
if (lbDstNic.SelectedIndex > -1 && lbSrcNic.SelectedIndex > -1)
{ {
btnLink.Enabled = true; btnLink.Enabled = true;
} }