Пример #1
0
        /// <summary>
        /// Completes a manual framebuffer update.
        ///
        /// Do not call this method without holding <see cref="VncServerSession.FramebufferUpdateRequestLock"/>.
        /// </summary>
        public bool FramebufferManualEndUpdate()
        {
            var fb = Framebuffer;

            if (_clientWidth != fb.Width || _clientHeight != fb.Height)
            {
                if (_clientEncoding.Contains(VncEncoding.PseudoDesktopSize))
                {
                    var region = new VncRectangle(0, 0, fb.Width, fb.Height);
                    AddRegion(region, VncEncoding.PseudoDesktopSize, new byte[0]);
                    _clientWidth = Framebuffer.Width; _clientHeight = Framebuffer.Height;
                }
            }

            if (_fbuRectangles.Count == 0)
            {
                return(false);
            }
            FramebufferUpdateRequest = null;

            lock (_c.SyncRoot)
            {
                _c.Send(new byte[2] {
                    0, 0
                });
                _c.SendUInt16BE((ushort)_fbuRectangles.Count);

                foreach (var rectangle in _fbuRectangles)
                {
                    _c.SendRectangle(rectangle.Region);
                    _c.SendUInt32BE((uint)rectangle.Encoding);
                    _c.Send(rectangle.Contents);
                }

                _fbuRectangles.Clear(); return(true);
            }
        }