Encapsulates the Xna-device so that it renders in the given window.
Наследование: IRenderWindow
Пример #1
0
        /// <summary>
        /// Creates a new render window.
        /// </summary>
        /// <param name="control">The control in which the content will be rendered.</param>
        /// <returns>A new created render window.</returns>
        public IRenderWindow CreateRenderWindow(Control control)
        {
            var renderWindow = new XnaRenderWindow(control.Handle);

            mDevice = renderWindow.Device;

            return renderWindow;
        }
Пример #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();
                }
            }
        }
Пример #3
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();
                }
            }
        }