private int CallBackViewProfile(Data received) { if (received.Command == Data.DataType.ViewProfile) { User user = (User)received.Other; UserProfilForm profilForm = new UserProfilForm(user, true); this.Invoke((MethodInvoker)delegate() { profilForm.ShowDialog(); }); } else { //MessageBox.Show("ERROR!!!."); } return 0; }
private int CallBackViewProfile(Data received) { if (received.Command == Data.DataType.ViewProfile) { User user = (User)received.Other; if (user == null) { MessageBox.Show("Cet utilisateur n'existe plus sous ce nom.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { bool readOnly = user.UserName != actualClient.UserName; UserProfilForm profilForm = new UserProfilForm(user, readOnly); DialogResult result = DialogResult.None; this.Invoke((MethodInvoker)delegate() { result = profilForm.ShowDialog(); }); if (!readOnly) { if (result == DialogResult.OK) { actualClient = user; } else { actualClient = profilForm.oldClient; } this.Invoke((MethodInvoker)delegate() { labelUserName.Text = actualClient.UserName; labelAvatar.Image = (Bitmap)Resources.ResourceManager.GetObject(actualClient.Avatar); }); } } Data listUserRequest = new Data(); listUserRequest.Command = Data.DataType.ListClient; Program.callBackOnReceive.Enqueue(CallBackListClient); Program.client.Send(listUserRequest); } else { //MessageBox.Show("ERROR!!!."); } return 0; }