示例#1
0
        private void addServerButton_Click(object sender, EventArgs e)
        {
            string serverName = InputBox.Show(
                "Please enter the server address",
                "Please enter the server address",
                "http://yourserver.org/path/to/update/folder/");

            if (serverName == null)
            {
                return;
            }
            serverName = serverName.Trim();
            if (!serverName.EndsWith("/"))
            {
                serverName += "/";
            }

            if (serverList.Items.Contains(serverName))
            {
                MessageBox.Show("Server already listed. Adding nothing", "Server already listed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (!serverName.StartsWith("http://"))
            {
                MessageBox.Show("Only http servers are supported", "Server not http", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            UpdateWindow oUpdateWindow = new UpdateWindow(MainForm.Instance, MainForm.Instance.Settings, true);

            if (oUpdateWindow.GetUpdateXML(serverName) != UpdateWindow.ErrorState.Successful)
            {
                if (MessageBox.Show("The server or the XML file is not available.\r\nShould it be added nevertheless?", "No connection to server", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
            }
            serverList.Items.Add(serverName);
        }