コード例 #1
0
        //Selected index changed on the ListView gets the selected Client and sets Textboxes.
        public void ClientsLView_SelectedIndexChanged(object sender, EventArgs e)
        {
            lock (serverLocker)
            {
                if (ServerWorking)
                {
                    ListView list          = (ListView)sender;
                    int      selectedIndex = 0;
                    foreach (int i in list.SelectedIndices)
                    {
                        selectedIndex = i;
                    }
                    ClientHandler c = (ClientHandler)list.Items[selectedIndex].Tag;
                    SelectedClient = c;


                    IpTextbox.BeginInvoke(txtDelegate,
                                          SelectedClient.ClientIep.Address.ToString(),
                                          IpTextbox, false);
                    PortTextbox.BeginInvoke(txtDelegate,
                                            SelectedClient.ClientIep.Port.ToString(),
                                            PortTextbox, false);
                    NameTextbox.BeginInvoke(txtDelegate,
                                            SelectedClient.Name,
                                            NameTextbox, false);
                }
            }
        }
コード例 #2
0
        //Refreshes ListView with all conected clients and refreshes selected client info.
        public void RefreshInfo()
        {
            lock (serverLocker)
            {
                if (ServerWorking)
                {
                    ClientsListView.BeginInvoke(lstClearDelegate, ClientsListView);
                    for (int i = 0; i < connectedClients.Count; i++)
                    {
                        ClientsListView.BeginInvoke(lstAddDelegate, connectedClients[i], i, 0, ClientsListView);
                    }

                    if (SelectedClient != null)
                    {
                        IpTextbox.BeginInvoke(txtDelegate,
                                              SelectedClient.ClientIep.Address.ToString(),
                                              IpTextbox, false);
                        PortTextbox.BeginInvoke(txtDelegate,
                                                SelectedClient.ClientIep.Port.ToString(),
                                                PortTextbox, false);
                        NameTextbox.BeginInvoke(txtDelegate,
                                                SelectedClient.Name,
                                                NameTextbox, false);
                    }
                    else
                    {
                        IpTextbox.BeginInvoke(txtDelegate,
                                              "-",
                                              IpTextbox, false);
                        PortTextbox.BeginInvoke(txtDelegate,
                                                "-",
                                                PortTextbox, false);
                        NameTextbox.BeginInvoke(txtDelegate,
                                                "-",
                                                NameTextbox, false);
                    }
                }
            }
        }