private void btnChange_Click(object sender, EventArgs e) { if (btnChange.Text == "Изменить") { txtIP.Enabled = true; txtPort.Enabled = true; txtUserName.Enabled = true; btnChange.Text = "Сохранить"; } else { string ip, userName; int port; ip = txtIP.Text; port = Convert.ToInt32(txtPort.Text); userName = txtUserName.Text; XMLFileManager.SaveConfig(config_xml, ip, port, userName); txtIP.Enabled = false; txtPort.Enabled = false; txtUserName.Enabled = false; btnChange.Text = "Изменить"; } }
private void Form1_Load(object sender, EventArgs e) { if (File.Exists(config_xml)) { string ip, userName; int port; XMLFileManager.LoadConfig(config_xml, out ip, out port, out userName); if (ip != null && port != 0 && userName != null) { txtIP.Text = ip; txtPort.Text = port.ToString(); txtUserName.Text = userName; } else { ip = "127.0.0.1"; port = 2500; userName = "******"; txtIP.Text = ip; txtPort.Text = port.ToString(); txtUserName.Text = userName; XMLFileManager.SaveConfig(config_xml, ip, port, userName); } } else { string ip, userName; int port; ip = "127.0.0.1"; port = 2500; userName = "******"; txtIP.Text = ip; txtPort.Text = port.ToString(); txtUserName.Text = userName; XMLFileManager.SaveConfig(config_xml, ip, port, userName); } }