Пример #1
0
        /// <summary></summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (device != null && !DesignMode && HandleDeviceReset() && application.IsInitailised)
            {
                // Draw the control using the GraphicsDevice.
                winFormWrapper.RunMainLoop();

                Rectangle sourceRectangle = new Rectangle(0, 0, ClientSize.Width,
                                                          ClientSize.Height);
                try
                {
                    if (device != null)
                    {
                        device.GraphicsDevice.Present(sourceRectangle, null, this.Handle);
                    }
                }
                catch (InvalidOperationException)
                {
                }
                catch (DeviceLostException)
                {
                }
                catch (DeviceNotResetException)
                {
                }
                catch (DriverInternalErrorException)
                {
                }

                if (autoRedraw)
                {
                    Invalidate();
                }
            }
            else
            {
                // If not in a drawable state, show a message using System.Drawing.
                PaintUsingSystemDrawing(e.Graphics);
            }
        }