using KMCCC.Authentication; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace CTZLauncher { /// /// Window1.xaml 的交互逻辑 /// public partial class RegisterWindow : Window { string serveraddress; int serverport; public RegisterWindow(string serveraddress, int serverport) { InitializeComponent(); this.serveraddress = serveraddress; this.serverport = serverport; } private void reg_Click(object sender, RoutedEventArgs e) { reg.IsEnabled = false; if (username.Text.Length == 0 || password.Text.Length == 0) { MessageBox.Show("请输入账号密码!"); return; } CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport); try { if (auth.isRegistered()) { MessageBox.Show("该用户名已注册 请更换用户名!"); return; } if (auth.Register()) { MessageBox.Show("注册成功!"); Close(); } else MessageBox.Show("注册失败!"); } catch (ArgumentNullException ex) { MessageBox.Show(ex.Message); } finally { reg.IsEnabled = true; } } } }