private DeviceResetError HandleDeviceReset() { bool needsReset; var clientSize = ClientSize; if (GraphicsDevice == null) { return(DeviceResetError.None); } switch (GraphicsDevice.GraphicsDeviceStatus) { case GraphicsDeviceStatus.Lost: return(DeviceResetError.DeviceLost); case GraphicsDeviceStatus.NotReset: needsReset = true; break; default: var pp = GraphicsDevice.PresentationParameters; needsReset = clientSize.Width > pp.BackBufferWidth || clientSize.Height > pp.BackBufferHeight; break; } if (needsReset) { if (GraphicsDeviceService == null) { return(DeviceResetError.Failed); } try { GraphicsDeviceService.ResetDevice(clientSize.Width, clientSize.Height); } catch (Exception ex) { Debug.Print(ex.ToString()); return(DeviceResetError.Failed); } } return(DeviceResetError.None); }