using EFCDesk.Classes; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls.Primitives; using System.Windows.Forms; using static System.Windows.Forms.VisualStyles.VisualStyleElement; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; namespace EFCDesk.Forms { public partial class FormConfiguracionJSON : Form { private ConfiguracionJSON _config; public FormConfiguracionJSON() { InitializeComponent(); _config = ConfiguracionJSON.LoadFromJson(); // Cargar los valores actuales en los controles if (_config.ProxyNingunoGenerico) { radioProxyGenericoHTTP.Checked = true; radioProxyGenericoNinguno.Checked = false; textBoxProxyGenericoNombreServidor.Text = _config.ServidorProxyGenerico; textBoxProxyGenericoPuertoServidor.Text = _config.PuertoProxyGenerico.ToString(); } else { radioProxyGenericoNinguno.Checked = true; textBoxProxyGenericoNombreServidor.Enabled = false; textBoxProxyGenericoPuertoServidor.Enabled = false; } if (_config.AuthProxyGenerico) { textBoxProxyGenericoUsuario.Text = _config.UsuarioProxyGenerico; textBoxProxyGenericoPassword.Text = _config.PasswordProxyGenerico; checkBoxProxyGenericoAuthProxy.Checked = true; textBoxProxyGenericoUsuario.Enabled = true; textBoxProxyGenericoPassword.Enabled = true; } else { textBoxProxyGenericoUsuario.Enabled = false; textBoxProxyGenericoPassword.Enabled = false; } if (_config.ProxyFTPNinguno) { radioButtonProxyFTPNinguno.Checked = false; radioButtonProxyFTP.Checked = true; textBoxProxyFTPNombreServidor.Text = _config.ServidorProxyFTP; textBoxProxyFTPPuerto.Text = _config.PuertoProxyFTP.ToString(); } else { radioButtonProxyFTPNinguno.Checked = true; textBoxProxyFTPNombreServidor.Enabled = false; textBoxProxyFTPPuerto.Enabled = false; } if (_config.AuthProxyFTP) { textBoxProxyFTPUsuario.Text = _config.UsuarioProxyFTP; textBoxProxyFTPPassword.Text = _config.PasswordProxyFTP; checkBoxProxyFTPAuth.Checked = true; textBoxProxyFTPUsuario.Enabled = true; textBoxProxyFTPPassword.Enabled = true; } else { textBoxProxyFTPUsuario.Enabled = false; textBoxProxyFTPPassword.Enabled = false; } textBoxDominio.Text = _config.DominioExp; } private void label5_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { if (radioProxyGenericoNinguno.Checked) { _config.ProxyNingunoGenerico = false; _config.ServidorProxyGenerico = ""; int.TryParse(textBoxProxyGenericoPuertoServidor.Text, out int puerto); _config.PuertoProxyGenerico = puerto; } else { _config.ProxyNingunoGenerico = true; _config.ServidorProxyGenerico = textBoxProxyGenericoNombreServidor.Text; _config.PuertoProxyGenerico = 0; } if (checkBoxProxyGenericoAuthProxy.Checked) { _config.AuthProxyGenerico = true; _config.UsuarioProxyGenerico = textBoxProxyGenericoUsuario.Text; _config.PasswordProxyGenerico = textBoxProxyGenericoPassword.Text; } else { _config.AuthProxyGenerico = false; _config.UsuarioProxyGenerico = ""; _config.PasswordProxyGenerico = ""; } if (radioButtonProxyFTPNinguno.Checked) { _config.ProxyFTPNinguno = false; _config.ServidorProxyFTP = ""; _config.PuertoProxyFTP = 0; } else { _config.ProxyFTPNinguno = true; _config.ServidorProxyFTP = textBoxProxyFTPNombreServidor.Text; int.TryParse(textBoxProxyFTPPuerto.Text, out int puerto); _config.PuertoProxyFTP = puerto; /*if (radioButton1.Checked) { MyClass.configuracion("tipoproxyFTP", "SOCKS5"); }*/ } if (checkBoxProxyFTPAuth.Checked) { _config.AuthProxyFTP = true; _config.UsuarioProxyFTP = textBoxProxyFTPUsuario.Text; _config.PasswordProxyFTP = textBoxProxyFTPPassword.Text; } else { _config.AuthProxyFTP = false; _config.UsuarioProxyFTP = ""; _config.PasswordProxyFTP = ""; } _config.DominioExp = textBoxDominio.Text; Properties.Settings.Default.urlEFC = _config.DominioExp; Properties.Settings.Default.Save(); _config.SaveToJson(); Application.Restart(); } private void radioProxyGenericoNinguno_CheckedChanged(object sender, EventArgs e) { if (radioProxyGenericoNinguno.Checked == true) { textBoxProxyGenericoNombreServidor.Enabled = false; textBoxProxyGenericoPuertoServidor.Enabled = false; } } private void radioProxyGenericoHTTP_CheckedChanged(object sender, EventArgs e) { if (radioProxyGenericoHTTP.Checked == true) { textBoxProxyGenericoNombreServidor.Enabled = true; textBoxProxyGenericoPuertoServidor.Enabled = true; } } private void buttonCancelar_Click(object sender, EventArgs e) { this.Close(); } private void FormConfiguracionJSON_Load(object sender, EventArgs e) { TabPage? tabOculta; tabOculta = tabControl1.TabPages["tabPage1"]; if (tabOculta != null) { tabControl1.TabPages.Remove(tabOculta); } // Mostrarla de nuevo // tabControl1.TabPages.Add(tabOculta); tabOculta = tabControl1.TabPages["tabPage2"]; if (tabOculta != null) { tabControl1.TabPages.Remove(tabOculta); } } private void checkBoxProxyGenericoAuthProxy_CheckedChanged(object sender, EventArgs e) { if (!checkBoxProxyGenericoAuthProxy.Checked) { textBoxProxyGenericoUsuario.Enabled = false; textBoxProxyGenericoPassword.Enabled = false; } else { textBoxProxyGenericoUsuario.Enabled = true; textBoxProxyGenericoPassword.Enabled = true; } } private void radioButtonProxyFTPNinguno_CheckedChanged(object sender, EventArgs e) { if (radioButtonProxyFTPNinguno.Checked == true) { textBoxProxyFTPNombreServidor.Enabled = false; textBoxProxyFTPPuerto.Enabled = false; } } private void radioButtonProxyFTP_CheckedChanged(object sender, EventArgs e) { if (radioButtonProxyFTP.Checked == true) { textBoxProxyFTPNombreServidor.Enabled = true; textBoxProxyFTPPuerto.Enabled = true; } } private void checkBoxProxyFTPAuth_CheckedChanged(object sender, EventArgs e) { if (!checkBoxProxyFTPAuth.Checked) { textBoxProxyFTPUsuario.Enabled = false; textBoxProxyFTPPassword.Enabled = false; } else { textBoxProxyFTPUsuario.Enabled = true; textBoxProxyFTPPassword.Enabled = true; } } } }