private void btnChooseAllFile_Click(object sender, EventArgs e) { OpenFileDialog chooseFileDialog = new OpenFileDialog() { Filter = "Image files (*.*) | *.*", Title = "Chọn một file" }; chooseFileDialog.ShowDialog(); if (!chooseFileDialog.FileName.Equals("")) { byte[] file = ChatAppUtils.ConvertFileToByte(chooseFileDialog.FileName); string[] arrFileName = chooseFileDialog.FileName.Split('\\'); string fn = arrFileName[arrFileName.Length - 1]; if (FileItem != null) { this.Controls.Remove(FileItem); FileItem = null; } FileItem = new FileItem(fn, file); this.Controls.Add(FileItem); FileItem.Location = new Point(25, 386); FileItem.BringToFront(); FileItem.ButtonCloseClick(closeFileItem); } this.txtMessage.Focus(); }
public List <ReferenceData.Entity.Account> SearchAccount(string keyword) { List <ReferenceData.Entity.Account> list = null; var resultSet = db.Usp_SearchAccountByEmailOrName(keyword).ToList(); if (resultSet.Count > 0) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; list = new List <ReferenceData.Entity.Account>(); foreach (var a in resultSet) { ReferenceData.Entity.Account acc = new ReferenceData.Entity.Account(); acc.id = (int)a.id; acc.email = a.email; acc.password = a.password; acc.firstName = a.firstName; acc.lastName = a.lastName; acc.birthday = a.birthday; acc.createdAt = a.createdAt; acc.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + a.avatar); list.Add(acc); } } return(list); }
public List <ReferenceData.Entity.Conversation> GetConversationListOfAccount(int accId) { var resultSet = db.Usp_GetConversationsByUserId(accId).ToList(); List <ReferenceData.Entity.Conversation> list = null; if (resultSet.Count > 0) { list = new List <ReferenceData.Entity.Conversation>(); string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; foreach (var c in resultSet) { ReferenceData.Entity.Conversation cvst = new ReferenceData.Entity.Conversation(); cvst.id = c.id; cvst.creatorId = c.creatorId; cvst.senderId = c.senderId; cvst.messageType = c.messageType; cvst.content = c.content; cvst.title = c.title; cvst.memberList = new AccountDAO().GetAccountByConversationId(cvst.id); if (cvst.memberList != null) { if (cvst.memberList.Count > 2) { cvst.state = true; cvst.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + c.avatar); } else { foreach (var u in cvst.memberList) { if (u.id != accId) { foreach (var onl in onlineList) { if (onl.Acc.Equals(u)) { cvst.state = true; break; } } cvst.title = u.firstName + " " + u.lastName; cvst.avatar = u.avatar; } } } } cvst.createdAt = c.createdAt; list.Add(cvst); } } return(list); }
private void btnChangeAvatar_Click(object sender, EventArgs e) { OpenFileDialog choosePictureDialog = new OpenFileDialog() { Filter = "Image files (*.png;*.jpg;*.jpeg;*.gif) | *.png;*.jpg;*.jpeg;*.gif", Title = "Chọn một file ảnh" }; choosePictureDialog.ShowDialog(); if (!choosePictureDialog.FileName.Equals("")) { Account acc = form.User; acc.avatar = ChatAppUtils.ConvertFileToByte(choosePictureDialog.FileName); new UpdateAccountHandler(form.Client).Handle(acc); } }
private void btnChangeAvatar_Click(object sender, EventArgs e) { OpenFileDialog choosePictureDialog = new OpenFileDialog() { Filter = "Image files (*.png;*.jpg;*.jpeg;*.gif) | *.png;*.jpg;*.jpeg;*.gif", Title = "Chọn một file ảnh" }; choosePictureDialog.ShowDialog(); if (!choosePictureDialog.FileName.Equals("")) { Avatar = ChatAppUtils.ConvertFileToByte(choosePictureDialog.FileName); string[] arrFileName = choosePictureDialog.FileName.Split('\\'); AvatarName = arrFileName[arrFileName.Length - 1]; pbGroupAvatar.Image = ChatAppUtils.ByteToImage(Avatar); } }
public List <ReferenceData.Entity.Message> GetMessagesByConversationId(string conversationId, int offset, int limit) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; string otherFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Another_Files\"; var resultSet = db.Usp_GetMessagesByConversationId(conversationId, offset, limit).ToList(); List <ReferenceData.Entity.Message> list = null; if (resultSet.Count > 0) { list = new List <ReferenceData.Entity.Message>(); foreach (var m in resultSet) { ReferenceData.Entity.Message message = new ReferenceData.Entity.Message(); message.id = m.id; message.conversationId = m.conversationId; message.senderId = m.senderId; message.content = m.content; message.messageType = m.messageType; if (m.messageType.Equals("FILE")) { if (getFileType(m.content).Equals("IMAGE")) { message.file = ChatAppUtils.ConvertFileToByte(imagesFolder + m.content); } else { message.file = ChatAppUtils.ConvertFileToByte(otherFolder + m.content); } } message.createdAt = m.createdAt; message.firstName = m.firstName; message.lastName = m.lastName; message.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + m.avatar); list.Add(message); } } return(list); }
public ReferenceData.Entity.Account GetAccountBySignInInfo(string email, string password) { var list = db.Usp_GetAccountBySignInInfo(email, password).ToList(); ReferenceData.Entity.Account acc = null; if (list.Count > 0) { string imagesFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\Files\Images\"; acc = new ReferenceData.Entity.Account(); foreach (var u in list) { acc.id = u.id; acc.email = u.email; acc.password = u.password; acc.firstName = u.firstName; acc.lastName = u.lastName; acc.avatar = ChatAppUtils.ConvertFileToByte(imagesFolder + u.avatar); acc.birthday = u.birthday; acc.createdAt = u.createdAt; } } return(acc); }