Ejemplo n.º 1
0
 /// <summary>
 /// 获得第一个可用的网卡
 /// </summary>
 /// <returns></returns>
 public NetCard getEnableCard()
 {
     this.netCardDic = this.netCards.getAllNetCard();
     //遍历网卡写入
     foreach (KeyValuePair<string, NetCard> kv in this.netCardDic)
     {
         NetCard netcard = kv.Value;
         if (!netcard.isDrop() && netcard.isEnableIp())
         {
             return netcard;
         }
     }
     return null;
 }
Ejemplo n.º 2
0
        private void initPanel()
        {
            //遍历网卡填入下拉列表,同时判断是否有设置合适的网卡
            foreach (KeyValuePair<string, NetCard> kv in this.netCardDic)
            {
                this.comboBox.Items.Add(kv.Key);
                NetCard netcard = kv.Value;
                //if (this.isEnable) continue;
                if (!netcard.isDrop() && netcard.isEnableIp())
                {
                    this.isEnable = true;
                    this.selectedNetCardName = netcard.Name;
                    writeIpPanel();

                }
            }
            //如果没找到符合规定的网卡,那么就选择默认第一个
            if (!this.isEnable && comboBox.Items.Count>0)
            {
                this.selectedNetCardName = comboBox.Items[0].ToString();
                writeIpPanel();
            }
        }