private async void set_msg() { flowLayoutPanel1.VerticalScroll.Visible = true; flowLayoutPanel1.AutoScroll = true; count = msg.find_msg_is_exist(productname); List <Resources.Message> send_msg; if (count == 0) { } else { send_msg = await msg.get_msg(productname); for (int i = 0; i < count; i++) { FlowLayoutPanel fl = new FlowLayoutPanel(); fl.Width = 487; fl.Height = 30; PictureBox picbox = new PictureBox(); picbox.Width = 30; picbox.Height = 30; set_msg_pic(picbox, await user.get_picture(send_msg[i].BuyerEmail)); picbox.Size = new System.Drawing.Size(30, 30); picbox.SizeMode = PictureBoxSizeMode.Zoom; Label sendemail = new Label(); sendemail.Width = 50; sendemail.Height = 30; sendemail.Font = new Font("微軟正黑體", 12, FontStyle.Regular); sendemail.ForeColor = Color.Navy; sendemail.Location = new Point(50, 100); if (send_msg[i].BuyerEmail == send_msg[i].OwnerEmail) { sendemail.Text = "賣家"; } else { sendemail.Text = send_msg[i].BuyerEmail; } Label sendmsg = new Label(); sendmsg.Width = 350; sendmsg.Height = 30; sendmsg.Text = send_msg[i].SendMessage; sendmsg.Location = new Point(100, 100); sendmsg.Font = new Font("微軟正黑體", 12, FontStyle.Regular); fl.Controls.Add(picbox); fl.Controls.Add(sendemail); fl.Controls.Add(sendmsg); flowLayoutPanel1.Controls.Add(fl); } } }
private async void set_pic() { WindowsFormsApplication1.Resources.UserDB user = new WindowsFormsApplication1.Resources.UserDB(); String inputString = await user.get_picture(this.mail.ToString()); byte[] imageBytes = Convert.FromBase64String(inputString); System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes); Image image = Image.FromStream(ms, true, true); Bitmap img2 = new Bitmap(image, 80, 80); pictureBox1.Image = img2; }