Example #1
0
 private void RecoverLostDevice()
 {
     if (_VIDEO_DEVICE_ == null)
     {
         Console.WriteLine("Bad DEVICE");
     }
     try
     {
         _VIDEO_DEVICE_.TestCooperativeLevel(); //let's check what the state of the device is, if we can reset the device or not.
     }
     catch (DeviceLostException)
     {
     }
     catch (DeviceNotResetException) //The device can be reset
     {
         try
         {
             _VIDEO_DEVICE_.Reset(_DeviceParams_.PresentationParameters); //Reset the device.
         }
         catch (DeviceLostException)
         {
             Application.ExitThread();
         }
     }
 }
Example #2
0
        /// <summary>
        /// Clears the screen to a specific color.
        /// </summary>
        /// <param name="red">Red component of the color (0-255).</param>
        /// <param name="green">Green component of the color (0-255).</param>
        /// <param name="blue">Blue component of the color (0-255).</param>
        /// <returns>true if successful, false otherwise.</returns>
        public bool Clear(Int32 red, Int32 green, Int32 blue)
        {
            if (device == null)
            {
                return(false);
            }

            //Clear the backbuffer to a color
            device.Clear(ClearFlags.Target, System.Drawing.Color.FromArgb(red, green, blue), 1.0f, 0);

            // Check for alt+tab
            try
            {
                device.TestCooperativeLevel();
            }
            catch (DeviceLostException)
            {
            }
            catch (DeviceNotResetException)
            {
                Reset();
            }

            return(true);
        }
Example #3
0
 protected void AttemptRecovery()
 {
     Debug.WriteLine("AttemptRecovery()");
     try
     {
         device.TestCooperativeLevel();
         lostDevice = false;
     }
     catch (DeviceLostException)
     {
     }
     catch (DeviceNotResetException)
     {
         try
         {
             device.Reset(d3dpp);
             lostDevice = false;
         }
         catch (DeviceLostException)
         {
             // Si c'est toujours perdu ou que ca a encore été perdu, ne fait rien
         }
     }
 }