private void btnSetConfig_Click(object sender, EventArgs e) { try { network_config = new networkconfig(); network_config.networkaddress = IPAddress.Parse(tb_NetworkAddress.Text.Trim()); network_config.subnetmask = IPAddress.Parse(tb_SubnetMask.Text.Trim()); network_config.dns = IPAddress.Parse(tb_DNS.Text.Trim()); network_config.defaultgateway = IPAddress.Parse(tb_DefaultGateway.Text.Trim()); network_config.dhcpserver = IPAddress.Parse(tb_DHCPServerIP.Text.Trim()); network_config.start = IPAddress.Parse(tb_IPStart.Text.Trim()); network_config.end = IPAddress.Parse(tb_IPEnd.Text.Trim()); network_config.leasetime = Int32.Parse(tb_LeaseTime.Text.Trim()); for (int i = 0; i < staticips.Count; i++) { network_config.static_ip.Add(staticips[i]); } } catch (Exception z) { MessageBox.Show(z.Message); return; } if (!checkvalidnetwork()) { network_config = new networkconfig(); return; } isset = true; this.Close(); }
private void btnImport_Click(object sender, EventArgs e) { FileStream fs; OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); try { fs = new FileStream(ofd.FileName, FileMode.Open); byte[] load = new byte[4096]; int len = fs.Read(load, 0, 4096); fs.Close(); byte[] data = new byte[len]; for (int i = 0; i < len; i++) { data[i] = load[i]; } network_config = new networkconfig(); network_config.fromByte(data); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } if (!checkvalidnetwork()) { network_config = new networkconfig(); return; } isset = true; this.Close(); }
public Setting(networkconfig n) { InitializeComponent(); tb_NetworkAddress.Text = n.networkaddress.ToString(); tb_SubnetMask.Text = n.subnetmask.ToString(); tb_DNS.Text = n.dns.ToString(); tb_DefaultGateway.Text = n.defaultgateway.ToString(); tb_DHCPServerIP.Text = n.dhcpserver.ToString(); tb_IPStart.Text = n.start.ToString(); tb_IPEnd.Text = n.end.ToString(); tb_LeaseTime.Text = n.leasetime.ToString(); staticips = new List <staticip>(); for (int i = 0; i < n.static_ip.Count; i++) { staticip s = new staticip(); s.ip = n.static_ip[i].ip; for (int j = 0; j < 6; j++) { s.mac[j] = n.static_ip[i].mac[j]; } ListViewItem o = new ListViewItem(displaymac(s.mac)); o.SubItems.Add(s.ip.ToString()); lv_StaticIP.Items.Add(o); } }
private void btnSetting_Click(object sender, EventArgs e) { Setting f = new Setting(network_config); f.ShowDialog(); if (f.isset) { network_config = f.network_config; } }
private void btnSetDefault_Click(object sender, EventArgs e) { network_config = new networkconfig(); isset = true; this.Close(); }