/// <summary>
        /// Present the back buffer of the swap chain.
        /// </summary>
        public virtual void Present()
        {
            // The application may optionally specify "dirty" or "scroll" rects to improve efficiency
            // in certain scenarios. In this sample we do not utilize those features.
            var parameters = new SharpDX.DXGI.PresentParameters();

            try
            {
                // If enabled the first argument instructs DXGI to block until VSync,
                // putting the application to sleep until the next VSync.
                // This ensures we don't waste any CPU/GPU cycles rendering frames that will never
                // be displayed to the screen.
                _swapChain.Present((VSync ? 1 : 0), SharpDX.DXGI.PresentFlags.None, parameters);
            }
            catch (SharpDX.SharpDXException ex)
            {
                // If the device was removed either by a disconnect or a driver upgrade, we
                // must completely reinitialize the renderer.
                if (ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceRemoved ||
                    ex.ResultCode == SharpDX.DXGI.ResultCode.DeviceReset)
                {
                    DeviceManager.Initialize(DeviceManager.Dpi);
                }
                else
                {
                    throw;
                }
            }
        }
        /// <summary>
        /// Initialize the attached DeviceManager and trigger an initial
        /// OnSizeChanged event.
        /// </summary>
        public virtual void Initialize()
        {
            // Initialize the device manager
            DeviceManager.Initialize();

            // We trigger an initial size change to ensure all
            // render buffers and size dependent resources have the
            // correct dimensions.
            SizeChanged();
        }