コード例 #1
0
        private void OnAddServerClick(object sender, RoutedEventArgs e)
        {
            var hostName = DirectIPTextBox.Text;

            DirectIPTextBox.Text = "";

            if (string.IsNullOrEmpty(hostName))
            {
                return;
            }

            try
            {
                var host = System.Net.Dns.GetHostEntry(hostName);
                var addr = host.AddressList.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork);
                if (addr == null)
                {
                    return;
                }

                //#TODO let user provide port with :
                //#TODO only add if doesn't exist yet
                var newEndpoint = new TacControlEndpoint {
                    Address = new IPEndPoint(addr, 8082), ClientID = hostName, LastActvity = DateTime.Now
                };
                networking.AvailableEndpoints.Add(newEndpoint);

                // also add to config
                AppConfig.Instance.GetEntry <ICollection <TacControlEndpoint> >("Networking.DirectEndpoints").Add(newEndpoint);
            }
            catch (System.Net.Sockets.SocketException)
            {
                // throws exception if "could not resolve host"
                return;
            }
        }
コード例 #2
0
 private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     CurrentEndpoint         = e.AddedItems[0] as TacControlEndpoint;
     ConnectButton.IsEnabled = true;
 }
コード例 #3
0
 private void ListView_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
 {
     CurrentEndpoint         = e.SelectedItem as TacControlEndpoint;
     ConnectButton.IsEnabled = true;
 }