Example #1
0
        private void connectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConnectionMenu connectionMenu = new ConnectionMenu(this);
            var            path           = Path.Combine(Path.GetTempPath(), "ServerList.txt");

            if (!File.Exists(path))
            {
                File.Create(path).Close();
            }
            else
            {
                debugMenu.UpdateDebugText("Reading data from ServerList file:");

                foreach (var s in File.ReadAllLines(path))
                {
                    debugMenu.UpdateDebugText(s);
                    var serverProps = s.Split('_');
                    var server      = new Server()
                    {
                        ServerName      = serverProps[0],
                        ConnectedClient = serverProps[1],
                        ServerAddress   = IPAddress.Parse(serverProps[2]),
                        ServerPort      = int.Parse(serverProps[3])
                    };
                    connectionMenu.AddServer(server);
                }
            }


            connectionMenu.ShowDialog();
        }
Example #2
0
 /// <summary>
 /// Contructor takes a reference to ConnectionMenu allowing for direct manipulation of the
 /// current instance of the ConnectionMenu
 /// </summary>
 /// <param name="form">
 /// Reference of ConnectionMenu; Allowing direct manipulation of current instance of ConnectionMenu
 /// </param>
 public AddServerToConnectionMenu(ConnectionMenu form)
 {
     referencedConnectionMenu = form;
     InitializeComponent();
 }