//注册 private void buttonRegister_Click(object sender, EventArgs e) { UserLogin.UserManager usma = new UserLogin.UserManager(); usma.user = textBoxUser.Text; usma.pass = UserLogin.UserManager.GetMD5Hash(textBoxPass.Text); usma.check = checkBox1.Checked; if (usma.Register()) { MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); TurnToLogin_Click(sender, e); } }
//自动登陆 private void LoginForm_Load(object sender, EventArgs e) { if (File.Exists("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt")) { this.Hide(); this.ShowInTaskbar = false; StreamReader sr = new StreamReader("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt"); UserLogin.UserManager usma = new UserLogin.UserManager(); FilePath = sr.ReadLine(); usma.user = sr.ReadLine(); usma.pass = sr.ReadToEnd(); sr.Close(); if (usma.Login()) { this.notifyIcon1.Visible = true; string hostName = usma.user + "+" + Dns.GetHostName(); t=new Sync.TimingSyncThread(hostName, FilePath); } else { //this.Show(); this.ShowInTaskbar = true; } } }
//点击注册,跳转注册页面 //单击登陆按钮事件 private void buttonLogin_Click(object sender, EventArgs e) { UserLogin.UserManager usma = new UserLogin.UserManager(); usma.user = textBoxUser.Text; usma.pass = UserLogin.UserManager.GetMD5Hash(textBoxPass.Text); if (usma.Login()) { //暂时先放在这,如果没有FilePath,则创建之, if (!Directory.Exists(FilePath)) { Directory.CreateDirectory(FilePath); } MessageBox.Show("登录成功,双击托盘图标打开同步的文件夹!", "Easybox"); this.Hide(); this.notifyIcon1.Visible = true; StreamWriter sw = new StreamWriter("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt",false); sw.WriteLine(FilePath); sw.WriteLine(usma.user); sw.Write(usma.pass); sw.Close(); File.SetAttributes("C:\\users\\"+Environment.UserName+"\\AppData\\Roaming\\Easybox\\test.txt", FileAttributes.Hidden); String hostName = usma.user + "+" + Dns.GetHostName(); t=new Sync.TimingSyncThread(hostName, FilePath); } }