IPAddress edit box should now appear inside the network box.

This commit is contained in:
Tim Young 2017-02-25 10:33:56 +03:00
parent 4a5450ac54
commit f4ab85f359
9 changed files with 34 additions and 28 deletions

View File

@ -432,7 +432,7 @@ namespace EduNetworkBuilder
//selectedNIC = Regex.Replace(selectedNIC, " .*", "");
//selectedNIC = Regex.Replace(selectedNIC, "\\*", "");
ndCLonedItem.EditNicInterface(selectedNIC, lbAddresses.SelectedIndex);
ndCLonedItem.EditNicInterface(selectedNIC, lbAddresses.SelectedIndex, this);
UpdateForm();
}
}
@ -483,7 +483,7 @@ namespace EduNetworkBuilder
if (NB.GetComponentType(ClonedItem) == GeneralComponentType.device)
{
NetworkDevice nd = (NetworkDevice)ClonedItem;
nd.EditGateway();
nd.EditGateway(this);
UpdateForm();
}
}

View File

@ -96,17 +96,17 @@ namespace EduNetworkBuilder
return false;
}
public bool Edit(NetworkDevice FromWhat, string message="")
public bool Edit(NetworkDevice FromWhat, Form ParentForm, string message="")
{
IPAddressEntry IPe = new IPAddressEntry(this, FromWhat);
IPAddressEntry IPe = new IPAddressEntry(this, FromWhat, ParentForm);
if (message != "")
IPe.Text = message;
return IPe.Edit();
}
public bool Edit(NetworkDevice FromWhat, IPAddress DHCPif)
public bool Edit(NetworkDevice FromWhat, IPAddress DHCPif, Form ParentForm)
{
IPAddressEntry IPe = new IPAddressEntry(this, FromWhat);
IPAddressEntry IPe = new IPAddressEntry(this, FromWhat, ParentForm);
return IPe.Edit(FromWhat, DHCPif);
}

View File

@ -21,10 +21,14 @@ namespace EduNetworkBuilder
NetworkDevice ParentDevice = null;
public IPAddressEntry(IPAddress toEdit, NetworkDevice ToEdit)
public IPAddressEntry(IPAddress toEdit, NetworkDevice ToEdit, Form ParentForm)
{
InitializeComponent();
LanguagifyComponents();
if(ParentForm != null)
{
Location = new Point(ParentForm.Location.X + (ParentForm.Width / 2), ParentForm.Location.Y + (ParentForm.Height / 2));
}
ParentDevice = ToEdit;
Network myNet = NB.GetNetwork();
IPAddress lastIP = myNet.RetrieveLastIP();

View File

@ -385,7 +385,7 @@ namespace EduNetworkBuilder
private void AddRoute()
{
IPAddress newip = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, NB.ZeroIPString);
newip.Edit(myNetDevice,NB.Translate("LBW_AddRouteCreate"));
newip.Edit(myNetDevice, this, NB.Translate("LBW_AddRouteCreate"));
myNetDevice.AddRoute(newip);
UpdateForm();
}
@ -398,12 +398,12 @@ namespace EduNetworkBuilder
if (lbWindowData.SelectedIndex >= EditableCount) return;
if (lbWindowData.SelectedIndex < 1) return;
//we always subtract 1 since we have added one line of comment to the list
myNetDevice.EditRoute(lbWindowData.SelectedIndex - 1);
myNetDevice.EditRoute(lbWindowData.SelectedIndex - 1, this);
}
if(MyMode == LBContents.dhcp)
{
//We always add one since we are skipping the loopback device
myNetDevice.EditDHCP(lbWindowData.SelectedIndex + 1);
myNetDevice.EditDHCP(lbWindowData.SelectedIndex + 1, this);
}
if (MyMode == LBContents.puzzles)
{

View File

@ -773,7 +773,7 @@ namespace EduNetworkBuilder
bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to ping from
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, NB.Translate("_Ping"));
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"));
if(todo)
{
ItemClickedOn.PingFromHere(destination);
@ -815,7 +815,7 @@ namespace EduNetworkBuilder
bool todo = true;
if (ItemClickedOn == null) return; //we do not have something chosen to arp request from
IPAddress destination = new IPAddress(NB.ZeroIPString, "255.255.255.255", IPAddressType.ip_only);
todo = destination.Edit(ItemClickedOn, NB.Translate("H_ARP_Title2"));
todo = destination.Edit(ItemClickedOn, this, NB.Translate("H_ARP_Title2"));
if (todo)
{
ItemClickedOn.AskArpFromHere(destination);
@ -1155,7 +1155,7 @@ namespace EduNetworkBuilder
{
bool todo = true;
IPAddress destination = new IPAddress(NB.ZeroIPString, NB.ZeroIPString, IPAddressType.ip_only);
todo = destination.Edit(null, NB.Translate("NB_NetViewPng"));
todo = destination.Edit(null, this, NB.Translate("NB_NetViewPng"));
if (todo)
{
myNetwork.DoAllPing(destination);

View File

@ -7,6 +7,7 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.IO;
using System.Xml;
using System.Windows.Forms;
namespace EduNetworkBuilder
@ -251,11 +252,11 @@ namespace EduNetworkBuilder
return false;
}
public void EditInterface(int index)
public void EditInterface(int index, Form ParentForm)
{
if (index < 0 || index > interfaces.Count())
return;
interfaces[index].EditAddress();
interfaces[index].EditAddress(ParentForm);
}
public void DeleteInterface(int index)
{

View File

@ -191,7 +191,7 @@ namespace EduNetworkBuilder
{
MyNicToEdit.TunnelEndpoint = new IPAddress(NB.ZeroIPString, "255.255.255.0", IPAddressType.ip_only);
}
MyNicToEdit.TunnelEndpoint.Edit(nd, NB.Translate("_Endpt"));
MyNicToEdit.TunnelEndpoint.Edit(nd, this, NB.Translate("_Endpt"));
UpdateForm();
}
}

View File

@ -293,9 +293,9 @@ namespace EduNetworkBuilder
}
}
public void EditGateway()
public void EditGateway(Form ParentForm)
{
DefaultGW.Edit(this,NB.Translate("ND_EdtGteway"));
DefaultGW.Edit(this,ParentForm,NB.Translate("ND_EdtGteway"));
}
public IPAddress GetGateway()
@ -703,11 +703,11 @@ namespace EduNetworkBuilder
}
}
public void EditNicInterface(int NicIndex, int ifIndex)
public void EditNicInterface(int NicIndex, int ifIndex, Form ParentForm)
{
if(NicIndex >=0 && NicIndex < NICs.Count())
{
NICs[NicIndex].EditInterface(ifIndex);
NICs[NicIndex].EditInterface(ifIndex, ParentForm);
}
}
public void DeleteNicInterface(int NicIndex, int ifIndex)
@ -717,12 +717,12 @@ namespace EduNetworkBuilder
NICs[NicIndex].DeleteInterface(ifIndex);
}
}
public void EditNicInterface(string NicName, int ifIndex)
public void EditNicInterface(string NicName, int ifIndex, Form ParentForm)
{
NetworkCard nic = NicFromName(NicName);
if (nic != null)
{
nic.EditInterface(ifIndex);
nic.EditInterface(ifIndex, ParentForm);
}
}
@ -2402,11 +2402,11 @@ namespace EduNetworkBuilder
return RouteTable;
}
public void EditRoute(int index)
public void EditRoute(int index, Form ParentForm)
{
if (index < 0) return;
if (index >= RouteTable.Count) return;
RouteTable[index].Edit(this);
RouteTable[index].Edit(this, ParentForm);
}
public void DeleteRoute(int index)
{
@ -2740,7 +2740,7 @@ namespace EduNetworkBuilder
}
return null;
}
public void EditDHCP(int index)
public void EditDHCP(int index, Form ParentForm)
{
if (index > DHCPRanges.Count) return;
if (index < 0) return;
@ -2756,7 +2756,7 @@ namespace EduNetworkBuilder
}
}
if (!found) return;
DHCPRanges[index].Edit(this, ifIP); //We need to pass the interface that is local to this
DHCPRanges[index].Edit(this, ifIP, ParentForm); //We need to pass the interface that is local to this
DHCPLeases.Clear();
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace EduNetworkBuilder
@ -167,11 +168,11 @@ namespace EduNetworkBuilder
/// <summary>
/// Pop up a window to edit this address.
/// </summary>
public void EditAddress()
public void EditAddress(Form ParentForm)
{
Network myNet = NB.GetNetwork();
NetworkDevice ND = myNet.GetDeviceFromID(AttachedToHostNic);
IPAddressEntry ipe = new IPAddressEntry(myIP,ND);
IPAddressEntry ipe = new IPAddressEntry(myIP,ND, ParentForm);
ipe.ShowDialog();
}
public bool isLocal(IPAddress tIp, bool AllowZeroMatch = true)