//所有button事件 private void Button_Click(object sender, RoutedEventArgs e) { if (e.Source == sign_in)//登录事件 { try { //登录检测,true则为登录成功 bool flag = client.Login(account.Text, passward.Password); if (flag) { //登录成功首先获取到该用户的所有信息,然后为传参做准备 us = client.Userinfo(account.Text); //生成该用户的关联窗体的关系 if (CC.Users == null) { CC.Users = new List <User>(); } User newuser = new User(us.Acount); CC.Users.Add(newuser); item = CC.GetUser(us.Acount); item.LoginWindow = this; item.LoginWindow.Close(); // item.MainWindow.ShowLogin(us.Name); //再显示登录后的界面,room RoomWindow RW = new RoomWindow(us); item.RoomWindow = RW; item.RoomWindow.Show(); } else { MessageBox.Show("登录失败!"); } } catch (Exception) { MessageBox.Show("未连接到服务器!"); } } else if (e.Source == forgetPw)//忘记密码事件 { this.Close(); ForgetPwWindow FP = new ForgetPwWindow(); FP.Show(); } else if (e.Source == sign_for)//注册事件 { this.Close(); RegisteredWindow RW = new RegisteredWindow(); RW.Show(); } }
public LoginReference.User us; //用户的所有信息 public RoomWindow(LoginReference.User ustmp) { InitializeComponent(); us = ustmp; item = CC.GetUser(us.Acount); Checkinclient = new CheckinServerClient(new InstanceContext(this)); loginclient = new LoginServiceClient(); if (us.Avart == null) { us.Avart = "boy.png"; } this.photo.Source = new BitmapImage(new Uri("pack://application:,,,/image/" + us.Avart)); Checkinclient.Login(us.Name); }
//传参方式的变化 public MainWindow(LoginReference.User ustmp) { InitializeComponent(); us = ustmp; item = CC.GetUser(us.Acount); }