Exemplo n.º 1
0
        private void PopulateValidIPs()
        {
            foreach (var ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
            {
                if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    comboBoxServerIP.Items.Add(ip.ToString());
                }
            }

            if (File.Exists(Settings.CustomIPsFile))
            {
                foreach (var line in File.ReadAllLines(Settings.CustomIPsFile))
                {
                    if (AddServerIpForm.IsValidIP(line))
                    {
                        comboBoxServerIP.Items.Add(line);
                    }
                }
            }

            if (comboBoxServerIP.Items.Count > 0)
            {
                comboBoxServerIP.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        private void linkLabelAddServerIp_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var ipForm = new AddServerIpForm();

            if (ipForm.ShowDialog() == DialogResult.OK)
            {
                comboBoxServerIP.Items.Add(ipForm.IP);
                var ipsList = new List <string>();
                if (File.Exists(Settings.CustomIPsFile))
                {
                    ipsList.AddRange(File.ReadAllLines(Settings.CustomIPsFile));
                }
                ipsList.Add(ipForm.IP);
                File.WriteAllLines(Settings.CustomIPsFile, ipsList);
            }
        }
Exemplo n.º 3
0
 private bool IsValidIP()
 {
     return(AddServerIpForm.IsValidIP(textBoxPS4IP.Text));
 }