示例#1
0
 private void AddImageOutgoing(Image image)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((MethodInvoker) delegate()
         {
             var width        = (int)Math.Ceiling((decimal)image.Width / 350);
             var height       = (int)Math.Ceiling((decimal)image.Height / 350);
             var c            = Math.Max(width, height);
             width            = (int)Math.Floor((decimal)image.Width / c);
             height           = (int)Math.Floor((decimal)image.Height / c);
             var imageZip     = ResizeImage(image, width, height);
             var piccontainer = new Panel();
             var pic          = new PicSent()
             {
                 Image = imageZip, Size = imageZip.Size, ImageOriginal = image
             };
             pic.Width          += 10;
             piccontainer.Height = pic.Height + 10;
             piccontainer.Controls.Add(pic);
             pic.Dock = DockStyle.Right;
             panel3.Controls.Add(piccontainer);
             piccontainer.Dock = DockStyle.Top;
             piccontainer.BringToFront();
             ScrollToBottom();
         });
     }
     else
     {
         var width  = (int)Math.Ceiling((decimal)image.Width / 350);
         var height = (int)Math.Ceiling((decimal)image.Height / 350);
         var c      = Math.Max(width, height);
         width  = (int)Math.Floor((decimal)image.Width / c);
         height = (int)Math.Floor((decimal)image.Height / c);
         var imageZip     = ResizeImage(image, width, height);
         var piccontainer = new Panel();
         var pic          = new PicSent()
         {
             Image = imageZip, Size = imageZip.Size, ImageOriginal = image
         };
         pic.Width          += 10;
         piccontainer.Height = pic.Height + 10;
         piccontainer.Controls.Add(pic);
         pic.Dock = DockStyle.Right;
         panel3.Controls.Add(piccontainer);
         piccontainer.Dock = DockStyle.Top;
         piccontainer.BringToFront();
         ScrollToBottom();
     }
 }
示例#2
0
 private void AddImageIncoming(Image image, string user)
 {
     if (this.InvokeRequired)
     {
         this.BeginInvoke((MethodInvoker) delegate()
         {
             var width        = (int)Math.Ceiling((decimal)image.Width / 350);
             var height       = (int)Math.Ceiling((decimal)image.Height / 350);
             var c            = Math.Max(width, height);
             width            = (int)Math.Floor((decimal)image.Width / c);
             height           = (int)Math.Floor((decimal)image.Height / c);
             var imageZip     = ResizeImage(image, width, height);
             var piccontainer = new Panel();
             var pic          = new PicSent()
             {
                 Image = imageZip, Size = imageZip.Size, ImageOriginal = image
             };
             var username = new Label()
             {
                 Text = user, Font = new Font("Segoe UI Semibold", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)))
             };
             username.Width     -= 60;
             piccontainer.Height = pic.Height + 10;
             piccontainer.Controls.Add(pic);
             username.Dock = DockStyle.Left;
             piccontainer.Controls.Add(username);
             pic.Dock = DockStyle.Left;
             panel3.Controls.Add(piccontainer);
             piccontainer.Dock = DockStyle.Top;
             piccontainer.BringToFront();
             ScrollToBottom();
         });
     }
     else
     {
         var width  = (int)Math.Ceiling((decimal)image.Width / 350);
         var height = (int)Math.Ceiling((decimal)image.Height / 350);
         var c      = Math.Max(width, height);
         width  = (int)Math.Floor((decimal)image.Width / c);
         height = (int)Math.Floor((decimal)image.Height / c);
         var imageZip     = ResizeImage(image, width, height);
         var piccontainer = new Panel();
         var pic          = new PicSent()
         {
             Image = imageZip, Size = imageZip.Size, ImageOriginal = image
         };
         var username = new Label()
         {
             Text = user, Font = new Font("Segoe UI Semibold", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)))
         };
         username.Width     -= 60;
         piccontainer.Height = pic.Height + 10;
         piccontainer.Controls.Add(pic);
         username.Dock = DockStyle.Left;
         piccontainer.Controls.Add(username);
         pic.Dock = DockStyle.Left;
         panel3.Controls.Add(piccontainer);
         piccontainer.Dock = DockStyle.Top;
         piccontainer.BringToFront();
         ScrollToBottom();
     }
 }