Exemplo n.º 1
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);
                }
            }));
        }
Exemplo n.º 2
0
        void HandleFramebufferChanged(object sender, FramebufferChangedEventArgs e)
        {
            BeginInvoke(new Action(() =>
            {
                if (DesignMode)
                {
                    return;
                }

                if (_client == null)
                {
                    return;
                }

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

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

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

                for (int i = 0; i < e.RectangleCount; i++)
                {
                    var rect = e.GetRectangle(i);
                    //设置要更新的区域
                    //Invalidate(new Rectangle(rect.X, rect.Y, rect.Width, rect.Height));
                    Invalidate(new Rectangle(0, 0, this.Width, this.Height));
                }
            }));
        }