Esempio n. 1
0
        private void EditServer(object sender, EventArgs e)
        {
            NewServer editServer = new NewServer();

            editServer.Text = "Edit Server";

            ServerData data = (ServerData)m_Form.ServerListView.FocusedItem.Tag;

            editServer.textBox_IPAddress.Text     = data.m_IPAddress;
            editServer.textBox_Port.Text          = data.m_port.ToString();
            editServer.textBox_FilePath.Text      = data.m_ServerDirectory;
            editServer.textBox_Launch.Text        = data.m_LaunchOption;
            editServer.checkBox_useLocalP.Checked = data.m_useLocalIP;

            if (true == data.m_useLocalIP)
            {
                editServer.textBox_IPAddress.Enabled = false;
                editServer.textBox_FilePath.Enabled  = true;
                editServer.textBox_Launch.Enabled    = true;
            }
            else
            {
                editServer.textBox_IPAddress.Enabled = true;
                editServer.textBox_FilePath.Enabled  = false;
                editServer.textBox_Launch.Enabled    = false;
            }

            if (editServer.ShowDialog() == DialogResult.OK)
            {
                data.m_IPAddress       = editServer.Data.m_IPAddress;
                data.m_port            = editServer.Data.m_port;
                data.m_ServerDirectory = editServer.Data.m_ServerDirectory;
                data.m_LaunchOption    = editServer.Data.m_LaunchOption;

                data.InitSocket();

                if (null != data.m_Thread && true == data.m_Thread.IsAlive)
                {
                    return;
                }

                data.m_Thread = new Thread(new ThreadStart(data.CheckServer));
                data.m_Thread.Start();

                SaveFile();
            }

            editServer.Dispose();
        }
Esempio n. 2
0
        private void NewServer(object sender, EventArgs e)
        {
            NewServer newServer = new NewServer();

            if (newServer.ShowDialog() == DialogResult.OK)
            {
                ListViewItem item = new ListViewItem();

                newServer.Data.InitServerData(m_Form, item, m_Form.listView_Player);
                newServer.Data.InitSocket();

                item.Tag = newServer.Data;

                item.Text = "";
                item.SubItems.Add(""); // IP
                item.SubItems.Add(""); // Port
                item.SubItems.Add(""); // Players
                item.SubItems.Add(""); // Map
                item.SubItems.Add(""); // PStatus
                item.SubItems.Add(""); // SStatus

                item.UseItemStyleForSubItems = false;

                m_Form.ServerListView.Items.Add(item);

                if (null != newServer.Data.m_Thread && true == newServer.Data.m_Thread.IsAlive)
                {
                    return;
                }

                newServer.Data.m_Thread = new Thread(new ThreadStart(newServer.Data.CheckServer));
                newServer.Data.m_Thread.Start();

                SaveFile();
            }

            newServer.Dispose();
        }