示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                string      HostName = Dns.GetHostName(); //得到主机名
                IPHostEntry IpEntry  = Dns.GetHostEntry(HostName);
                this.IpComboBox.Items.Clear();
                for (int i = 0; i < IpEntry.AddressList.Length; i++)
                {
                    //从IP地址列表中筛选出IPv4类型的IP地址
                    //AddressFamily.InterNetwork表示此IP为IPv4,
                    //AddressFamily.InterNetworkV6表示此地址为IPv6类型
                    if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                    {
                        this.IpComboBox.Items.Add(IpEntry.AddressList[i].ToString());
                        //rbtnet_.configNet(IpEntry.AddressList[i].ToString(), 6001, false, true, "");
                    }
                }
                if (startConfigNet)
                {
                    rbtnet_.configNet(useIp, 6001, false, true, "");
                    //string strIP = this.IpComboBox.Text;
                    //if (!string.IsNullOrEmpty(strIP))
                    //{
                    //    rbtnet_.configNet(strIP, 6001, false, true, "");
                    //}
                }

                if (string.IsNullOrEmpty(this.IpComboBox.Text) && this.IpComboBox.Items.Count > 0)
                {
                    this.IpComboBox.Text = this.IpComboBox.Items[0].ToString();
                }

                int nItemCount = this.listView1.Items.Count;
                int count      = 0;
                for (int i = 0; i < nItemCount; ++i)
                {
                    if (this.listView1.Items[i].SubItems[2].Text == "在线")
                    {
                        count++;
                    }
                }
                this.label5.Text = count.ToString();

                if (isClosing)
                {
                    delayClose--;
                    if (delayClose <= 0)
                    {
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取本机IP出错:" + ex.Message);
            }
        }
示例#2
0
 private void DispatcherTimer_Tick(object sender, EventArgs e)
 {
     if (isStart)
     {
         string strIP = this.cbIps.Text;
         if (!string.IsNullOrEmpty(strIP))
         {
             rbtNet.configNet(strIP, 6001, false, true, "");
         }
     }
 }