LevelOS-Core/UI/Dashboards/Configurações/Servicos/FtpClienteCadastroPanel.cs

111 lines
4.1 KiB
C#

using CPM;
using MLL;
using System;
using System.Drawing;
using System.Windows.Forms;
using UI;
namespace UI
{
public partial class FtpClienteCadastroPanel : FormularioModelo
{
private ModeloFtpCliente _ftp = new ModeloFtpCliente();
// Controles - Conexão
private LV_TEXTBOX1 txtId, txtNome, txtHost, txtPorta, txtDiretorio;
// Controles - Autenticação
private LV_TEXTBOX1 txtUsuario, txtSenha;
private CheckBox chkSsl, chkPassivo, chkAtivo;
// Controles - Info e Ação
private LV_TEXTBOX1 txtCriadoEm, txtAtualizadoEm;
private Button btnTestarFtp;
public FtpClienteCadastroPanel()
{
this.Titulo = "Configuração de Cliente FTP / Storage";
MontarInterface();
}
private void MontarInterface()
{
// --- SEÇÃO 1: Endereçamento ---
content.Controls.Add(CreateSectionHeader("SERVIDOR DE ARQUIVOS", 20));
txtId = AddInput(content, "ID", 20, 50, 70, 30, true);
txtNome = AddInput(content, "NOME DA CONEXÃO (EX: BACKUP CLOUD)", 100, 50, 350, 30);
txtHost = AddInput(content, "HOST / IP (EX: ftp.meusite.com)", 20, 105, 330, 30);
txtPorta = AddInput(content, "PORTA", 360, 105, 90, 30);
chkSsl = new CheckBox { Text = "USAR SSL/TLS", Location = new Point(470, 121), AutoSize = true };
chkPassivo = new CheckBox { Text = "MODO PASSIVO", Location = new Point(580, 121), AutoSize = true, Checked = true };
chkAtivo = new CheckBox { Text = "ATIVO", Location = new Point(700, 121), AutoSize = true, Checked = true };
content.Controls.Add(chkSsl);
content.Controls.Add(chkPassivo);
content.Controls.Add(chkAtivo);
// --- SEÇÃO 2: Credenciais e Caminhos ---
content.Controls.Add(CreateSectionHeader("AUTENTICAÇÃO E DIRETÓRIO", 165));
txtUsuario = AddInput(content, "USUÁRIO", 20, 195, 250, 30);
txtSenha = AddInput(content, "SENHA", 280, 195, 200, 30);
txtSenha.PasswordChar = '●';
txtDiretorio = AddInput(content, "DIRETÓRIO RAIZ (EX: /public_html/backups)", 20, 250, 460, 30);
btnTestarFtp = new Button
{
Text = "📁 Testar Acesso",
Location = new Point(500, 266),
Size = new Size(150, 30),
BackColor = Color.FromArgb(0, 122, 204),
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat,
Font = new Font("Segoe UI", 9, FontStyle.Bold)
};
btnTestarFtp.Click += (s, e) => MessageBox.Show("Tentando conectar ao servidor FTP...");
content.Controls.Add(btnTestarFtp);
// --- SEÇÃO 3: Datas ---
content.Controls.Add(CreateSectionHeader("LOG DE REGISTRO", 310));
txtCriadoEm = AddInput(content, "CRIADO EM", 20, 340, 185, 30, true);
txtAtualizadoEm = AddInput(content, "ÚLT. ATUALIZAÇÃO", 215, 340, 185, 30, true);
content.Height = 400;
}
private void PreencherModel()
{
_ftp.Nome = txtNome.Text;
_ftp.Host = txtHost.Text;
_ftp.Porta = int.TryParse(txtPorta.Text, out int p) ? p : 21;
_ftp.Usuario = txtUsuario.Text;
_ftp.Senha = txtSenha.Text;
_ftp.UsarSsl = chkSsl.Checked;
_ftp.ModoPassivo = chkPassivo.Checked;
_ftp.DiretorioRaiz = txtDiretorio.Text;
_ftp.Ativo = chkAtivo.Checked;
}
protected override void OnNovo()
{
_ftp = new ModeloFtpCliente();
txtPorta.Text = "21";
txtNome.Focus();
}
protected override void OnSalvar()
{
PreencherModel();
MessageBox.Show("Configuração FTP salva com sucesso!", "LevelOS Storage", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
protected override void OnAlterar() { }
protected override void OnExcluir() { }
protected override void OnLocalizar() { }
protected override void OnCancelar() { }
}
}