Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void
Esempio n. 1
0
        public void CanSwitchBetweenRenderWindows()
        {
            using (var form = new Form())
            {
                form.ClientSize = new Size(800, 600);

                IRenderWindow renderWindow = new XnaRenderWindow(form.Handle);

                form.KeyPress +=
                    delegate(object sender, KeyPressEventArgs args)
                    {
                        if (args.KeyChar == 'p')
                        {
                            renderWindow.TakeScreenshot("test.bmp");
                        }
                        else if (args.KeyChar == 's')
                        {
                            if (renderWindow is XnaRenderWindow)
                            {
                                renderWindow.Dispose();
                                renderWindow = new SlimDXRenderWindow(form.Handle);
                            }
                            else
                            {
                                renderWindow.Dispose();
                                renderWindow = new XnaRenderWindow(form.Handle);
                            }
                        }
                    };

                Application.Idle +=
                    delegate
                    {
                        renderWindow.Render();

                        Application.DoEvents();
                    };

                Application.Run(form);

                if (renderWindow != null)
                {
                    renderWindow.Dispose();
                }
            }
        }
Esempio n. 2
0
        public void CanSwitchBetweenRenderWindowsWhenRenderingIsDoneInAControl()
        {
            using (var form = new Form())
            {
                form.ClientSize = new Size(1024, 760);

                var button = new Button { Size = new Size(800, 600), Top = 112, Left = 80, Parent = form };

                IntPtr handle = button.Handle;
                IRenderWindow renderWindow = new XnaRenderWindow(handle);

                button.KeyPress +=
                    delegate(object sender, KeyPressEventArgs args)
                    {
                        if (args.KeyChar == 'p')
                        {
                            renderWindow.TakeScreenshot("test.bmp");
                        }
                        else if (args.KeyChar == 's')
                        {
                            if (renderWindow is XnaRenderWindow)
                            {
                                renderWindow.Dispose();
                                renderWindow = new SlimDXRenderWindow(handle);
                            }
                            else
                            {
                                renderWindow.Dispose();
                                renderWindow = new XnaRenderWindow(handle);
                            }
                        }
                    };

                Application.Idle +=
                    delegate
                    {
                        renderWindow.Render();

                        Application.DoEvents();
                    };
                Application.Run(form);

                if (renderWindow != null)
                {
                    renderWindow.Dispose();
                }
            }
        }