Example #1
0
        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));
                }
            }
        }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            // Release our reference to the GraphicsDeviceService if we have one
            if (graphicsService != null)
            {
                graphicsService.Release(disposing);
                graphicsService = null;
            }

            if (timer != null)
            {
                timer.Stop();
                timer.Tick -= timer_Tick;
                timer       = null;
            }

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

            base.Dispose(disposing);
        }