/// <summary> /// Создает компы с адресами в диапазоне /// </summary> /// <param name="start_ip"></param> /// <param name="end_ip"></param> /// <param name="mask"></param> public void SetPCs(IPAddress start_ip, IPAddress end_ip, IPAddress mask, IPAddress gateway) { var tools = new IPAddressTools.RangeFinder(); var ips = tools.GetIPRange(start_ip, end_ip); pcs.Clear(); foreach (var ip in ips) { var pc = new PC(this); pc.Left = -1000; pc.Top = -1000; pc.SetIP(new IPAddressWithMask(ip, mask)); pc.Gateway = gateway; pcs.Add(pc); } lblIPStart.Text = start_ip.ToString(); lblIPEnd.Text = end_ip.ToString(); fill_combo_box(); }
private static IEnumerable <IPAddress> get_range(string str) { if (!str.Contains('-')) { return new List <IPAddress>() { IPAddress.Parse(str) } } ; else { //Несколько записей int index = str.IndexOf('-'); var start_str = str.Substring(0, index); var end_str = str.Substring(index + 1); var tool = new IPAddressTools.RangeFinder(); return(tool.GetIPRange(IPAddress.Parse(start_str), IPAddress.Parse(end_str))); } }