private void ButtonRegisterClick(object sender, EventArgs e) { if (string.IsNullOrEmpty(textEmail.Text)) { MessageBox.Show("Please enter an email"); return; } if (string.IsNullOrEmpty(textNick.Text)) { MessageBox.Show("Please enter a nickname"); return; } if (string.IsNullOrEmpty(textPass.Text)) { MessageBox.Show("Please enter a password"); return; } if (textPass.Text != textConfirmPass.Text) { MessageBox.Show("Please ensure the password match"); return; } FormMain.Client.Connect(FormMain.IPADDRESS, FormMain.PORT); var creq = Packets.CreateRequest(textEmail.Text, textPass.Text, textNick.Text); FormMain.Client.WritePacket(creq); labelRegister.Visible = true; }
private void UserListUpdate(string rawdata) { var data = rawdata.Deserialize(); onlineList.Clear(); foreach (var user in data) { var attr = user.Deserialize(); string nick = attr[0]; string role = attr[1]; bool isbanned = attr[2].ToLower() == "true"; string userid = attr[3]; var contextMenu = new ContextMenu(); var ban = new MenuItem("Ban", (a, b) => Client.WritePacket(Packets.UpdateRole(userid, "banned"))); var unban = new MenuItem("Unban", (a, b) => Client.WritePacket(Packets.UpdateRole(userid, "unbanned"))); var admin = new MenuItem("Admin", (a, b) => Client.WritePacket(Packets.UpdateRole(userid, Sets.UserRole.Admin))); var reg = new MenuItem("Regularize", (a, b) => Client.WritePacket(Packets.UpdateRole(userid, Sets.UserRole.Regular))); var kill = new MenuItem("Kill", (a, b) => Client.WritePacket(Packets.Kill(userid))); contextMenu.MenuItems.AddRange(new[] { admin, reg, GetSep(), ban, unban, GetSep(), kill }); onlineList.Controls.Add( new CustomItem() { Nickname = nick, Status = (isbanned) ? "banned" : role, ContextMenu = contextMenu }); } }
private void ButtonChangePassClick(object sender, EventArgs e) { string newPass = ""; var result = InputBox.Show("Change your password", "Edit your password, then press submit to save changes", ref newPass, true); if (result == DialogResult.OK) { Client.WritePacket(Packets.UpdatePassword(newPass)); } }
private void ButtonChangeNickClick(object sender, EventArgs e) { string newNickname = CurrentNickname; var result = InputBox.Show("Change your nickname", "Edit your nickname, then press submit to save changes", ref newNickname, false); if (result == DialogResult.OK) { Client.WritePacket(Packets.UpdateNickname(newNickname)); CurrentNickname = newNickname; } }