Ejemplo n.º 1
0
        /// <summary>
        /// This is the standard RenderMessageHandler callback, posted via PostRender()
        /// and Resize().  This wraps RenderMessageHandlerCore and emits an ETW events
        /// to trace its execution.
        /// </summary>
        internal object RenderMessageHandler(object arg)
        {
            try
            {
                _isRendering = true;

                //_screen.Clear();

                if (_invokeOnRenderCallbacks != null)
                {
                    int callbackLoopCount = 0;
                    int count = _invokeOnRenderCallbacks.Count;

                    while (count > 0)
                    {
                        callbackLoopCount++;
                        if (callbackLoopCount > 153)
                        {
                            throw new InvalidOperationException("infinite loop");
                        }

                        InvokeOnRenderCallback[] callbacks;

                        lock (_invokeOnRenderCallbacks)
                        {
                            count = _invokeOnRenderCallbacks.Count;
                            callbacks = new InvokeOnRenderCallback[count];

                            _invokeOnRenderCallbacks.CopyTo(callbacks);
                            _invokeOnRenderCallbacks.Clear();
                        }

                        for (int i = 0; i < count; i++)
                        {
                            callbacks[i].DoWork();
                        }

                        count = _invokeOnRenderCallbacks.Count;
                    }
                }

                DrawingContext dc = new DrawingContext(_screen);

                /* The dirty rectange MUST be read after the InvokeOnRender callbacks are
                 * complete, as they can trigger layout changes or invalidate controls
                 * which are expected to be redrawn. */
                int x = _dirtyX0;
                int y = _dirtyY0;
                int w = _dirtyX1 - _dirtyX0;
                int h = _dirtyY1 - _dirtyY0;
                _dirtyX0 = _screenW; _dirtyY0 = _screenH;
                _dirtyX1 = _dirtyY1 = 0;

                try
                {
                    if (w > 0 && h > 0)
                    {
                        //
                        // This is the big Render!
                        //
                        // We've now updated layout and the updated scene will be
                        // rendered.
                        dc.PushClippingRectangle(x, y, w, h);
                        _target.RenderRecursive(dc);
                        dc.PopClippingRectangle();
                    }
                }
                finally
                {
                    dc.Close();
                    if (w > 0 && h > 0)
                    {
                        _screen.Flush(x, y, w, h);
                    }
                }
            }
            finally
            {
                _currentRenderOp = null;
                _isRendering = false;
            }

            return null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the standard RenderMessageHandler callback, posted via PostRender()
        /// and Resize().  This wraps RenderMessageHandlerCore and emits an ETW events
        /// to trace its execution.
        /// </summary>
        internal object RenderMessageHandler(object arg)
        {
            try {
                this._isRendering = true;

                //_screen.Clear();

                if (this._invokeOnRenderCallbacks != null)
                {
                    var callbackLoopCount = 0;
                    var count             = this._invokeOnRenderCallbacks.Count;

                    while (count > 0)
                    {
                        callbackLoopCount++;
                        if (callbackLoopCount > 153)
                        {
                            throw new InvalidOperationException("infinite loop");
                        }

                        InvokeOnRenderCallback[] callbacks;

                        lock (this._invokeOnRenderCallbacks) {
                            count     = this._invokeOnRenderCallbacks.Count;
                            callbacks = new InvokeOnRenderCallback[count];

                            this._invokeOnRenderCallbacks.CopyTo(callbacks);
                            this._invokeOnRenderCallbacks.Clear();
                        }

                        for (var i = 0; i < count; i++)
                        {
                            callbacks[i].DoWork();
                        }

                        count = this._invokeOnRenderCallbacks.Count;
                    }
                }

                var dc = new DrawingContext(this._screen);

                /* The dirty rectange MUST be read after the InvokeOnRender callbacks are
                 * complete, as they can trigger layout changes or invalidate controls
                 * which are expected to be redrawn. */
                var x = this._dirtyX0;
                var y = this._dirtyY0;
                var w = this._dirtyX1 - this._dirtyX0;
                var h = this._dirtyY1 - this._dirtyY0;
                this._dirtyX0 = this._screenW; this._dirtyY0 = this._screenH;
                this._dirtyX1 = this._dirtyY1 = 0;

                try {
                    if (w > 0 && h > 0)
                    {
                        //
                        // This is the big Render!
                        //
                        // We've now updated layout and the updated scene will be
                        // rendered.
                        dc.PushClippingRectangle(x, y, w, h);
                        this._target.RenderRecursive(dc);
                        dc.PopClippingRectangle();
                    }
                }
                finally {
                    dc.Close();
                    if (w > 0 && h > 0)
                    {
                        this._screen.Flush(x, y, w, h);
                    }
                }
            }
            finally {
                this._currentRenderOp = null;
                this._isRendering     = false;
            }

            return(null);
        }
Ejemplo n.º 3
0
 internal object RenderMessageHandler(object arg)
 {
     try
     {
         this._isRendering = true;
         if (this._invokeOnRenderCallbacks != null)
         {
             int num5 = 0;
             for (int i = this._invokeOnRenderCallbacks.Count; i > 0; i = this._invokeOnRenderCallbacks.Count)
             {
                 InvokeOnRenderCallback[] callbackArray;
                 num5++;
                 if (num5 > 0x99)
                 {
                     throw new InvalidOperationException("infinite loop");
                 }
                 ArrayList list = this._invokeOnRenderCallbacks;
                 lock (list)
                 {
                     i             = this._invokeOnRenderCallbacks.Count;
                     callbackArray = new InvokeOnRenderCallback[i];
                     this._invokeOnRenderCallbacks.CopyTo(callbackArray);
                     this._invokeOnRenderCallbacks.Clear();
                 }
                 for (int j = 0; j < i; j++)
                 {
                     callbackArray[j].DoWork();
                 }
             }
         }
         DrawingContext dc     = new DrawingContext(this._screen);
         int            x      = this._dirtyX0;
         int            y      = this._dirtyY0;
         int            width  = this._dirtyX1 - this._dirtyX0;
         int            height = this._dirtyY1 - this._dirtyY0;
         this._dirtyX0 = this._screenW;
         this._dirtyY0 = this._screenH;
         this._dirtyX1 = this._dirtyY1 = 0;
         try
         {
             if ((width > 0) && (height > 0))
             {
                 dc.PushClippingRectangle(x, y, width, height);
                 this._target.RenderRecursive(dc);
                 dc.PopClippingRectangle();
             }
         }
         finally
         {
             dc.Close();
             if ((width > 0) && (height > 0))
             {
                 this._screen.Flush(x, y, width, height);
             }
         }
     }
     finally
     {
         this._currentRenderOp = null;
         this._isRendering     = false;
     }
     return(null);
 }