Ejemplo n.º 1
0
        void MainPage_LayoutUpdated(object sender, EventArgs e)
        {
            // Create the UIElementRenderer to draw the Silverlight page to a texture.

            // Verify the page has a valid size
            if (ActualWidth <= 0 && ActualHeight <= 0)
            {
                return;
            }

            int width  = (int)ActualWidth;
            int height = (int)ActualHeight;

            // See if the UIElementRenderer is already the page's size
            if ((elementRenderer != null) &&
                (elementRenderer.Texture != null) &&
                (elementRenderer.Texture.Width == width) &&
                (elementRenderer.Texture.Height == height))
            {
                return;
            }

            // Dispose the UIElementRenderer before creating a new one
            if (elementRenderer != null)
            {
                elementRenderer.Dispose();
            }

            elementRenderer = new UIElementRenderer(this, width, height);
        }
Ejemplo n.º 2
0
        void GamePage_LayoutUpdated(object sender, EventArgs e)
        {
            int width  = (int)ActualWidth;
            int height = (int)ActualHeight;

            if (uiRenderer != null &&
                uiRenderer.Texture != null &&
                uiRenderer.Texture.Width == width &&
                uiRenderer.Texture.Height == height)
            {
                return;
            }
            // Ensure the page size is valid
            if (width <= 0 || height <= 0)
            {
                return;
            }
            //UIElementRenderer
            //    uiRenderer = this.get();
            // Do we already have a UIElementRenderer of the correct size?


            // Before constructing a new UIElementRenderer, be sure to Dispose the old one
            if (uiRenderer != null)
            {
                uiRenderer.Dispose();
            }

            uiRenderer = new UIElementRenderer(this, width, height);
        }
Ejemplo n.º 3
0
        /*public override bool animate()
         * {
         * }*/

        public void draw()
        {
            if (uirInternal != null)
            {
                uirInternal.Dispose();
            }
            uirInternal = null;
            repaint();
        }
Ejemplo n.º 4
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            // Stop the timer
            timer.Stop();

            // Set the sharing mode of the graphics device to turn off XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);

            base.OnNavigatedFrom(e);

            elementRenderer.Dispose();
            elementRenderer = null;
        }
Ejemplo n.º 5
0
        private void SetupTheUIRenderer()
        {
            if (uiRenderer != null &&
                uiRenderer.Texture != null &&
                uiRenderer.Texture.Width == 800 &&
                uiRenderer.Texture.Height == 480)
            {
                return;
            }

            // Before constructing a new UIElementRenderer, be sure to Dispose the old one
            if (uiRenderer != null)
            {
                uiRenderer.Dispose();
            }

            // Create the renderer
            uiRenderer = new UIElementRenderer(this, 800, 480);
        }
Ejemplo n.º 6
0
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            // Stop the timer
            timer.Stop();

            isActive = false;

            // Set the sharing mode of the graphics device to turn off XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(false);

            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back)
            {
                elementRenderer.Dispose();

                elementRenderer = null;
            }

            base.OnNavigatedFrom(e);
        }
Ejemplo n.º 7
0
 public void Destory()
 {
     log.I("LGame 2D Engine Shutdown");
     isClose = true;
     XNAConfig.Dispose();
     useXNAListener = false;
     if (this.sl_listener != null)
     {
         this.sl_listener.Dispose(GamePage, true);
         this.sl_listener = null;
     }
     if (UIElementRenderer != null)
     {
         UIElementRenderer.Dispose();
         UIElementRenderer = null;
     }
     if (content != null)
     {
         content.Unload();
         content = null;
     }
 }