程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> C#實現的QQ登錄器(2)

C#實現的QQ登錄器(2)

編輯:關於C語言

ConfigForm.cs 配置窗體

Code

[copy to clipboard]

CODE:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace QQLogin
{
  public partial class ConfigForm : Form
  {
    UserInfo ui;
    public ConfigForm()
    {
      InitializeComponent();
    }
    private void txtPath_Click(object sender, EventArgs e)
    {//點擊一次文本框,彈出一次對話框來選擇QQ路徑
      DialogResult dr = this.opfQQ.ShowDialog();
      if (dr == DialogResult.OK)
      {
        this.txtPath.Text = opfQQ.FileName;
      }
    }
    private bool ValidateInput()
    {//驗證是否輸入完整
      if (this.txtUser.Text == "")
      {
        this.txtUser.Focus();
        return false;
      }
      else if (this.txtPwd.Text == "")
      {
        this.txtPwd.Focus();
        return false;
      }
      else if (this.txtPath.Text == "")
      {
        return false;
      }
      return true;
    }
    private void btnCancel_Click(object sender, EventArgs e)
    {
      this.Close();
    }
    private void ConfigForm_Load(object sender, EventArgs e)
    {
      LoadInfo();
    }
    private void btnSave_Click(object sender, EventArgs e)
    {
      ui = new UserInfo();
      ui.Username = this.txtUser.Text.Trim();
      ui.PassWord = this.txtPwd.Text;
      ui.Type = this.cboType.Text == "正常" ? "41" : "40";
      ui.Path = this.txtPath.Text;
      if (this.ValidateInput())
      {
        SerializeHelper.SerializeUserInfo(ui);        
        this.Close();
      }
    }
    private void LoadInfo()
    {
      ui = SerializeHelper.DeserializeUserInfo();
      if (ui != null)
      {
        this.txtUser.Text = ui.Username;
        this.txtPwd.Text = ui.PassWord;
        this.cboType.SelectedIndex = ui.Type == "41" ? 0 : 1;
        this.txtPath.Text = ui.Path;
      }
      else
      {
        this.cboType.SelectedIndex = 0;
      }
    }
  }
}

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved