Example #1
0
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
        {
            if (!DesignerProperties.GetIsInDesignMode(this) && _graphicsDeviceService != null)
            {
                _imageSource.Dispose();
                _imageSource     = new XnaImageSource(GraphicsDevice, (int)ActualWidth, (int)ActualHeight);
                RootImage.Source = _imageSource.WriteableBitmap;
            }

            base.OnRenderSizeChanged(sizeInfo);
        }
Example #2
0
        private void InitializeGraphicsDevice()
        {
            if (_graphicsDeviceService != null)
            {
                return;
            }

            // Adiciona refefĂȘncia do graphics device
            _graphicsDeviceService = GraphicsDeviceService.AddRef((PresentationSource.FromVisual(this) as HwndSource).Handle);

            // cria um image source
            _imageSource     = new XnaImageSource(GraphicsDevice, (int)ActualWidth, (int)ActualHeight);
            RootImage.Source = _imageSource.WriteableBitmap;

            _services.AddService(typeof(IGraphicsDeviceService), _graphicsDeviceService);

            _totalTime   = new TimeSpan(DateTime.Now.Ticks);
            _elapsedTime = new TimeSpan(DateTime.Now.Ticks);

            CompositionTarget.Rendering += CompositionTarget_Rendering;
        }