예제 #1
0
        /// <summary>
        /// BeforeRender - Make sure we have a Graphics object to render to.
        /// If we don't have one, then create one to match the SvgWindow's
        /// physical dimensions.
        /// </summary>
        private void RendererBeforeRender()
        {
            // Testing for null here allows "advanced" developers to create their own Graphics object for rendering
            if (_graphics == null)
            {
                // Get the current SVGWindow's width and height
                int innerWidth  = (int)_svgWindow.InnerWidth;
                int innerHeight = (int)_svgWindow.InnerHeight;

                // Make sure we have an actual area to render to
                if (innerWidth > 0 && innerHeight > 0)
                {
                    // See if we already have a rasterImage that matches the current SVGWindow dimensions
                    if (_rasterImage == null || _rasterImage.Width != innerWidth || _rasterImage.Height != innerHeight)
                    {
                        // Nope, so create one
                        if (_rasterImage != null)
                        {
                            _rasterImage.Dispose();
                            _rasterImage = null;
                        }
                        _rasterImage = new Bitmap(innerWidth, innerHeight);
                    }

                    // Make a GraphicsWrapper object from the rasterImage and clear it to the background color
//                    _graphics = GdiGraphicsWrapper.FromImage(_rasterImage, _isStatic);
                    _graphics = GdiGraphicsImpl.FromImage(_rasterImage, _isStatic);
                    _graphics.Clear(_backColor);

                    _hitTestHelper = _graphics.HitTestHelper;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// AfterRender - Dispose of Graphics object created for rendering.
        /// </summary>
        private void OnAfterRender()
        {
            if (_ownsGraphics)
            {
                if (_graphics != null)
                {
                    if (_hitTestHelper != null)
                    {
                        if (_hitTestHelper != _graphics.HitTestHelper)
                        {
                            _hitTestHelper.Dispose();
                            _hitTestHelper = _graphics.HitTestHelper;
                        }
                    }

                    _graphics.HitTestHelper = GdiHitTestHelper.NoHit; // Prevent disposal actual height test
                    _graphics.Dispose();
                    _graphics = null;
                }
            }

            if (_hitTestHelper == null)
            {
                _hitTestHelper = GdiHitTestHelper.NoHit;
            }
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the GdiRenderer class.
 /// </summary>
 public GdiGraphicsRenderer(bool isStatic = false, bool disposeRaster = true)
 {
     _isStatic      = isStatic;
     _disposeRaster = disposeRaster;
     _invalidRect   = SvgRectF.Empty;
     _backColor     = Color.White;
     _hitTestHelper = GdiHitTestHelper.NoHit;
     _svgRenderer   = new GdiRenderingHelper(this);
 }
예제 #4
0
        protected override void Dispose(bool disposing)
        {
            if (_hitTestHelper != null)
            {
                _hitTestHelper.Dispose();
            }
            _hitTestHelper = null;

            base.Dispose(disposing);
        }
예제 #5
0
        private void Dispose(bool disposing)
        {
            if (_hitTestHelper != null)
            {
                _hitTestHelper.Dispose();
            }
            if (_disposeRaster && _rasterImage != null)
            {
                _rasterImage.Dispose();
            }
            if (_graphics != null)
            {
                _graphics.Dispose();
            }

            _graphics      = null;
            _rasterImage   = null;
            _hitTestHelper = null;
        }
예제 #6
0
 public void ClearAll()
 {
     if (_graphics != null)
     {
         _graphics.Dispose();
         _graphics = null;
     }
     if (_rasterImage != null)
     {
         _rasterImage.Dispose();
         _rasterImage = null;
     }
     if (_hitTestHelper != null)
     {
         _hitTestHelper.Dispose();
         _hitTestHelper = null;
     }
     _hitTestHelper = GdiHitTestHelper.NoHit;
 }