Helper class responsible for creating and managing the GraphicsDevice. All GraphicsDeviceControl instances share the same GraphicsDeviceService, so even though there can be many controls, there will only ever be a single underlying GraphicsDevice. This implements the standard IGraphicsDeviceService interface, which provides notification events for when the device is reset or disposed.
Inheritance: IGraphicsDeviceService
        protected override void Dispose(bool disposing)
        {
            // Release our reference to the GraphicsDeviceService if we have one
            if (graphicsService != null)
            {
                graphicsService.Release(disposing);
                graphicsService = null;
            }

            // Unhook the Rendering event so we no longer attempt to draw
            CompositionTarget.Rendering -= CompositionTarget_Rendering;

            base.Dispose(disposing);
        }
Beispiel #2
0
        bool InitGraphicsDevice()
        {
            // If we don't yet have a GraphicsDeviceService reference, we must add one for this control
            if (graphicsService == null || graphicsService.GraphicsDevice == null || graphicsService.GraphicsDevice.IsDisposed)
            {
                graphicsService = GraphicsDeviceService.AddRef(hWnd, (int)ActualWidth, (int)ActualHeight);
                // Invoke the LoadContent event
                if (LoadContent != null)
                {
                    LoadContent(this, new GraphicsDeviceEventArgs(graphicsService.GraphicsDevice));
                }

                return(true);
            }

            return(false);
        }
 void XnaWindowHost_Loaded(object sender, RoutedEventArgs e)
 {
     // If we don't yet have a GraphicsDeviceService reference, we must add one for this control
     if (graphicsService == null)
     {
         graphicsService = GraphicsDeviceService.AddRef(hWnd, (int)ActualWidth, (int)ActualHeight);
         // Invoke the LoadContent event
         if (LoadContent != null)
             LoadContent(this, new GraphicsDeviceEventArgs(graphicsService.GraphicsDevice));
     }
 }
        protected override void Dispose(bool disposing)
        {
            // Release our reference to the GraphicsDeviceService if we have one
            if (graphicsService != null)
            {
                graphicsService.Release(disposing);
                graphicsService = null;
            }

            // Unhook the Rendering event so we no longer attempt to draw
            CompositionTarget.Rendering -= CompositionTarget_Rendering;

            base.Dispose(disposing);
        }
        bool InitGraphicsDevice()
        {
            // If we don't yet have a GraphicsDeviceService reference, we must add one for this control
            if (graphicsService == null || graphicsService.GraphicsDevice == null || graphicsService.GraphicsDevice.IsDisposed)
            {
                graphicsService = GraphicsDeviceService.AddRef(hWnd, (int)ActualWidth, (int)ActualHeight);
                // Invoke the LoadContent event
                if (LoadContent != null)
                    LoadContent(this, new GraphicsDeviceEventArgs(graphicsService.GraphicsDevice));

                return true;
            }

            return false;
        }