/// <summary> /// OK按钮被点击 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OKButton_Click(object sender, EventArgs e) { Ram.UserName = UserNameTextBox.Text; Ram.PassWord = PassWordTextBox.Text; Master.SavePassWord(); string JsonText = TTMaster.Login(UserNameTextBox.Text, PassWordTextBox.Text); string loginStatus = ""; try { loginStatus = TTMaster.loginJson(JsonText); } catch { goto TT; } if (loginStatus == "ok") { Ram.serverStatus = TTMaster.ServerJson(JsonText); MetroMessageBox.Show(this, "恭喜你登录成功", "TT提示"); Main main = new Main(this); main.ShowDialog(); } else { MetroMessageBox.Show(this, "用户名或者账号错误", "TT提示"); } TT: MetroMessageBox.Show(this, "皓月服务器无法连接,请稍后再试", "TT提示"); //Environment.Exit(0); }
/// <summary> /// 刷新服务器按钮被点击 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void 刷新服务器ToolStripMenuItem_Click(object sender, EventArgs e) { ServerList.Items.Clear(); Ram.serverList.Clear(); Ram.serverName.Clear(); Ram.serverPlayerCount.Clear(); Ram.joinServer.Clear(); string jsonText = TTMaster.Login(Ram.UserName, Ram.PassWord); try { Ram.serverStatus = TTMaster.ServerJson(jsonText); } catch { MetroMessageBox.Show(this, "皓月服务器炸了,刷新不出来,请稍后再试", "温馨提示"); } ServerListF5(); 加入服务器ToolStripMenuItem.Enabled = false; }