示例#1
0
 private void LoadItems(bool enableView = true)
 {
     itemView.BeginUpdate();
     foreach (KeyValuePair <uint, byte[]> datas in MainGXTFile.DataItems)
     {
         string dataString = System.Text.Encoding.UTF8.GetString(datas.Value);
         ComponentOwl.BetterListView.BetterListViewItem newItem = new ComponentOwl.BetterListView.BetterListViewItem();
         newItem.Text = string.Format("0x{0:X8}", datas.Key);
         newItem.SubItems.Add(dataString);
         itemView.Items.Add(newItem);
     }
     itemView.EndUpdate();
     itemView.Enabled = enableView;
 }
示例#2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            this.btnStart.Enabled = false;
            int port = -1;
            if (int.TryParse(this.tbPort.Text, out port) && port <= 0)
            {
                MessageBox.Show("Wrong tcp port");
                return;
            }

            int clientNums = -1;
            if (int.TryParse(this.tbClientNum.Text, out clientNums) && clientNums <= 0)
            {
                MessageBox.Show("Wrong client nums");
                return;
            }
            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("Network UnAvailable");
                return;
            }

            IPHostEntry host = Dns.GetHostByAddress(tbServerIP.Text);
            IPAddress[] addressList = host.AddressList;

            if (addressList.Length < 1)
            {
                MessageBox.Show("Didn't found any server");
                return;
            }

            this.Rebots.Clear();//Clear old rebot data.
            this.lvClients.Items.Clear();//Clear List View Old Rebot Data.

            for (int i = 0; i < clientNums; i++)
            {
                NSocket.SocketLib.NSocketRebot rebot = new SocketLib.NSocketRebot(addressList[addressList.Length - 1], 7890, 1024);
                rebot.Name = "#" + i.ToString();
                rebot.SendMessage = "HELLO WORLD";
                Rebots.Add(rebot.Name, rebot);
            }

            var rebotItems = new BetterListViewItem[this.Rebots.Keys.Count];

            this.lvClients.BeginUpdate();
            int rebotIndex = 0;
            foreach (var rebot in this.Rebots.Values)
            {
                var item = new ComponentOwl.BetterListView.BetterListViewItem(new[]{string.Empty, rebot.Name,
                            rebot.DelayTime.ToString(),
                            rebot.SendLength.ToString(),
                            rebot.ReceivedLength.ToString(),
                            rebot.WorkStatus.ToString(),
                            rebot.ConnectStatus.ToString(),
                            rebot.SendSuccessTimes.ToString(),
                            rebot.SendFailureTimes.ToString(),
                            rebot.ReceivedTimes.ToString(),
                            rebot.TryConnectTimes.ToString(),
                            rebot.ConnectDelay.ToString(),
                            rebot.WorkThreadID.ToString() });
                item.Name = rebot.Name;
                rebotItems[rebotIndex++] = item;
            }
            this.lvClients.Items.AddRange(rebotItems);
            this.lvClients.EndUpdate();
            foreach (var rebot in this.Rebots.Values)
            {
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    rebot.Start();
                });
            }

            this.btnStop.Enabled = true;
        }
示例#3
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            this.btnStart.Enabled = false;
            int port = -1;

            if (int.TryParse(this.tbPort.Text, out port) && port <= 0)
            {
                MessageBox.Show("Wrong tcp port");
                return;
            }

            int clientNums = -1;

            if (int.TryParse(this.tbClientNum.Text, out clientNums) && clientNums <= 0)
            {
                MessageBox.Show("Wrong client nums");
                return;
            }
            if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("Network UnAvailable");
                return;
            }

            IPHostEntry host = Dns.GetHostByAddress(tbServerIP.Text);

            IPAddress[] addressList = host.AddressList;

            if (addressList.Length < 1)
            {
                MessageBox.Show("Didn't found any server");
                return;
            }

            this.Rebots.Clear();          //Clear old rebot data.
            this.lvClients.Items.Clear(); //Clear List View Old Rebot Data.

            for (int i = 0; i < clientNums; i++)
            {
                NSocket.SocketLib.NSocketRebot rebot = new SocketLib.NSocketRebot(addressList[addressList.Length - 1], 7890, 1024);
                rebot.Name        = "#" + i.ToString();
                rebot.SendMessage = "HELLO WORLD";
                Rebots.Add(rebot.Name, rebot);
            }

            var rebotItems = new BetterListViewItem[this.Rebots.Keys.Count];

            this.lvClients.BeginUpdate();
            int rebotIndex = 0;

            foreach (var rebot in this.Rebots.Values)
            {
                var item = new ComponentOwl.BetterListView.BetterListViewItem(new[] { string.Empty, rebot.Name,
                                                                                      rebot.DelayTime.ToString(),
                                                                                      rebot.SendLength.ToString(),
                                                                                      rebot.ReceivedLength.ToString(),
                                                                                      rebot.WorkStatus.ToString(),
                                                                                      rebot.ConnectStatus.ToString(),
                                                                                      rebot.SendSuccessTimes.ToString(),
                                                                                      rebot.SendFailureTimes.ToString(),
                                                                                      rebot.ReceivedTimes.ToString(),
                                                                                      rebot.TryConnectTimes.ToString(),
                                                                                      rebot.ConnectDelay.ToString(),
                                                                                      rebot.WorkThreadID.ToString() });
                item.Name = rebot.Name;
                rebotItems[rebotIndex++] = item;
            }
            this.lvClients.Items.AddRange(rebotItems);
            this.lvClients.EndUpdate();
            foreach (var rebot in this.Rebots.Values)
            {
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    rebot.Start();
                });
            }

            this.btnStop.Enabled = true;
        }
示例#4
0
 private void LoadItems(bool enableView = true)
 {
     itemView.BeginUpdate();
     foreach (KeyValuePair<uint, byte[]> datas in MainGXTFile.DataItems)
     {
         string dataString = System.Text.Encoding.UTF8.GetString(datas.Value);
         ComponentOwl.BetterListView.BetterListViewItem newItem = new ComponentOwl.BetterListView.BetterListViewItem();
         newItem.Text = string.Format("0x{0:X8}", datas.Key);
         newItem.SubItems.Add(dataString);
         itemView.Items.Add(newItem);
     }
     itemView.EndUpdate();
     itemView.Enabled = enableView;
 }