Ejemplo n.º 1
0
 private string FindHostedNetworkId()
 {
     foreach (var nic in IcsManager.GetAllIPv4Interfaces())
     {
         if (nic.OperationalStatus == OperationalStatus.Up &&
             HasHostedNetworkAttrs(nic))
         {
             return(nic.Id);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        private bool PopulateNetworkList(string SelStr = null)
        {
            try
            {
                cbSourceNetworks.BeginUpdate();

                cbSourceNetworks.Items.Clear();

                int idx = -1;
                foreach (var nic in IcsManager.GetAllIPv4Interfaces())
                {
                    if (nic.OperationalStatus != OperationalStatus.Up ||
                        HasHostedNetworkAttrs(nic))
                    {
                        continue;
                    }

                    string name = nic.Name;
                    if (!string.IsNullOrEmpty(SelStr) &&
                        name.Equals(SelStr, StringComparison.CurrentCulture))
                    {
                        idx    = cbSourceNetworks.Items.Count;
                        SelStr = null;
                    }

                    cbSourceNetworks.Items.Add(new NicItem(
                                                   Name: name,
                                                   Guid: nic.Id,
                                                   Description: nic.Description
                                                   ));
                }
                cbSourceNetworks.EndUpdate();

                if (idx == -1)
                {
                    idx = 0;
                }

                if (cbSourceNetworks.Items.Count > 0)
                {
                    cbSourceNetworks.SelectedIndex = idx;
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }