Esempio n. 1
0
 public AddressEntryDelegate(AddressEntryDataSource datasource)
 {
     DataSource = datasource;
 }
Esempio n. 2
0
        partial void btnList(NSObject sender)
        {
            string errormsg = "";
            string network  = txtNetwork.StringValue;

            if (network != null)
            {
                IPNetwork           ipnetwork = null;
                IPAddressCollection subnet    = null;
                bool invalid = false;

                if (!W.IsValidIP(network))
                {
                    invalid  = true;
                    errormsg = "Invalid IP or network address. When specifying a network address you must use CIDR notation. Example: 192.168.1.0/24";
                }
                else
                {
                    try
                    {
                        // get list of IPs
                        ipnetwork = IPNetwork.Parse(network);
                        subnet    = IPNetwork.ListIPAddress(ipnetwork);
                    }
                    catch (ArgumentException)
                    {
                        invalid  = true;
                        errormsg = "Failed to retrieve IP addresses for the network.";
                    }
                }

                if (invalid == false)
                {
                    ToggleGUI(false);

                    DataSource         = new AddressEntryDataSource();
                    Delegate           = new AddressEntryDelegate(DataSource);
                    tblList.Delegate   = Delegate;
                    tblList.DataSource = DataSource;
                    ReloadTable();

                    List <string> subnetwork = new List <string>();
                    foreach (IPAddress ip in subnet)
                    {
                        subnetwork.Add(ip.ToString());
                    }

                    if (chkPIng.IntValue == 1)
                    {
                        runningTasks = 0;
                        stopPings    = false;

                        // launch monitoring thread that fills threadpool
                        Thread monitor = new Thread(() => { MonitorThread(W.Split <string>(subnetwork)); });
                        monitor.Start();
                    }
                    else
                    {
                        int    checkDNS = chkDNS.IntValue;
                        Thread list     = new Thread(() => { IPListThread(subnetwork, checkDNS); });
                        list.Start();
                    }
                }
                else
                {
                    // invalid input, show an alert
                    W.Alert("Error", errormsg, NSAlertStyle.Critical);
                }
            }
        }