How to run a C# winform in an XNA C# project
Someone asked on Stack Overflow:
I am trying to use the PDFsharp library in an XNA game. The example code I am trying to get to work is:
static void Main() { Renderer renderer = new Renderer(); PreviewForm form = new PreviewForm(); form.RenderEvent = new PagePreview.RenderEvent(renderer.Render); Application.Run(form); }But I don’t know how to get this to run in XNA.
Is it possible to pass the graphics that are passed to the winform to the XNA graphics engine instead?
I posted the following answer, which was chosen as the accepted answer:
update 2
It appears that the original links to MSDN have been broken, I can’t seem to find them on MSDN anymore, if someone does, please update the post. In the mean time you may want to check out this codeproject article — http://www.codeproject.com/Articles/21330/Easy-Rendering-with-XNA-Inside-a-Windows-Form
update after a quick check, looks like the first link at (See also: XNA and WinForms) is the same one I found.
I recommend you look into mixing winforms and XNA, try this: http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1
Notable comments
Nate (0 upvotes): @user1306322 I have updated my post with another link and a request for anyone who finds the new location of the broken link to update the post.
Originally posted on Stack Overflow — 0 upvotes (accepted answer). Licensed under CC BY-SA.