public void OnMessageRecieved(string content) { contentFromServer = contentFromServer.SetContent(content); switch (contentFromServer.Action) { case "Authorization": if (contentFromServer.Message == "True") { ClientAPI.Ban = true; } authorization.Authorized(contentFromServer.Name); break; case "SignUP": if (contentFromServer.Message == "Success") { signUP_Form.Success(true); } else if (contentFromServer.Message == "No success") { signUP_Form.Success(false); } break; case "Invite": mainWindow.CreateDialog(contentFromServer.NameDialog, false); break; case "SendMessage": if (contentFromServer.Login != ClientAPI.Login) { mainWindow.NewMessage(contentFromServer.NameDialog); } collectionOfDialogsView.GetMessage(contentFromServer.Login, contentFromServer.Message, contentFromServer.NameDialog); break; case "ShowOnlineUsers": var users = contentFromServer.Message.Split(';'); mainWindow.ShowOnlineUsers(users); break; case "ShowAllDialogs": var dialogs = contentFromServer.Message.Split(';'); mainWindow.ShowAllDialogs(dialogs); break; case "ShowBannedUsers": var bannedUsers = contentFromServer.Message.Split(';'); adminSetings.ShowUsers(bannedUsers); break; case "ShowAllUsersForAdmin": var allUsers = contentFromServer.Message.Split(';'); adminSetings.ShowUsers(allUsers); break; case "PrivatMessage": if (collectionOfDialogsView.FindDialog(contentFromServer.NameDialog) == false) { mainWindow.CreateDialog(contentFromServer.NameDialog, true); } mainWindow.NewMessage(contentFromServer.NameDialog); collectionOfDialogsView.GetMessage(contentFromServer.Login, contentFromServer.Message, contentFromServer.NameDialog); break; case "Banned": ClientAPI.Ban = true; break; case "Unbaned": ClientAPI.Ban = false; break; case "ChangePassword": MessageBox.Show("Your password has been changed", "Succes"); break; default: break; } }
private void btnOK_Click(object sender, EventArgs e) { mainWindow.CreateDialog(txtNameDialog.Text, false); ServerCommands.CreateDialog(ClientAPI.Login, txtNameDialog.Text); Close(); }