protected override void OnCreateControl()
 {
     if (!this.DesignMode)
     {
         IntPtr handle     = this.Handle;
         Size   clientSize = this.ClientSize;
         int    width      = clientSize.Width;
         clientSize = this.ClientSize;
         int height = clientSize.Height;
         this.graphicsDeviceService = GraphicsDeviceService.AddRef(handle, width, height);
         this.services.AddService <IGraphicsDeviceService>((IGraphicsDeviceService)this.graphicsDeviceService);
         this.Initialize();
     }
     base.OnCreateControl();
 }
        private string HandleDeviceReset()
        {
            bool flag;

            switch (this.GraphicsDevice.GraphicsDeviceStatus - 1)
            {
            case GraphicsDeviceStatus.Normal:
                return("Graphics device lost");

            case GraphicsDeviceStatus.Lost:
                flag = true;
                break;

            default:
                PresentationParameters presentationParameters = this.GraphicsDevice.PresentationParameters;
                flag = this.ClientSize.Width > presentationParameters.BackBufferWidth || this.ClientSize.Height > presentationParameters.BackBufferHeight;
                break;
            }
            if (flag)
            {
                try
                {
                    GraphicsDeviceService graphicsDeviceService = this.graphicsDeviceService;
                    Size clientSize = this.ClientSize;
                    int  width      = clientSize.Width;
                    clientSize = this.ClientSize;
                    int height = clientSize.Height;
                    graphicsDeviceService.ResetDevice(width, height);
                }
                catch (Exception ex)
                {
                    return("Graphics device reset failed\n\n" + (object)ex);
                }
            }
            return((string)null);
        }