I am currently working on a Level Editor for XNA which is built by combining Windows Forms and XNA. I am using stuff from the example on App Hub link text, but I have made some changes, so I have some ViewportController class which manages all the viewport controls, instead of the form manages them directly. The problem is that when I need to update the Draw method I have to shake the window. Anybody knows how to fix this, so the Draw will update realtime?
相关问题
- F#: Storing and mapping a list of functions
- Is it possible to restore a GraphicsDevice if some
- How do I bind a DataGridViewComboBoxColumn to a pr
- Partial Form Class C# - Only display code view for
- Can we add four protocols to ServicePointManager.S
相关文章
- Sort TreeView Automatically Upon Adding Nodes
- Where does this quality loss on Images come from?
- Missing partial modifier on declaration of type
- PropertyGrid - Possible to have a file/directory s
- Why do base Windows Forms form class with generic
- How to handle the TextChanged event only when the
- Difference between SuspendLayout and BeginUpdate
- Adding Combobox to DataGridView Headers
Not sure what a ViewportController might be. However, the Draw() method is triggered by a Windows paint request. That runs the Control.OnPaint() method, there is an override for it in the GraphicsDeviceControl class which causes Draw() to run.
The sample SpinningTriangleControl shows how you'd get a control to redraw itself repeatedly, what you'd need to get it animated:
Note the Control.Invalidate() method call, that's what eventually causes the OnPaint() method to run. Using the Idle event ensures this is done over and over again but only if the main thread isn't otherwise busy with anything. This isn't necessary for controls that show only static content, like the sample SpriteFontControl. Another way to do it is to use a Timer with a short Interval, its Tick event handler can call Invalidate().