public void changeIP(ipItem item) { if (item.changeIP) { if (!item.autoIP) { setIP(item.network, item.IP, item.mask, item.gateway); } else { setIP(item.network); } } if (item.changeDNS) { if (!item.autoDNS) { setDNS(item.network, item.DNS1 + "," + item.DNS2); } else { setDNS(item.network, ""); } } }
public void ChangeIP(int index) { if (index >= IPlist.Count) { return; } ipItem item = IPlist[index]; changeIP(item); }
private void btnSave_Click(object sender, EventArgs e) { ipItem item = new ipItem(); item.name = cbProfile.Text; item.network = cbNetwork.Text; item.changeIP = chbSetIP.Checked; if (rbIPauto.Checked) { item.autoIP = true; } else { item.autoIP = false; } item.IP = txtIPaddress.Text; item.mask = txtIPmask.Text; item.gateway = txtGateway.Text; item.changeDNS = chbSetDNS.Checked; if (rbDNSauto.Checked) { item.autoDNS = true; } else { item.autoDNS = false; } item.DNS1 = txtDNS1.Text; item.DNS2 = txtDNS2.Text; List <ipItem> list = IPdev.GetList(); bool edited = false; for (int i = 0; i < list.Count; i++) { if (list[i].name == cbProfile.Text) { IPdev.EditList(i, item); edited = true; break; } } if (!edited) { IPdev.AddList(item); loadProfile(); loadList(list.Count - 1); } }
private void btnSet_Click(object sender, EventArgs e) { ipItem item = new ipItem(); item.name = cbProfile.Text; item.network = cbNetwork.Text; item.changeIP = chbSetIP.Checked; if (rbIPauto.Checked) { item.autoIP = true; } else { item.autoIP = false; } item.IP = txtIPaddress.Text; item.mask = txtIPmask.Text; item.gateway = txtGateway.Text; item.changeDNS = chbSetDNS.Checked; if (rbDNSauto.Checked) { item.autoDNS = true; } else { item.autoDNS = false; } item.DNS1 = txtDNS1.Text; item.DNS2 = txtDNS2.Text; try { IPdev.changeIP(item); Dialogs.ShowInfo("IP updated!", "Info"); } catch (Exception err) { Dialogs.ShowErr(err.Message, "Error"); } RefreshIP(); }
public void AddList(ipItem item) { IPlist = addToList(IPlist, item); }
public void EditList(int index, ipItem item) { IPlist = editList(IPlist, index, item); }
private List <ipItem> addToList(List <ipItem> list, ipItem item) { list.Add(item); return(list); }
private List <ipItem> editList(List <ipItem> list, int index, ipItem item) { list.RemoveAt(index); list.Insert(index, item); return(list); }