Пример #1
0
        public void Render()
        {
            if (_bitmap1 == null || _renderTarget2D == null)
            {
                return;
            }

            DeviceContext.Target = _bitmap1;
            using (DeviceContext.Target)
            {
                DeviceContext.BeginDraw();
                if (this.needsClear)
                {
                    DeviceContext.Clear(this.ClearColor);
                    this.needsClear = false;
                }
                while (_queue.Count > 0)
                {
                    CanvasObject o = _queue.Dequeue();
                    o.DoWork(DeviceContext);
                }
                DeviceContext.EndDraw();
            }
            DeviceContext.Target = null;

            _spriteBatch.Begin(SpriteSortMode.Immediate, this._graphicsDeviceManager.GraphicsDevice.BlendStates.NonPremultiplied);
            _spriteBatch.Draw(_renderTarget2D, Vector2.Zero, Color.White);
            _spriteBatch.End();
        }
Пример #2
0
        public void PushObject(CanvasObject canvasObject)
        {
            if (canvasObject == null)
            {
                throw new ArgumentNullException("canvasObject");
            }
            bool isInitialized = canvasObject.IsInitialized;

            if (!isInitialized)
            {
                canvasObject.Initialize(DeviceContext);
            }
            _objects.Add(canvasObject);
            _queue.Enqueue(canvasObject);

            State = CanvasState.Append;
        }