`ConfigForm` 負責單一用戶的 QQ 號、密碼、登入模式(正常/隱身)、QQ 執行檔路徑的編輯與持久化。
private void txtPath_Click(object sender, EventArgs e)
{
if (opfQQ.ShowDialog() == DialogResult.OK)
txtPath.Text = opfQQ.FileName;
}
點擊文字框即彈出 `OpenFileDialog`,選取 `QQ.exe` 路徑。
private bool ValidateInput()
{
if (string.IsNullOrEmpty(txtUser.Text)) { txtUser.Focus(); return false; }
if (string.IsNullOrEmpty(txtPwd.Text)) { txtPwd.Focus(); return false; }
if (string.IsNullOrEmpty(txtPath.Text)) return false;
return true;
}
必填欄位檢查,失敗時聚焦對應控件,回傳 `false` 阻止儲存。
private void LoadInfo()
{
var ui = SerializeHelper.DeserializeUserInfo();
if (ui != null)
{
txtUser.Text = ui.Username;
txtPwd.Text = ui.PassWord;
cboType.SelectedIndex = ui.Type == "41" ? 0 : 1; // 41=正常, 40=隱身
txtPath.Text = ui.Path;
}
else cboType.SelectedIndex = 0;
}
private void btnSave_Click(object sender, EventArgs e)
{
var ui = new UserInfo
{
Username = txtUser.Text.Trim(),
PassWord = txtPwd.Text,
Type = cboType.Text == "正常" ? "41" : "40",
Path = txtPath.Text
};
if (ValidateInput())
{
SerializeHelper.SerializeUserInfo(ui);
Close();
}
}