示例#1
0
        private void UpdateFramebuffer(bool force, VncFramebuffer framebuffer)
        {
            if (framebuffer == null)
            {
                return;
            }

            int w = framebuffer.Width, h = framebuffer.Height;

            if (this.bitmap == null || this.bitmap.Width != w || this.bitmap.Height != h || force)
            {
                this.bitmap = new Bitmap(w, h, PixelFormat.Format32bppRgb);
                VncBitmap.CopyFromFramebuffer(framebuffer, new VncRectangle(0, 0, w, h), this.bitmap, 0, 0);

                this.ScaleFactor = this.GetScaleFactor(framebuffer);
                this.Invalidate();
            }
        }
示例#2
0
        private void HandleFramebufferChanged(object sender, FramebufferChangedEventArgs e)
        {
            this.BeginInvoke(new Action(() =>
            {
                if (this.DesignMode)
                {
                    return;
                }

                if (this.client == null)
                {
                    return;
                }

                var framebuffer = this.client.Framebuffer;
                if (framebuffer == null)
                {
                    return;
                }

                lock (framebuffer.SyncRoot)
                {
                    this.UpdateFramebuffer(false, framebuffer);

                    if (this.bitmap != null)
                    {
                        for (int i = 0; i < e.RectangleCount; i++)
                        {
                            var rect = e.GetRectangle(i);
                            VncBitmap.CopyFromFramebuffer(framebuffer, rect, this.bitmap, rect.X, rect.Y);
                        }
                    }
                }

                for (int i = 0; i < e.RectangleCount; i++)
                {
                    var rect            = e.GetRectangle(i);
                    var transformedRect = this.Transform(
                        new Rectangle(rect.X, rect.Y, rect.Width, rect.Height),
                        TransformDirection.FromDevice);
                    this.Invalidate(transformedRect);
                }
            }));
        }